I’m building an interface between my truck’s status signals and an Arduino Uno R4 Wifi.
The truck’s status signals are either 12-14V or ground and can provide up to 0.5A. For example the signal “Engine is running” is defined as [open circuit] when RPM is <450 and [12V] otherwise. The max current is 0.5A.
I’m not sure how to connect this signal to one of the Uno’s digital input pins. I read that Uno’s I/O pins are limited to 8mA and logic operates at 5V.
Can I simply connect this signal to an input pin? or should I reduce the voltage to 5V? Should I also limit the current?
Only if you don't mind burning out the Uno's input pin and associated circuitry.
or should I reduce the voltage to 5V?
Input signals on an Uno should always be limited to 0-5V.
Should I also limit the current?
Your load determines how much current is required.
A simple voltage divider is one option, but as the automotive environment is a harsh one for electronics, an optoisolator would be safer. There are many other options as well.
An automotive electrical system is a hazardous environment for MCUs. If you want a robust solution, you should look for suitable optocouplers, etc., that meet the AEC-Q101/102 criteria.
You should be able to find the max current supported by the RA4M1 in the manual. My suggestion is to take a look at the M2 to see how they designed it to be (kinda) robust in a 12V environment. It's based on a 3.3V MCU (same one in the Arduino Due) but most of the same lessons apply and the design files are all open source.
In theory, this can be connected directly to the Arduino input pin. You would enable the Arduino's internal pull-up resistor in your code. The current that flows would be very small because the internal pull-ups are quite high resistance.
But as already mentioned, automotive environments are "unpleasant", so it might be safer to use an opto-isolator here also.
Is irrelevant in answering @myriaxis 's questions. If the signals are connected directly to the Arduino input pins (through a voltage divider if required), the Arduino input pins would be the "load" and these have a very high impedance (resistance) and so only a tiny current will flow, in the micro-amps range.. A tiny fraction of the max current these signals could provide.
If, as recommended, opto-isolators are used, the signals need to provide only a small current (a few milli-amps) to light the IR LED inside the opto-isolator.
You should never connect an open circuit to an Arduino input pin. It won't damage the pin, but it won't reliably read HIGH or LOW. It would be what is called "floating".
If the signal is ~12V or open circuit, you would need to connect a pulldown resistor from the pin to ground to prevent it floating when the signal is open circuit. Or use the Arduino's internal pulldown resistor, which most Arduino models don't have.
If the signal is ground or open circuit, you would need to connect a pullup resistor from the pin to 5V to prevent it floating when the signal is open circuit. Or use the Arduino's internal pullup resistor, which most Arduino models do have.
The exact value of pull-up and pulldown resistors isn't critical. They are usually around 5K~50K. With that kind of value, they can be easily "defeated" then the signal is 5V or ground. But if they are too low, like a few tens or hundreds of ohms, the signal may not be able to maintain the correct voltage level and the Arduino pin reading might become unstable. If they are too high, like hundreds of kilo-ohms or mega-ohms, they will leave the Arduino pin open to interference from the environment, like when the pin is floating.
Just a heads-up: a plain PC817 might not live very long in a real automotive environment.
On paper it works fine, but a 12 V car system is anything but “12 V”. You’ve got spikes, negative transients, load dump events… all the fun stuff. Without proper protection, the input LED in the optocoupler will eventually see conditions it really wasn’t designed for.
It may work on the bench and even for a while in the car, but long-term reliability is questionable. So unless you add proper protection (or use an automotive-rated part), don’t be surprised if it starts acting up at some point.
@myriaxis
There will always be people who claim that something won’t work but provide no evidence supporting that claim and who also don’t provide an alternate solution. It’s best to just dismiss such forum posts.
Just something to keep in mind when reading posts here on the forum.
I guarantee my that my circuits will work as is for your interfaces, no shoulds, coulds, or maybes.
Also, human made actual schematics not unreadable AI generated ASCII stuff.