Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: dfurlano on January 18, 2010, 09:54:04 PM

Title: Opto switches behaving badly
Post by: dfurlano on January 18, 2010, 09:54:04 PM
Dear Friends (can you tell I need help?)

I wanted to add homing switches to my mini mill.  After looking around I decided on purchasing these Opto Endstops switches; http://reprap.org/bin/view/Main/OptoEndstop_2_1 from searching the forums this switch seemed like a reasonable choice, a standard 5v source and easy to assemble.

So I assembled the switch and mounted it as shown on the Z axis.  Of course I did a bench test and every thing seemed ok.  Here is a photo of the Z opto endstop;

http://www.dfurlano.com/optoz.jpg

I created a small cover and taped it over the switch (in white) used a cat5 cable and I then connected the switch to a 5v power connector from inside my PC.  I checked the voltage and I was getting 5v in and 4.2v out of the switch.  When I move the Z up the LED lights and the voltage goes to zero and I thought I was ready to go.

After some consideration I thought I would buy a second parallel port for my PC after searching the forum I found that people had successfully used the SIIG Cyberpro board so I purchased a new one from Newegg and installed it in my PC.  I set the address for the SIIG and it again seemed to function properly.  

I then mounted all four homing switches and bench tested them. All seemed to work.  Then my luck ran out.  When I began testing I found first that some LED's were remaining lit after homing.  I read that the procedure is to hit the switch and then back off so it does not stay triggered.  Well I was getting all confused about what was going on so I started over with just the Z being connected.  But it is clear something is wrong not only does the LED remain lit but most times the homing stops short of actually triggering the switch.  I checked the voltage and clearly when I am off the switch I read 4.2v and when I am on I read zero.  Not sure if 4.2v is not good enough and that is why it is randomly stopping (seems odd that it would work then not work) or do I have another problem?

I somehow need to trouble shoot what is going on.  I tried to find a printer port monitor but the only one I can find have preset addresses to monitor the ports and my second port is not one of the presets.  

I am lost on what I should try and do and I was hoping that someone could give me a suggestion or offer any advice on how to figure this out.

As always thanks in advance for your help.

Dan
Title: Re: Opto switches behaving badly
Post by: Chaoticone on January 19, 2010, 01:27:38 AM
Dan, I'm thinking it may be noise. Do you have any debounce set in General config.? I'm a little confused about your post. If it does a homeing routine does the leds stay on after they should have moved off? If you jog away from the switches do the LEDs go out once you clear them? If your BOB is opticaly isolated and the switches that can cause a problem. Dual optical isolation isn't a good thing.

Brett
Title: Re: Opto switches behaving badly
Post by: simpson36 on January 19, 2010, 02:44:57 AM
See if there is voltage present at the BOB inputs.

I have all opto and two PP. On one of my BOBs, the input pins have about 1.2v on them all the time. No idea why the voltatge is there,  but it causes unreliable operation. I put resistors fropm the pins to ground to pull them down to zero volts and the problems went away.

The other BOB is a different brand and does not have the same behavior.
Title: Re: Opto switches behaving badly
Post by: dfurlano on January 19, 2010, 08:20:11 AM
Guys thanks for the replys.  One very important point I forgot to tell you.  I have a Gecko G540 and after I searched the forum I decided to go directly into the printer port with the output signal from the Opto switches.  I am using 10,11,12,13 on the second parallel port. 

The LED staying on after homing is not consistent.  If the LED is on I get a message that a limit switch is active.  If I jog off the switch the LED does go off.

I will also check the debounce (I did not set it)  but for some reason I thought that was only for mechanical switches.  I will try this tonight when I get home.

Thanks

Dan
Title: Re: Opto switches behaving badly
Post by: BClemens on January 19, 2010, 09:38:42 AM
Most all opto switches do have debounce in their circuit already - a schmidt trigger. But it will not hurt a thing to add a bit more delay in Mach3.
Title: Re: Opto switches behaving badly
Post by: dfurlano on January 19, 2010, 05:01:48 PM
I put a value of 100 in for both inputs and after some short testing the Z seems to work very well.  I will do more later but it looks to have solved the problem.

