DIY Arduino PLC - Stepping 12/24V down to 5V

Thread Starter

Ryan Jones

Joined Aug 27, 2016
35
Hey, everyone!

I am working on designing my own circuit and had some questions on typical procedure.

At work I use an Arduino PLC called the Controllino which operates at 12V *OR* 24V logic, either works, and no settings need to be changed. I wanted to design something similar using an Atmega328p, which of course, runs on 5V logic. Ideally, I need mine to operate at 12/24V just as the Controllino does. Upon doing my research (self-taught EE and hobbyist), I can figure out several different ways to step down EITHER 12V or 24V separately using voltage dividers, regulators, or a resistor/diode network, but can't seem to figure out how a single circuit can operate automatically at one or the other.

Basically, I know how to step down voltage to 5V but can't figure out how the input voltage can be 12V or 24V without using separate circuits. I hope this makes sense. Can anyone shed some light?

Thanks in advance!
 

MaxHeadRoom

Joined Jul 18, 2013
28,838
Typically industrial PLC's use opto isolation between I/O, you could do the same.
If neccesary use a regulator to drop to 5v for the micro.
Max.
 

Thread Starter

Ryan Jones

Joined Aug 27, 2016
35
Typically industrial PLC's use opto isolation between I/O, you could do the same.
If neccesary use a regulator to drop to 5v for the micro.
Max.
Thanks, Max!

Are there any limitations to optocouplers? Should most of them be able to handle up to 24V dependent on the circuit existing outside of the IC?
 

#12

Joined Nov 30, 2010
18,224
Are there any limitations to optocouplers?
Certainly. They use external resistors on both ends to make them current driven and current controlled output, so there is no problem with the voltage aspect. The "transfer ratio" of current in for current out is sometimes pretty lame. That's what datasheets are for.;)
 

Thread Starter

Ryan Jones

Joined Aug 27, 2016
35
Certainly. They use external resistors on both ends to make them current driven and current controlled output, so there is no problem with the voltage aspect. The "transfer ratio" of current in for current out is sometimes pretty lame. That's what datasheets are for.;)
Hey, I appreciate the input! Thanks!
 

MaxHeadRoom

Joined Jul 18, 2013
28,838
The 4n35 should be suitable for that application, just size the input LED resistor for the optimum current at that voltage,
For outputs you could also use SSR's, they already have conditioned (AC/DC) outputs.
Max.
 
Usually the output logic isn't selectable. It depends on the power provided to the PLC. So, if you have 24 V in, the output for a high is 24 V. 12 V in, it 12 V or close anyway, OPTOMOS relays use a LED and FET and will have lower on resistance. For lower currents an OPTO FET (I use a discontinued part Vactrol VTL5C1) as an example.

Open collector contacts to ground are easy.

For the input, you can use a current source in series with the LED. The LM334 https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=20&cad=rja&uact=8&ved=0ahUKEwjd8fvFlu3TAhUJ5yYKHQwyC-sQFgiPATAT&url=http://www.ti.com/product/LM334&usg=AFQjCNFpoDpqCB5PUZNUZXpAfnWmX8jH2g or the LT

The LT3092 http://www.linear.com/product/LT3092 has both reverse voltage and current protection up to 40 V and as low of an input as 1.2 V, but you still need to consider the drop of the LED.

If you post some typical I/O specs we can see if we can meet them.

As was said, most PLC type circuits are isolated.

In another approach (no current source) for the input (cheaper), one can use two resistors and the second resistor is bypassed with a transistor depending on the power supply. Add a diode for polarity protection.
The LT6700 http://www.linear.com/product/LT6700 could sense the power supply. It can handle an input greater than the supply.

So, these can be used for isolated inputs too. The threshold can change based on the power supplied or have two.

In one case the power to the PLC selects the I/O and in the other you allow both for inputs. Outputs (12/24) pretty much have to selected by the power in.

Optocouplers are slow compared to transistors and FETS,
 

MaxHeadRoom

Joined Jul 18, 2013
28,838
What I have used in the past for a semi-industrial application is to use Opto22 G4 opto-isolated boards with a Picmicro, they have assorted I/O modules for both input and output from 230vac to 80vdc, all 5v logic controlled, the boards are laid out so that the modules can be mixed and matched how you wish.
All outputs have a replaceable fuse. They can usually be had cheap on ebay.
It give a PLC kind of appearance to it.
The boards come in 4, 8, 12, 24 sizes
upload_2017-5-13_10-46-12.jpeg
Max.
 

Thread Starter

Ryan Jones

Joined Aug 27, 2016
35
Thanks, everyone!

This is a lot of useful information for moving forward. I appreciate the input. When I make further progress I will surely share. My end goal is to try to design and order my first custom pcb.

I think am going to order some 4n35's and give them a shot. Some optocoupler channels are 4 or 6 pin, what is the advantage of using one over the other?
 

MaxHeadRoom

Joined Jul 18, 2013
28,838
T
Some optocoupler channels are 4 or 6 pin, what is the advantage of using one over the other?
Generally for PLC I/O applications super high speed switching is really not required, for e.g. in a commercial PLC there is quite a delay in update/scan time before outputs are acted on.
In the real world a contactor pick up time is much longer.
Max.
 

#12

Joined Nov 30, 2010
18,224
Wow! I pulled @SgtWookie out of retirement for a joke? (Post #6) :eek:
(I thought it was a ROFL.:p Thanks for the 5 confirmations.:))
This is the kind of response that helps me feel like a member of a community.;)

So, back to business:
See the zener I put on the output?
You can do that if the next stage needs a very limited input voltage or the opto has a rather low max input voltage for its output stage.

The limit of the zener is the lesser of a) {the power limit of the zener diode calculated by the current through the output resistor times the zener voltage when the opto is, "off".} If you're always in a switching condition, you can design for even more current through the output resistor by multiplying the b) {[% of time off/ % of time total] times [the max current through the output resistor] times [Vz]}. Or, c) The max current through the opto output transistor as limited by the transfer ratio of the opto.

Gosh, that's wordy. Let me do that in math formulas.

RL min =Vmax out / [Iin x (Transfer ratio)]

The Zener limit is:
Pz = IRL x duty cycle as opto Toff/Ttotal x Vz
And you always size the zener for double the power it actually has to dissipate (because heat dissipation).


But you will rarely need to maximize the output current to feed the next stage enough current, or,
You usually find that the Rl defined by the opto transfer ratio can easily drive the next stage.
If you are hitting the current transfer limit of the opto, you first look to increase the input current. Only when you hit a limit on the Input Current times the Transfer Ratio do you need to maximize the Output Current because the Output Supply Voltage is too high.V-limited Opto-output.jpg
 
Last edited:
Top