Help me understand this photogate (Robotics)

Thread Starter

mcardoso

Joined May 19, 2020
226
OK. So make R1 a 1KΩ resistor. Use a 1 watt resistor as you could be seeing almost half an amp. (490mA) Can the opto handle that much current without blowing out?
I think the issue is that the phototransistor on the output of the opto will only sink 6mA to GND (If I understand the datasheet correctly). So no, I don't think it will blow out, but it certainly won't be able to pull the input low if R1 is 1000 ohm
 

Thread Starter

mcardoso

Joined May 19, 2020
226
OK I did the math again, I hope correctly.

If I set the conditions Vhigh = 19.0V, Vlow = 6V, and the forward current of the optogate emitter at 30mA, then allow us to vary the values of R1 (the external resistor) and R4 (the forward current limiting resistor), I can get the following values. R1 = 1973.7 ohms and R4 = 822.1 ohms.

I think I could use the 2000 ohm external resistor, and replace the resistor R4 on the PCB with an 800 ohm resistor. This will give me 2V above and below the noise margins of the input module.
1600892205534.png



1600892160483.png

1600892182217.png

What do you think? Don't want to replace the PCB resistor, but it is a minor change
 

Thread Starter

mcardoso

Joined May 19, 2020
226
I don't think the sensor is supposed to put out the type of signal you are expecting. It looks like this sensor is configured as an NPN output type sensor. The pin you label as "input" is actually considered the output. When photosensor is aligned with the gap in the encoder wheel the photosensor conducts, giving the output terminal a path to gnd, or outputting an on/triggered condition. When the gap is not aligned with the sensor it does not conduct removing the path to ground, outputting an off/untriggered condition. If you are connecting this to an NPN input then it is ready to go. Common to the common of the PLC card, and output of sensor to input of the PLC card. If you are connecting to something else and needing a logical output, ie. >17V when high and <8V when low as you indicated, it would just be a matter of adding a pullup resistor between V+ and what the sensor output large enough to limit the current sufficiently to protect the sensor. This would give a high output(close to V+) when the gap is not aligned with the sensor, and a low signal (almost 0V) when it is aligned.
I think you have it correct. This is not the right type of sensor to interface to this card, but I am trying to make it work

I'm hoping the resistor calculations I just posted give me the expected results without changing any other components in the system.
 

scorbin1

Joined Dec 24, 2019
103
I think you have it correct. This is not the right type of sensor to interface to this card, but I am trying to make it work :)

I'm hoping the resistor calculations I just posted give me the expected results without changing any other components in the system.
I reread the post and realized you already knew this. Also answered a couple of my own qeustions. Easiest resolution here would probably be to use the photo switch to control a SPDT relay and use the relay to switch between high and low with the input of the servo amp wired to the common contact of the relay. Clean and easy, only potential issue is switch bounce if that is an issue.
 

Thread Starter

mcardoso

Joined May 19, 2020
226
I'm going to try this with the 2000 ohm R1 resistor tonight. That's what I have on hand. It won't work until I replace R4, but I can do some measurements to make sure my math works right. If the numbers are way off then something about my circuit is wrong.
 

Thread Starter

mcardoso

Joined May 19, 2020
226
I reread the post and realized you already knew this. Also answered a couple of my own qeustions. Easiest resolution here would probably be to use the photo switch to control a SPDT relay and use the relay to switch between high and low with the input of the servo amp wired to the common contact of the relay. Clean and easy, only potential issue is switch bounce if that is an issue.
I like that idea too! I just wonder if this optical switch can actually pull in the relay or not. I guess I can try. I have plenty of slim DIN mount SPDT relays
 

scorbin1

Joined Dec 24, 2019
103
It absolutely will. Size your relay accordingly but almost any small industrial automation relay would work. This sensor can handle up to 200mA on it's output. We do this all the time here at work. It's the only method that would actually be approved in most commercial environments. Creating a voltage divider as you are is considered questionable practice, especially in situations where safety could be an issue. Safety is always an issue in industrial robotics. Not saying it's perfectly reasonable, but you would almost never see that as a commercial solution.