Thanks to everyone who responded, very much appreciated.

Dan
Title: Re: Opto switches behaving badly
Post by: Chaoticone on January 19, 2010, 06:19:43 PM
Good Dan, hopefuly your all set. Simpsons solution may be the most robust though. If setting debouce helps your problem it will tell us it is most likely noise. I should have explained it a little better. Debouce increases the time a signal state change has to be seen to be considered changed. For troubleshootiing you can set the debounce pretty high but if you have to set it very high to make the switches stable I would prefer resistors like simpson said. Other things to consider are wire routing and shielding.

Brett
Title: Re: Opto switches behaving badly
Post by: simpson36 on January 20, 2010, 06:01:55 AM
In extreme cases in very noisy environments, you can also opt to run the signal side of the opto at 12V for more noise immunity. You then need to knock the 12V down to 5V be for connecting to the BOB.

I am making a little circuit board for signal boosting and running remote LEDs. It can also be used for the above mentioned task of knocking a high voltage signal down to 5V.

This is a video showing my previous mill routing the little boards. You will see the finished board at the end of the vid. Routing PCBs is new to me and it is really fun.

http://www.youtube.com/watch?v=r9Zf_5yHB1I
Title: Re: Opto switches behaving badly
Post by: dfurlano on January 20, 2010, 09:39:44 AM
Currently I have the debounce at 30 for the Z axis.   It seems to work at 25 but I thought I would just be sure with 30.  I will find out if it changes once I hook up the other three switches and then I can decide what if anything else I should do to reduce the debounce. 

It sounds like there are 3 options to reducing the debounce;

1) Add a BOB of some type.
2) Somehow better isolating to reduce noise (grounding, shielding)
3) Increasing the opto to 12v for better noise immunity

Any other suggestions?

Dan
Title: Re: Opto switches behaving badly
Post by: simpson36 on January 20, 2010, 10:49:48 AM
Be aware that debounce delays the recognition of a 'hit', so you may need to slow your homing so that the axis does not slam into the end of travel while the computer is figuring out if the signal is real or not.  :'(

Title: Re: Opto switches behaving badly
Post by: dfurlano on January 20, 2010, 11:10:01 AM
At 10 inches per minute the z can move 0.005" in 30 milliseconds.  The homing seems to be very consistent when I measure for absolute positioning.  My homing switches are no that close to the end of travel.  I have about .3" before I hit the end.
Title: Re: Opto switches behaving badly
Post by: simpson36 on January 20, 2010, 05:13:27 PM
If you have Mach3 set up to share homing and limits, you waste whatever the delta is between your trigger point and the actual physical limit.  Speaking for myself, I'm good to go on my X and Z, but I would not give up .3" of my Y.

Opto's are extremely accurate and allow you so set the trigger very close to the actual stop, that is one of the reasons I ditched the mechanical switches. Those with significant travel likely will home at a pretty good clip, so the need to be cautious about messing with the debounce is a real concern in many cases.  The relationship between debounce and homing is something useful to be aware of.
Title: Re: Opto switches behaving badly
Post by: dfurlano on January 20, 2010, 10:35:41 PM
I don't have limit switches I have never reached end of travel for the work I do.  After thinking about it I don't see why a high debounce would effect the homing switches.  I did the above calculation incorrect.  If I use a value of 100 the manual says to calculate in milliseconds the debounce you divide the value by the speed you are running at in my case 25000 hz

100/25000 = .004 or 4 milliseconds and at 10 IPM that is .0006 movement.  I have seen reports that suggest 1000 or even 2000 for debounce.  Since the routine is to back off the switch after it triggers I think it would be fairly accurate even with a high debounce but I guess the only way to know is to actually test different values.   I did see a report that showed the higher the input voltage the more accurate the positioning using an optical switch.

