Photo interrupter as limit switch

danimal
Posts: 332
Joined: Wed Mar 13, 2013 5:53 pm
Location: Colorado

Photo interrupter as limit switch

Post by danimal » Thu Aug 08, 2013 2:52 am

So I bought these photo interrupters for a different project but I only need two of them. It was literally 50 cents more to order ten and have them shipped from china than it was to buy two individual ones from anywhere stateside so I figured that I would go this route and use them for limit switches if possible. Are these going to be accurate enough?

I see that they might dissipate a little too much power to be used stand alone with the arduino and would need an additional supply. I just happen to have a computer power supply that I am using in my enclosure and really it is only powering the cooling fans so there are a host of unused 3v, 5v and 12v sources that I could use to power an additional external circuit. But I am not that great at circuit design as of yet so I thought that I would appeal to everyone here for some help to get through it. I am going to be working on it as soon as I can get some time off of work, but any advice or design ideas would be greatly appreciated.

I have tons of electrical components for all kinds of applications so whatever is needed I probably have it already somewhere. I am just starting circuits 3 in college to finish up my EE so I am not completely lost, but I just do not always approach things the easiest way and I end up dancing around with all kinds of problems until the seemingly obvious solution (aka the right way) presents itself. What I am hanging up on right now is connecting the two circuits without causing any problems on the arduino. I thought about different methods of isolating it, but none of them made me have a warm feeling about my abilities to apply it successfully. I would like to avoid releasing the magic smoke from my arduino if at all possible so any help would be greatly appreciated.


http://www.amazon.com/dp/B008DG96NU/ref ... 1_ST1_dp_1
Shapeoko # 1458

RT0701C Spindle || dual y motor || x axis nema23 with custom carriage 1000mm length || z axis nema23 linear rail upgrade with 1/2-10 ACME

danimal
Posts: 332
Joined: Wed Mar 13, 2013 5:53 pm
Location: Colorado

Re: Photo interrupter as limit switch

Post by danimal » Thu Aug 08, 2013 3:02 am

If you think that it will be too much of a pain in the ass, or if they are not reliable / accurate enough let me know. I needed them for another project and wanted to have an extra or two so buying all ten just made financial sense and using them for the CNC was more of a curiosity and a challenge than anything else. I am thinking of mounting them below the axis of travel and have the motor carriage plate interrupt the signal as it approaches the end of travel. This way there would be no mechanical interference and overshooting a run would not result in limit switch striking or damage other than the normal excess travel consequences. Thoughts?
Shapeoko # 1458

RT0701C Spindle || dual y motor || x axis nema23 with custom carriage 1000mm length || z axis nema23 linear rail upgrade with 1/2-10 ACME

veng1
Posts: 250
Joined: Fri Nov 30, 2012 12:09 pm

Re: Photo interrupter as limit switch

Post by veng1 » Thu Aug 08, 2013 12:24 pm

This is a generic approach. Use the data sheet to calculate the specifics:
Set the diode current at the typical value which is probably about 20mA using a series resistor and the diode forward voltage drop which is probably about 2.2V .

Wire the photo transistor in common emitter using, say, 1K or less to Vcc. If you need a smaller value, make sure you don't exceed the dissipation of the transistor nor bias it for more than the current transfer ratio will allow for reliable switching.

I'd use Vcc = 5V, the output should be normally low, measure the collector with a voltmeter and make sure it is in saturation from the data sheet. Interrupt the beam and it should go to about 5V.

A photo interrupter should probably be run with shielded cable. A small cap across the output may be needed if the circuit is noisy.

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: Photo interrupter as limit switch

Post by cvoinescu » Thu Aug 08, 2013 2:59 pm

What veng1 said, except that if the LED is infrared, the forward voltage drop is more like 1.8 V. Check the datasheet, some optointerrupters need only 10 mA for the LED. For the output, 1 Kohm pull-ups should be fine with most phototransistors.

Also, make sure that the tab that interrupts the beam travels perpendicular to the long dimension of the slot -- that way you get a nice, sharp response.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

deejayspinz
Posts: 96
Joined: Wed Oct 17, 2012 9:33 am
Location: Burlington Ontario, Canada