With the values you give it looks like you should get somewhere around 19V when high and around 1.5V when low. R2 really doesnt have much of a role except setting the output voltage when the output signal is high. When the signal is on(low) the LED and trasistor will drop approx 0.7V each for a total of 1.5V leaving 22.5V across R1. It should be sized to limit current accordingly and with R1 at 2kohm should allow approximately 12 mA to flow. R4 will only affect the brightness and/or longevity of the emmitter. I would not play with this much. It is simply to turn the photo transistor on if current flow is sufficient. This should not have any affect on output voltage whatsoever.
 

Thread Starter

mcardoso

Joined May 19, 2020
226
It absolutely will. Size your relay accordingly but almost any small industrial automation relay would work. This sensor can handle up to 200mA on it's output. We do this all the time here at work. It's the only method that would actually be approved in most commercial environments. Creating a voltage divider as you are is considered questionable practice, especially in situations where safety could be an issue. Safety is always an issue in industrial robotics. Not saying it's perfectly reasonable, but you would almost never see that as a commercial solution.

With the values you give it looks like you should get somewhere around 19V when high and around 1.5V when low. R2 really doesnt have much of a role except setting the output voltage when the output signal is high. When the signal is on(low) the LED and trasistor will drop approx 0.7V each for a total of 1.5V leaving 22.5V across R1. It should be sized to limit current accordingly and with R1 at 2kohm should allow approximately 12 mA to flow. R4 will only affect the brightness and/or longevity of the emmitter. I would not play with this much. It is simply to turn the photo transistor on if current flow is sufficient. This should not have any affect on output voltage whatsoever.
Sounds good. I like this plan. Where did you see this device sinking 200mA. I’ve been under the impression that it would only do 6mA under my operating conditions
 

scorbin1

Joined Dec 24, 2019
103
I apologize, I misread the data sheet. I thought it said the maximum collector current was 200mA, it is actually 20mA. And I see where you found that it will only pass 6mA of current at the current config. I understand why you were looking to change R4 now. I honestly looked over it much quicker than I should have after thinking I seen 200mA. I assumed it was general use industrial sensor, being that it was made by omron. That does make it awful tough to use a relay or even as an input to a PLC. I am sure you could probably find one to fit the bill, though I am not sure how easy to find and readily available it will be. Sounds like you were on the right track and I was trying to pull you off of it. The voltage divider would likely be your best bet.

Just a word of wisdom, be VERY VERY careful with this. Read up on safety circuits and try your best to implement them just as industrial safety standards require. Robotics is a very fun field but there are A LOT of safety implications that go along with it. One small piece of code that doesnt work as expected and very bad things can happen without proper safeties in place. Even this small manipulator could potentially cause a lot of harm. That all being said, keep us updated. I would love to see more details on your progress. I almost salvaged an old arc welding robot from work recently. If only I had the space....
 

Thread Starter

mcardoso

Joined May 19, 2020
226
I apologize, I misread the data sheet. I thought it said the maximum collector current was 200mA, it is actually 20mA. And I see where you found that it will only pass 6mA of current at the current config. I understand why you were looking to change R4 now. I honestly looked over it much quicker than I should have after thinking I seen 200mA. I assumed it was general use industrial sensor, being that it was made by omron. That does make it awful tough to use a relay or even as an input to a PLC. I am sure you could probably find one to fit the bill, though I am not sure how easy to find and readily available it will be. Sounds like you were on the right track and I was trying to pull you off of it. The voltage divider would likely be your best bet.
No worries! I often jump to the end of forums and don't catch up on all the posts above. Just thought I was misunderstanding something about the datasheet which would make my life easier. I read the name Omron and also though about rugged industrial sensors. I think they were fairly space constrained when designing the robot so these smaller sensors fit the bill.

