Convert 12V to 5V?

So we just got stuff from FIRST Choice, including what seems to be a line tracker: Allen-Bradley 42EF-D2MPAK-F4. Does anyone know how to wire it? I’ve been told to hook up power to 12V 500mA on the VRM, Ground to GND on a Digital I/O port on the RIO, and a signal to a signal port on the RIO for digital as well, but according to my research I would need to take the voltage down to 5V. How would I do that? Resistors?

1 Like

If so, which ones?

The VRM has a 5V output rail. Also don’t plug the gorund to a digital IO on the RIO, plug it in to ground on the VRM

but according to my research I would need to take the voltage down to 5V. How would I do that? Resistors?

One way is a voltage divider: Line tracker Sensor 2019? - #19 by MarkBalla

Here’s a logic level adapter that could also do it: https://www.sparkfun.com/products/12009

Also see the discussion here: Solved: Re: Is the roboRIO DIO Compatable with the AB Line Sensor? - NI Community

Unless something has gone horribly wrong, they should both be equivalent :stuck_out_tongue:

Granted, the Rio shouldn’t be expected to sink much current through ground, but the 30mA the 42EF draws shouldn’t be an issue.

1 Like

I agree, but I’ve found that the best practice is to connect ground to the same place you got VCC from (if possible). There’s no reason to run two different lengths of wire, one to the VRM for VCC and one to the RIO for GND, when we all (at least both of us) know that the two grounds should be equivalent.

Plugging in ground at the RIO is just extra complexity

The easiest way to drop a 12v signal to a 5V signal is using a voltage divider.

http://www.ohmslawcalculator.com/voltage-divider-calculator

The ratio of R2 to (R1 + R2) needs to be about 5/12, though you can go slightly lower than 5v (probably down to 3.3v at least) on the output because it’s a digital signal. Finding this ratio is left as an exercise to the reader.

I would use resistors in the kOhm to 100 kOhm range. You want something high enough that current sink isn’t an issue, but small enough that tolerances don’t mess up your division. You can probably go even higher, but in this range the current draw isn’t enough to matter (a few mA).

Voltage dividers don’t work for power, because it relies on the tap having infinite (or incredibly high, in real life) resistance to ground on other legs.

The connection scheme you are suggesting is appropriate for large, noisy loads such as relay coils, motor controllers and motors. It gets the noise currents and voltages out of the local reference for the sensitive circuitry.

The OP is connecting a low current sensor. The return of the sensor should go to the 0 V pin of the DIO so that the circuitry inside only sees the difference between the signal output pin of the sensor and the return pin of the sensor.

Depending on what is going on in the system, there can be a voltage differential between the 0 V in the Roborio and other “ground points”. The input circuitry connected to the DIO pin sees the output voltage from the sensor PLUS this voltage differential. This may lead to spurious input signals being sensed by the DIO pin.

One of the lessons I learned early in my career is that “Ground” is almost never at the expected ground potential.

We used the Sparkfun dual OptoIsolator board for $4.99.