Hi guys so I am currently working on a pcb design that will be implemented in an automotive application and am needing to read some 12V inputs which are as follows:
Vehicle speed sensor: 0-12V Pulsed signal
RPM: 0-12V Pulsed Signal
On/Off Toggle Switch
VGT: 0-12V PWM Signal
I was testing using simple voltage dividers but am planning on taking this to production so I need it to be safe and reliable.
I am new to optoisolators so am having a bit of a problem figuring out the circuit required for them. I need 20mA through the led correct which is I forward correct?
and how would i hookup the transistor side to the atmega328p in order to have it so when the input signal is high the atmega reads high etc?
Here is what I am thinking so far But i do not know how to hook up the transistor side to the atmega chip.
Ground the emitters, Collectors to i/o as INPUT_PULLUP. The logic will be "upside down" since the collector-emitter gate will close with the led input high and thus take your i/o pin low, but that's easy to take care of in code.
edit.... each segment looks like the circuit shown here but with the internal pullup instead.
I will be implementing this on my own pcb not on an arduino board or shield. So what you are saying is i can use the atmega chip's internal pullup resistor instead of using an external resistor connected to the collector as shown in the link you provided? If i wanted to use a external pull up resistor how would one go about calculating the resistor value for the collector?
Would it be possible to connect the i/o pin to the base as not to invert the signal going to the atmega chip?
I think 10k's a pretty common value for a pullup. Afaik, it's not calculated in the same sense as one would calculate the resistor in series with an led for example.
The base of the transistor is effectively the led anode, so I don't see what you mean about connecting the i/o there, it's the input. The nature of the npn transistor is that it inverts the signal.... I suppose you could invert the signal on the way in, with a 74xx (I forget the number, 7414?) inverter chip so when it gets re-inverted it's the right way up again.