I think I'm going to try the resistor swap and see if it works. If not, then I will investigate other sensors or wiring options.

Just a word of wisdom, be VERY VERY careful with this. Read up on safety circuits and try your best to implement them just as industrial safety standards require. Robotics is a very fun field but there are A LOT of safety implications that go along with it. One small piece of code that doesn't work as expected and very bad things can happen without proper safeties in place. Even this small manipulator could potentially cause a lot of harm. That all being said, keep us updated. I would love to see more details on your progress. I almost salvaged an old arc welding robot from work recently. If only I had the space....
Absolutely agreed. This circuit only gets used by the robot to find the home position. The motion of the robot is controlled with some Allen Bradley AC servo drives. I am also adding a safety rated relay with a dual channel pulse tested ESTOP button to allow me to stop this puppy regardless of the software is doing. My drives do not have Safe Torque Off (STO) since they are so old, but the safety relay can interrupt the enable inputs to the drive. This is for home use and not for sale, so I can take a few liberties with the machine guarding. I'll be standing well clear of this thing. The arm weighs 140 lbs and can get the end of the arm up to 13mph . That would hurt.

I'd love to get my hands on a 6 axis robot, but this 4 axis SCARA is what I could find. I can use it as a stepping stone to a more complicated robot in the future. If you find this interesting, I write all the details of my build here:

https://www.hobby-machinist.com/threads/mikes-scara-robot.84001/
 

Tonyr1084

Joined Sep 24, 2015
7,905
I used to use paintbrush to do my schematics. Have a page with all kinds of symbols on so all I have to do is copy and paste. I'm going to try starting a wood shop business, and for that I bought TurboCAD for doing drawings of parts I want to build. I also use it to make schematics now. Like in paintbrush, I also made a bunch of components ready for copy and paste functions.

If you have paintbrush it may take a little work but you can do some pretty good drawings. I still use paintbrush to take photos of PCB's and then eliminate the varying colors and make a drawing of traces and components so I can decipher a PCB more easily. Few years ago I did one of a 12V wall wart. Wanted to convert it to a 13.8V output. Found the regulating circuit and modified the reference voltage. Caps were rated at 16 volts so I upgraded them to (from memory) 35VDC. I'll look around on my computer and see if I can find that work. I can PM you with the drawing. No need to post it here and possibly confuse things.
 

Thread Starter

mcardoso

Joined May 19, 2020
226
Well, I ordered the 800 ohm resistors to get it hooked up. Not thrilled with the results. One out of the 3 sensors operated as expected with the exception of 8V when low instead of 6V. I think this probably has to do with the forward voltage of the diagnostic LED in the circuit that I did not consider. This works but is super close to the noise margin and I am not happy with it.

The circuit for the second sensor also worked, but the sensor was found to be completely soaked in heavy dark oil from the robot joint gearbox and non-functional. It will need to be replaced.

The 3rd sensor is also functional, but there is a short to GND in the circuit somewhere between the LED and the sensor. the input is pulled down to 2V regardless of if the sensor is plugged in or not.

I'm taking this as a sign that I need to replace the sensors and do this the right way.

Option 1 will be to keep the sensors, but rewire them for sourcing operation rather than sinking. This will get rid of the external resistor. I will need to reverse the LEDs on the PCB or remove them all together.

Option 2 will be to replace the sensors. The ones I have are "transmissive photo interrupters - phototransistor output" (general term according to Digikey). They also have these sensors with logic outputs which are a digital signal that is amplified. This is closer to what I want if I could find one that had the same physical dimensions (or close enough) to the ones I currently have.

Replacing the sensors is going to be a total pain. The arm needs to be disassembled to get to where they are installed. It is around 150lbs so it will be a chore.
 
Last edited:

MisterBill2

