Skip to main content

Reply to "Using an optocoupler to connect insulated rail to input pin of shift register"

crood58 posted:

JGL,

I have a question on your circuit. What is the 12V feeding into? A voltage divider or still an RC Circuit with Opt Amp? 

The 12VDC line is only used to power the optocouplers.  The circuit is pretty much a 1.5k resistor, an LED(inside the optocoupler), and a diode to prevent reverse current if AC is used on the sense lines.  With a 1.5k resistor on the cny17-1 optos I have, I get reliable results from 5vdc to 30vdc.  I have not tested below 5 volts, but going by the specs it should work down to about 3.5 volts if I recall.  The other end of the optocoupler is used to switch on a pin of the arduino (or other input device).  For a switch machine controller that does not need to know if a train is still there, only when one approaches even a 60Hz AC supply to the optocoupler will make pulses that last plenty long enough to be detected.  For other applications, however, an RC filter is used, if you want the input to remain on while a train is present, such as in my multi-function track presence detector project.  

Like I said previously, I plan to used the 12vdc because I have it and am not using it for anything else.  Accessory level AC, or track level AC are equally usable options.  


On the current limitations of the MCP23017:  There are also similar limits on the ports of the arduino its self.  Depending on the board in question the ports are split up differently, and usually the I/O pins are spread over several ports, but each port can only sink/source 100 or 200 mA (again depends on the port) It's something that you need to keep track of when you design, to make sure you're not drawing too much current through any one port.  You can also just use a transistor to up the current if needed, or an inexpensive transistor array if you need a lot of them.  

Another thing to keep in mind with those relay modules, while they only draw about 30mA per relay when on, they will draw about 70mA surge current when the relay is clicked on.  Make sure your power supply can handle the spikes of current.  As for driving them, you can get away with limiting the current further, but unless you do that, expect each channel to draw about 20 mA from your I/O port.  

The shift registers have the same problem as port expanders here, the common 74HC595 can sink 20mA per pin, for example, but only a total of 70mA across all 8 outputs.  

Transistor arrays like the ULN2803 can be very useful here as it can sink 500ma per channel.  

JGL

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
×