24vdc to arduino

Okay so this must have been asked before, but i see so many answers so i'll just ask you guys for your opinion in this...

How would you think would be best for me to connect a 24Vdc signal to the arduino inputs exactly?

Opto coupler (what kind) resistor (what kind) ?

It's not that i have no clue, it's just that i want a perfect solution.

Greetz

Probably a [u]voltage divider[/u] (2 resistors). A 4k* ohm and a 1k ohm resistor would give you a 5-to-1 voltage reduction.

What kind of "signal' is this? Analog (variable voltage) or digital (on or off)? Do you know anything about the available current? The voltage divider requires some current, depending on the resistor values you choose.

*You probably won't find 4k resistor. 3.9k is a standard, and that would work.

Opto coupler would also work. You would need the proper resistor on the 24V side. This would allow you to isolate teh 24V side from the Arduino. Not always needed, but not a bad thing.

I agree. The voltage divder comes to mind first. It's the easiest for sure. Cheapest. and it will work. If it was me, that's what I would do.

It's a digital signal from a 24vdc plc as start signal. Edit: the available current is 10A so current is no problem. The plc is on a different power supply I don't know if a voltage divider is my best option then, what do you guys think?

Thanks for your input in this :)

Kenny

You say you're using a PLC, which if I understand outputs 24VDC, or 0V depending on logic level. But most PLC modules are powered by mains voltage, IE 110/120/220/240VAC stuff that you plug things into, or they use a power supply (transformer or adaptor) that is also plugged into a main supply. In either case, the outputs of the PLC may in fact be ground-referenced, but this is more likely "common" ground versus "earth" ground. Follow me here, this is important.

Your household AC powered stuff if it has a 3 or more prong plug has a ground connection. This ground is connected to a bus bar in your breaker panel, connected likewise to the Neutral bus, but the Ground bus is also connected (literally) to the Earth itself (as a buried electrode on your Property as well as connected to your power provider). All of your copper plumbing as well is at Ground potential.

Now here's the connectivity issue. The Arduino can be powered by an external power supply such as a common adaptor, if not a battery. Chances are that this adaptor doesn't have a Ground pin, but it may have a polarized plug. In either case, there is no guarantee that the output voltage of said adaptor is actually in fact ground-referenced. IF you want to test this, use a DVM,and measure the resistance from the negative terminal of this power supply, and the ground pin (or Neutral prong) of the adaptor itself. IF you read zero, it's (mains) ground referenced, but we're not done yet.

The PLC as mentioned intrinsic or external power supply, you can figure out if its zero volt output is relative to the Earth ground as mentioned, but I suspect that it is likely not; the outputs are likely floating from Earth Ground.

Everything that has a (floating) supply however often has a Chassis ground. Your PLC likely has this, but verify that from your PLC literature to be sure that your PLC common connection ground is NOT earth ground. your Arduino project can also have this by design, but in the Arduino case what you call Chassis ground must in fact be isolated from Earth ground; this is likely if you use an external power supply that is not referenced to Earth Ground as mentioned prior with the testing of stuff. For your Arduino project to have a Chassis ground which can be bussed to other chassis grounds, is up to you.

Getting to the point, if both devices are Earth grounded (or chassis grounded), and all voltages are relative thereto, voltage dividers will work correctly betwixt the devices. But you got to figure out if both are using a common ground (or not), and if either or both are floating, you can have problems; current can flow from one to the other if neither is at the same potential sort of thing, so I'll get to my point.

Rather than trying to find a "cheap" solution using a voltage divider comprised of resistors, assuming that both the PLC and the Arduino are at the same Ground potential (never mind voltages), rather than wreck either device, just use an Optocoupler, 4N27, 4N33 or whatever, google the devices, or just google Optocouplers.

Using the Optocouplers mentioned, your PLC outputs say 24V, just use a series resistor to the diode inside the optocoupler (it's all right there in the app notes which you can download from the manufacturer), and the other half of the optocoupler is typically an NPN phototransistor, one resistor is all that's required to make this happen with the Arduino (again read the app notes for the Optocoupler in question).

In closing, I would suggest not farting around with figuring out voltages and using voltage dividers at all for what you're trying to do. If all that you are concerned with, is GO or NO GO, use Optocouplers, and you can dispense with the issues of "what if the device sending is sending things at a different voltage". That way, your Arduino project can operate at 5V, your PLC can operate at 24V, and they can be 500V difference in potential and not hurt one another, as they are (optically) isolated.

Cheers.

I have this exact same problem in a project I'm currently working on. I need to read the output from a sensor (fiber optic) intended for PLC use - 24V. I am using it alone, however.

I am using solid state relays. Basically an optocoupler but can switch larger currents. You don't need large currents in your application but they are cheap and will still work great.

I am using this device: http://www.mouser.com/Search/ProductDetail.aspx?R=G3VM-61D1virtualkey65300000virtualkey653-G3VM-61D1 Same device in a DIP package: http://www.mouser.com/Search/ProductDetail.aspx?R=G3VM-61A1virtualkey65300000virtualkey653-G3VM-61A1

Very simple, connect your 24V output through the input pin, then the other end to ground through a resistor. I am using a 2.5k resistor which gives 10 mA to drive the LED. Max is 50mA, but datasheet lists normal characteristics at a reference of 10mA so I went with that. Then just connect the output side to your +3.3V and then to the arduino (with a pulldown resistor to ground to avoid floating input).

Keep in mind that at 24V and 10mA, you are dissipating about 1/4 Watt, so spec your resistor accordingly. I am using 0.5W rated resistors in my application.

EDIT: OK they aren't that cheap. Maybe a regular optocoupler would suit you better, same principle. Wow the SMT version DOUBLED in price since I bought a few 2 weeks ago.

Thanks for the complete answers on my problem! :)

When i finish this project i would like to build more and just implement it wherever i like so i guess that measuring if i have common grounds will maybe help me here, but it could kick me in the ass later on :~.

My first suggestion was an opto input in my board, so i guess that this is the way to go!

So i will go on and do the same for my analog signal (0 or 4 - 20mA) and use a resistor after a opto-coupler on my board?

With this set-up it will be a little more expensive, but cheaper than blowing my arduino up :) if you have more suggestions there welcome! :)