Joined Jan 23, 2018
18,590
The way to determine what the actual input impedance is would be to connect a known value resistor between the 24 volt source and that input terminal and measure the voltage.
It may ell be that there is a 7500 ohm resistor near the input terminal, because that was a traditional value for inputs at one time. Just a bit of experiment and you can be certain.
 

Thread Starter

mcardoso

Joined May 19, 2020
226
The way to determine what the actual input impedance is would be to connect a known value resistor between the 24 volt source and that input terminal and measure the voltage.
It may ell be that there is a 7500 ohm resistor near the input terminal, because that was a traditional value for inputs at one time. Just a bit of experiment and you can be certain.
I did do that. I get about 19.3V with a 2000ohm +/- 1% resistor for R1. Power supply is 24.1V. This gives a calculated 8041 ohms for the input impedance. Good enough for government work :)

If you're open to experimentation, this should drop another 2 to 3 volts, depending on the Vf of the extra LED:
View attachment 218248
I can try that. My issue is I need a higher high voltage and a lower low voltage. Don't think this will help.

I think I could reverse the wiring of the phototransistor output and instead of connecting it to GND, connect it to 24V. This should now source current instead of sinking it. I would then need to remove HL4 or install it the other way around.
 

Tonyr1084

Joined Sep 24, 2015
7,905
Looking to see where you gave some high and low voltages that you're looking for. I'll find it and tag it. But from memory I thought you said something like 17V was a minimum high signal requirement and something below 8.6V for a low signal. IF you're seeing a low of 8 volts (which is below 8.6V) then you should be low enough to trigger a "Low" signal. If you're starting with 24V and dropping an extra - lets say - 2.5V, you're still over 17 volts by a good margin.

We may be getting some mis-information here, but if I recall what you were saying about those voltages, there should be a threshold between high and low signals. Above that should give a high signal and below that should give a low signal. I'm sure there's some grey area at that point where the signal is translated from high to low and back to high, but it's likely going to be a volt or less.
 

Tonyr1084

Joined Sep 24, 2015
7,905
Had to step away for an ill pet.
I need to get the input at the far left "Home0/1" above 17.0V for a logical 1 and below 8.5V for a logical 0.
I suspect that dropping the voltage an extra 2.5V might keep you in these ranges. Only testing will tell for sure, but it should be a quick test. Let me look at some numbers. If I don't screw them up I should be able to guess pretty well what a logical high and logical low look like when tapped at the junction of the two LED's.
 

Thread Starter

mcardoso

Joined May 19, 2020
226
Sorry to add any confusion.

Target voltage is >17.0 for High and <8.5V for Low

Currently I am getting 19.3V for High and 8.1V for Low. This is after the installation of the 2000 ohm R1 resistor and replacement of the 1200 ohm resistor with an 800 ohm one.

This is acceptable, but really close to those margins. Any noise (there will be some, industrial application near HF servo drives) could push it over.

I'd really like to get close to 24V High and <1V low. That is likely not going to happen with the current sensor configuration. I think a new sensor with a amplified PNP transistor output or using the current sensor but rewired for sourcing operation will need to be done.

Really appreciate all your help. This has been a good discussion and I am learning a lot. I originally really wanted to avoid dismantling the robot to change out the sensor or rewire it for a different mode of operation, however the dead sensor is going to force me to do that anyways. Might as well do it right.
 

MisterBill2

Joined Jan 23, 2018
18,590
Are you able to get into the system beyond that terminal strip? If you are able to increase the input resistance then that should allow a different pullup resistor and solve the problem completely
 

Thread Starter

mcardoso

Joined May 19, 2020
226
Are you able to get into the system beyond that terminal strip? If you are able to increase the input resistance then that should allow a different pullup resistor and solve the problem completely
I can set the pullup resistor to any value I want. I cannot change the 7500 ohm input pulldown resistor. It is somewhere within a module I cannot modify. I am now willing to change anything about the right half of the circuit. I pushed back on that originally because I did not want to modify the robot itself.
 
Top