Re: Photo interrupter as limit switch

Post by deejayspinz » Thu Aug 08, 2013 5:03 pm

Something to consider about these... I presume your setup would trigger the limit switch when a plate of some sort mounted on the moving axis crosses the IR path of the photo interrupter - for all your axis. It will be hard to place these anywhere that could guarantee a 0% chance that a piece of milled material would fly into the path and trigger the switch. If you've got a vacuum mounted to the milling area, that would help but still may not guarantee the switch does not trigger.

veng1
Posts: 250
Joined: Fri Nov 30, 2012 12:09 pm

Re: Photo interrupter as limit switch

Post by veng1 » Fri Aug 09, 2013 8:17 am

Of course cvoinescu is probably correct on both points, that's why I suggested looking at the data sheet.

It is probably prudent to take anything you read in the forums with a grain of salt (including my posts) and follow it up with your own due diligence.

danimal
Posts: 332
Joined: Wed Mar 13, 2013 5:53 pm
Location: Colorado

Re: Photo interrupter as limit switch

Post by danimal » Tue Aug 13, 2013 1:54 am

Thank you for the help. I am using them for timing in my other project, so I really did not care about accuracy when I bought them. I just need the + pulse to count up as the cam turns. Most of the data sheets that I can find say .1 to .2mm accuracy for the switch, though I am not sure about this exact switch. I thought that I would be able to locate the data sheet for this switch, but as of yet I can not find one anywhere. I hope that there is one in the box when they get here on thursday.

It would be convenient if I could get them to work for this application. Thanks again for the help and I will try to get a working circuit drawn up here in the next few days. I have been remodeling my bathroom so the free time that I thought I would have has all but evaporated into thin air. If anyone can find a data sheet for this switch I would really appreciate it. I looked on all data and googled every combination of the title that I could think of and I had no luck.
Shapeoko # 1458

RT0701C Spindle || dual y motor || x axis nema23 with custom carriage 1000mm length || z axis nema23 linear rail upgrade with 1/2-10 ACME

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: Photo interrupter as limit switch

Post by cvoinescu » Tue Aug 13, 2013 11:19 am

You don't really care about the absolute accuracy, you care about repeatability, which should be better than 0.2 mm, but depends on the electronics somewhat -- in your case, it depends on the choice of both resistors and on the characteristics of the input pin, so it's hard to predict.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

danimal
Posts: 332
Joined: Wed Mar 13, 2013 5:53 pm
Location: Colorado

Re: Photo interrupter as limit switch

Post by danimal » Sun Aug 25, 2013 4:13 am

So I finally got a little time to get going on this. Here is where I am at. I have everything wired up and have verified proper response on the photo interrupter. It was setting at about 4.8v then when I interrupted the signal it dropped to a zero and seemed very steady. But for whatever reason the grblshield is not phased when the pin D09 drops to logic 0. It continues normally and does not stop. Is there something in grbl that I need to enable to enable homing and limit switches? Here are some pics of what I did. I also verified continuity between the limit switch and the soldered pin D09 on the stepper shield and it is good to go. Thanks in advance for the help.

Image

Image

Image
Shapeoko # 1458

RT0701C Spindle || dual y motor || x axis nema23 with custom carriage 1000mm length || z axis nema23 linear rail upgrade with 1/2-10 ACME

danimal
Posts: 332
Joined: Wed Mar 13, 2013 5:53 pm
Location: Colorado

Re: Photo interrupter as limit switch

Post by danimal » Sun Aug 25, 2013 7:38 pm

I am missing something here and I am still messing with this limit switch. Being that I am only using one limit switch to get the wiring and the logic correct before I apply it to the machine, I tried all three axis to make sure that I did not have crossed wires somewhere. I have the trace hooked up to the D09 pin on the stepper shield and I am moving the x axis.

I have $17=1 and I slowed $5=100 so that I would have a little more time to shoot the video and verify operation. Here is a video so maybe someone can pick up on where I am going wrong here.

Image
Shapeoko # 1458

RT0701C Spindle || dual y motor || x axis nema23 with custom carriage 1000mm length || z axis nema23 linear rail upgrade with 1/2-10 ACME

Post Reply