Converting 24V to Digital I/O

Thread Starter

BusManJamie

Joined Dec 9, 2020
9
Hello,

Hope you're all well.

I'm currently investigating how to approach part of a project I'm dealing with. I want to take a pos/neg wire from various 24V appliances in a vehicle, and end up with a digital signal of what's being used. This will feed via datalink to a small computer, which will then create a software instance and deal with this information in real time.

I'm a beginner with electronics as such, but I've soldered kits in the past.

However, my biggest query is, how would I take an input of a pos/neg wire from a 24V input, say, an indicator stalk, and convert this into a binary I/O situation? What components should I be looking for to make my kit?

Many thanks,

Jamie.
 

AnalogKid

Joined Aug 1, 2013
10,987
The most simple approach is to attenuate the 24 V down to whatever logic level is for your device (3.3 V, 5 V, 12 V) with two resistors. But we can't know if this will work without a lot of information.

What produces the 24 v signal?

When the signal is not present, is the line open or shorted to GND or something else?

What is the power source for the datalink?

ak
 

ScottWang

Joined Aug 23, 2012
7,397
Usual way to do this is to use an opto-isolator.
Resistor R1 sets the LED current depending on the input voltage.
Resistor R2 is a pull-up for the logic (binary) output.
The opto-isolator isolates the vehicle electrics from the logic circuit.
Good job.
To me, I will plus one stage of pnp transistor, so the output logic polarity will be the same with input.
 

Tim Davis

Joined Jun 10, 2015
23
Maybe I interpret the question totally differently, but It sounds like you're trying to measure the current of these devices? You want to know how much energy these devices are using in real time?

This is a great use of Microcontrollers (Audrino), You need an analog to digital conversion, a voltage divider to reduce the current/voltage for Audrino because they operate on 5V. There are plenty of Youtube videos how to do analog to digital conversion with Audrino. Audrino already includes 5 ADC's - You will get a value from 0-1023 which is a 10 bit resolution. You take this value and use ohms law based on the voltage to get the current. You can do this at the frequency of the audrino which is 16MHZ. You can then use Wifi, USB, RF, or Serial to send this data to central processor.
 

Thread Starter

BusManJamie

Joined Dec 9, 2020
9
Maybe I interpret the question totally differently, but It sounds like you're trying to measure the current of these devices? You want to know how much energy these devices are using in real time?

This is a great use of Microcontrollers (Audrino), You need an analog to digital conversion, a voltage divider to reduce the current/voltage for Audrino because they operate on 5V. There are plenty of Youtube videos how to do analog to digital conversion with Audrino. Audrino already includes 5 ADC's - You will get a value from 0-1023 which is a 10 bit resolution. You take this value and use ohms law based on the voltage to get the current. You can do this at the frequency of the audrino which is 16MHZ. You can then use Wifi, USB, RF, or Serial to send this data to central processor.

Hey,

So when a 24v appliance on the bus triggers, I wish to log this with software. It may be an indicator signal, or brake pedal, trottle pedal. Inside the vehicle, they connect a 24v circuit to the relay, and then usually a 24v light somewhere - be it brake light, tail light, indicator light, reverse light.

It's a telematic unit as an end game, but I'm wondering how I would go about taking these rudimentary 24v switches and loops, and turning them into something I can modify and deal with on software and whatever else I chose.

I can use a transformer if required, thought I'd like to just rob the 24V signals directly, rather than having to step down, as this wastes more space in what's already a wire-y mess!

Cheers,

J
 

Tim Davis

Joined Jun 10, 2015
23
Hey,

So when a 24v appliance on the bus triggers, I wish to log this with software. It may be an indicator signal, or brake pedal, trottle pedal. Inside the vehicle, they connect a 24v circuit to the relay, and then usually a 24v light somewhere - be it brake light, tail light, indicator light, reverse light.

It's a telematic unit as an end game, but I'm wondering how I would go about taking these rudimentary 24v switches and loops, and turning them into something I can modify and deal with on software and whatever else I chose.

I can use a transformer if required, thought I'd like to just rob the 24V signals directly, rather than having to step down, as this wastes more space in what's already a wire-y mess!

Cheers,

J
This is very unique. I'm not electrical engineer only software engineer (digital vs analog) .. but I do know that you are now describing momentary switches and possibly other appliances. Since Audrino can only detect on and off you would need to write some code to determine how long they were pressed (brake pedal, etc) .

For this task I recommend a Raspberry Pi instead, as it comes with Network, WiFi, SDRam, and a more powerful CPU. And you can easily attach a touch screen to monitor stuff all in the size of a deck of cards. You can even add a sim card and log this data to the cloud.

Raspberry Pi doesn't come with ADCs but going with the current measuring suggestion above you need to purchase an expansion board that will give you 16 Analog inputs. You could design a patch bay that simply splices into (serial) the 24V lines with an opto isolator to protect the Pi, map each device to a channel in code.

Another option is these tiny current sensors / transformer that you can use as well (no splicing!)

Watch youtube video how to measure large current with audrino (confusing but there are more tutorials on audrino, but they work the same on Pi)

now for the logging part, you can simply have a condition.. if current > •somethreshhold• then log to CSV file or cloud. You can do this several times per second and whenever the brake is pressed, it will begin logging. You can also log the current values and have a log of power actually used. For something like a turn signal, you would see current on for brief highly regular periods.. for something like this you can monitor the brake lights on the bus from 1000 miles away in real time..

just remember vehicles are very noisye electrical environments prone to huge spikes ... and you may have to deal with this somehow.. when starting the bus huge surges go through the system.

Do you have a photo of the electrical connectors on the bus? Could help design something

happy coding!
 
Last edited:

Thread Starter

BusManJamie

Joined Dec 9, 2020
9
This is very unique. I'm not electrical engineer only software engineer (digital vs analog) .. but I do know that you are now describing momentary switches and possibly other appliances. Since Audrino can only detect on and off you would need to write some code to determine how long they were pressed (brake pedal, etc) .

For this task I recommend a Raspberry Pi instead, as it comes with Network, WiFi, SDRam, and a more powerful CPU. And you can easily attach a touch screen to monitor stuff all in the size of a deck of cards. You can even add a sim card and log this data to the cloud.

Raspberry Pi doesn't come with ADCs but going with the current measuring suggestion above you need to purchase an expansion board that will give you 16 Analog inputs. You could design a patch bay that simply splices into (serial) the 24V lines.. use an opto isolator to protect the Pi, map each device to a channel in code. Watch youtube video how to measure large current with audrino (confusing but there are more tutorials on audrino, but they work the same on Pi)

now for the logging part, you can simply have a condition.. if current > •somethreshhold• then log to CSV file or cloud. You can do this several times per second and whenever the brake is pressed, it will begin logging. You can also log the current values and have a log of power actually used. For something like a turn signal, you would see current on for brief highly regular periods.. for something like this you can monitor the brake lights on the bus from 1000 miles away in real time..

just remember vehicles are noise electrical environments and you may have to deal with this somehow.. when starting the bus huge surges go through the system.

happy coding!
Funnily enough, this is what it was going to plug into inside the vehicle. I have a version 1 rasp PI, and was going to feed it into USB on this. I did not know there was such an expansion device.

Can you please show me such an expansion device?

Cheers,

J
 

Tim Davis

Joined Jun 10, 2015
23
Funnily enough, this is what it was going to plug into inside the vehicle. I have a version 1 rasp PI, and was going to feed it into USB on this. I did not know there was such an expansion device.

Can you please show me such an expansion device?

Cheers,

J
The device is linked above in orange
 
Top