Dan
Title: Re: Opto switches behaving badly
Post by: simpson36 on January 21, 2010, 06:32:37 AM
I don't have limit switches I have never reached end of travel for the work I do.  After thinking about it I don't see why a high debounce would effect the homing switches. 

If you read carefully, you may note that my comment was that if you share homing and limits in Mach. You may *think* that you don't have 'limit' switches, but that is simply a semantics argument that indicates you do not understand how Mach can handle 'home' switches.

Your assumption is theoretical and overly simplistic. You do not take deceleration into account in your calculations. In your case, you have the axis literally crawling up to the switch, but in any case, an axis is not going to stop instantly when the switch is triggered. The table weight (plus the vice, fixture and workpiece), the acceleration setting, the homing speed, 'cushion' between the switch and the hard stop, and finally the debounce setting all are part of the equation that predicts 'bang' or 'no bang'.

I would be interested to see a report that states an opto is 'more accurate' with higher voltage. Do you have a link to that?


Title: Re: Opto switches behaving badly
Post by: BClemens on January 21, 2010, 07:49:59 AM


I would be interested to see a report that states an opto is 'more accurate' with higher voltage. Do you have a link to that?




A 5 volt opto switch has a propagation delay of 4 nanoseconds but that same switch has a response to 110V of 1 gigliopiconanoumous second - but only one time.
Title: Re: Opto switches behaving badly
Post by: Overloaded on January 21, 2010, 01:26:42 PM
 :) ;D :D ;D :)
Title: Re: Opto switches behaving badly
Post by: dfurlano on January 21, 2010, 01:49:51 PM
http://www.vinland.com/Opto-Interrupter.html
Title: Re: Opto switches behaving badly
Post by: BClemens on January 21, 2010, 02:58:01 PM
That's interesting....wonder if that guy ever mounted any of those switches or did he go right into checking the accuracy of the pitch of the tap for the mounting screw threads.
Title: Re: Opto switches behaving badly
Post by: dfurlano on January 21, 2010, 03:53:43 PM
I also found some interesting information here:

http://www.cnccookbook.com/CCCNCNoise.html
Title: Re: Opto switches behaving badly
Post by: BClemens on January 21, 2010, 04:20:52 PM
Good info. That makes me think how lucky I am to be past all of that - but I remember well....The machine is 'well' now and a joy of reliability.

 I had a noise issue and totally rewired the limit switches (mechanical) and a few other things that made the job of conversion tedious as hell. Then found that during the initial build, my daughter borrowed the computer that I had bought for the mill. She needed a printer so she installed one and I didn't know.....the problem was that she had left pages to be printed on the computer so the printer was being called to print - on the main parallel port that Mach3 was running the mill on. Was that noise - YES! That was resetting the Mach3 at random times. I wanted to kick the cat! (but we didn't have one)

This is totally (almost) off the subject but right in with a noise issue.

I must bring that up once in a while - it's so obvious - too obvious - and is totally overlooked.....clean up the computer first!
Title: Re: Opto switches behaving badly
Post by: dfurlano on February 19, 2010, 08:09:38 AM
This is what I ended up with.  I found an old analytical instrument that was going to be thrown out and I salvaged the box.

Inside the box I used three power supplies.  From the top there is a 12v for the spindle control.  Next is the 48v motor supply. And at the bottom I used an ATX power supply for the homing switches and cooling fans.

(http://www.dfurlano.com/box1.jpg)

This is the back I have two plugs on for the motors and spindle another for the homing and fans.

(http://www.dfurlano.com/box2.jpg)

Here is the front from the top of the box.  The Gecko G540 then the db25 (under the G540) is the spindle control, to the right is the probe and Estop. At the bottom is the db25 for the homing switches that attaches to a second parralell port and below that are the cat5 connectors to the opto endstops. 

(http://www.dfurlano.com/box3.jpg)

No more noise issues the endstops work great.

Dan
Title: Re: Opto switches behaving badly
Post by: Overloaded on February 19, 2010, 11:39:32 AM
Very nice Dan !
Glad you got it all working well.
Good work, very nice and tidy!
Russ