there has been a lot of discussion about reading car's voltage as input pin, with suggestions on using voltage dividers etc.
Maybe it has been said before, but here's my attempt:
I want to use solid state relays with car DC as coil power supply, and arduinos own 5V as the switched circuit attached to inputs with appropriate pullup/pulldown resistors etc.
I know it's not as cheap as the voltage divider approach, but surely provides better surge protection. I'm going to use this to read the VSS and few other sensors in my car.
I want to use solid state relays with car DC as coil power supply,
Sorry I am a bit confused about exactly what you are trying to do. Do you want to read the car's voltage or do you want to read sensors that have a 12V output. If so it will matter what sort of sensor output you have. It could be a varying voltage, voltage pulses or a current loop.
here is something you can try. by "VSS" I assume you mean vehicle speed sensor. My 95 VW has this and I think it is 7 pulses per revolution of the wheel. Last winter, I diagrammed the circuit of the cruise control module. This, of course has an interface for the speed in which the incoming voltage is 0V to 12V and it has to clean this speed signal to 5V for the microcontroller.
have a look at this circuit. The speed signal comes in where I drew "7" inside a triangle. "7" is the pin number on the connector.
What I think it is doing is using a diode to prevent 12V on the input but it will pull to 0V. R5 is a pull-up resistor that will hold the line at 5V if it is not being asserted to 0V. There is also a CMOS inverter chip to buffer between the transistor and the microcontroller.
the speed signal comes in - goes through the diode, through R6 and into PNP transistor T11. After that - I have a hard time following it but I know that IC4 (the microcontroller) has one interrupt pin "INT" and that is what the speed signal is connected to and this is 5V, 50% duty cycle and frequency varying with speed. in other words, this circuit cleans up a 0 to 12V speed signal to make it 0-5V.
please be aware I knew very little about electronics when I made the diagram so I cannot explain everything on there. but I did check the circuit over and over and over again to make sure I had the diagram correct.
PS
The signal that goes out of that area through C7 is what causes the cruise to turn off when the car goes below 24mph. I tested this a bunch of times with my multimeter hooked to the module as I drove.
thanks deSilva - now I have learned something. I didn't know really what R9 did.
What do you think about the diode at the input - do I have that correct? that it limits the basic input to 0-5V by only allowing the speed signal to sink current?
maybe there is a way to use a Schmitt trigger chip?? to cut down the number of components?
for sure, the cruise control module had a lot of extra things in it to contribute to safety. If one just needed the basic function without any safety I'd guess the circuit might have been 1/2 or 1/4 the size.
Another simple option is an opto isolator. You drive the LED with the car's 12v, through a suitable current limiting resistor, and "look at" the photo-transistor with the Arduino....
Re: Optocoupler: Good choice for cars! Many types, quite cheap. The link is fine, one thing missing there: the resistor can be tied either to the collector or the emitter, giving you inverted or straight signals. It's value: 10 k is fine!
Have fun!
Okay, I've read my previous posts and I'm like WTF...
The concept is like this:
My car VSS is a linear frequency generated by reed switch, the signal is supposed to be 12V (<= 14V in fact)
instead of messing around with the circuits, I want to use a solid state relay (yes, they don't have a coil, sorry for the confusion).
So, the VSS signal will trigger the relay, which, in turn, will switch the arduino's 5V connected to digital-in via the said relay. so in practice, 12V pulses will trigger 5V pulses on the arduino input pin with the same frequency as the original VSS (with few microseconds delay).
SSR's provide better isolation (they are optoisolated) and are bounceless. Not to mention no moving parts and 100% silent operation.
Like this (yay my paint skills):
Ofcourse there will be pull-down resistors on both VSS (before the relay due to its sensitivity to transient voltages) and +5V.
Fazzah, the way I read this is that everyone did understand your first post but simply took some time from their day to explain better ways to do it.
my take on this is that the SSR 'looks' like it would work but these are designed for switching Loads. The other circuits or methods described here are for interfacing inputs of micros which of course is what you are attempting to do. I am not an EE so I don't know the fine details of the various options. What I can say is that I have read the diagrams for some of the boards at my work and opto-isolators are very common as interfaces between the high voltage AC side and the DC 5V microcontroller. there might even be a chip that does opto and schmitt trigger in one package...?
And the page says "Furthermore, don't think "Oh, we always connect all the grounds." In this circuit, you DON'T connect the grounds."
But since the arduino is powered by car's DC, the grounds are already connected huh? Or am I overlooking something again?
If you have a common ground then you have defeated the point in having an opto isolator, which is to isolate two systems.
It boils down to you simply needing a transistor to act as a voltage converter. Emitter to ground collector to input and base via a 4K7 resistor to the 12v sensor. Enable the internal pull up resistor. This provides just the same isolation as a SSR at a tiny fraction of the price.
But is there a way to not have a common ground with the power supply?
Not sure I understand the question. If you have an isolated supply powering the arduino then there is no need for a common ground if you use an opto isolator. However it is tricky to make an isolated power supply from an existing supply. It involves making an inverter. That is power oscillator, transformer, then rectify and smooth again.
But this is also only part of the truth....
An optocoupler will protect the input against high current/voltage EVEN if grounds are connected. Worst case he optocoupler will break, but never the input
This is only half of all its benefits, but might be worth considering. Note that we are talking about 20 cents articles, be it a cheap optocoupler, a 4049 (still ma favourite solution), or a transistor plus base resistor)
I think never mentioned before, but the simplest solution is just using a serial 220k resistor and nothing else. This is absolutely fine for upto 22 volts input and spikes upto 220 volts. The edges of the signal however will no longer look like in the textbook
Worst case he optocoupler will break, but never the input
True but this is almost always the case with a transistor as well. When a transistor fails due to excessive base current / voltage then it fails base to emitter short or open. The only way the arduino input would be in damaged is if the transistor failed short base to collector which I can't see happening.
Let's get back to what is creating your signal. You said there is a reed switch on the speedo cable. Is this original equipment or something you added?
A reed switch may not last very long - is there a possibility of putting an optical switch or hall-effect switch there?
I asked a very talented EE tech this morning about isolation of grounds in boards. I got very confused but in the end I keep looking back at my mostly very reliable cruise control module which seems to fundamentally use a transistor. There is no transformer, switching supply or opto-isolator in that module. It is still working even though the car is 16 years old.
The PCBs at work seem to have earth ground, chassis ground and signal ground but on a car I think there might be just one ground for everything. might
Let's get back to what is creating your signal. You said there is a reed switch on the speedo cable. Is this original equipment or something you added?
A reed switch may not last very long - is there a possibility of putting an optical switch or hall-effect switch there?
It's the original equpiment, it's where the ECU gets the VSS. It is there since 1997 when the car was built, and never heard that it has broken in even older Vitaras (or Sidekicks, as named on US market)
It looks like this:
Also, as you can see, it is placed in a quite clever way, so should the need arise, I can replace it in no-time (well, after maybe 30mins needed to remove and disassemble the cluster)