Measuring VSS (SOLVED) - Page 1
Forum section: electronics / projects

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 17, 2011, 07:25:51 pm
content: Hi guys.I want to measure VSS (Vehicle Speed Sensor) signal from my car. It's analog device, just magnet and coil and it is going to another analog device (speedometer). And I'm in situation where it gets more complicated just because I want to have it digital.I'm working now with Mega16 (but if it's necessary I intend to upgrade to Mega644) and I have 1 external IRQ free, 1 or 2 Timers (and their inputs) and some ADC should be free as well. The sensor is designed to make 5khz signal when going 3600kmhso with 90khm speed signal should be 125Hz. But problem is with low speeds the signal amplitude is very weak like 50mV - 100mV and I would like not to miss them. I don't want go with car 30kmh just to force it that I'm moving at all.What you think guys would be the best approach? Amplify it, filtering spikes with zener and then sample it all the time with ADC? Somehow when I expected that the signal will be strong enough and only I had to do is just filter over voltages and I will be grand with 1 or 4 passive components.For any advice thanks in advance. Anton.PS: I recorded the waveform, it's here (in description on youtube is explanation for the spikes)PS2: I didn't post it into AVR micros section, because I think it's irrelevant. If I will be able to make digital signal from that analog it won't matter to what I will feed the signal.

author: Zero999
author_rank: Super Contributor
timestamp: February 17, 2011, 09:14:43 pm
content: It's pretty easy to make an amplifier and Schmitt trigger from CMOS logic gates.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 17, 2011, 10:15:29 pm
content: Quote from: Hero999 on February 17, 2011, 09:14:43 pmBut the 50mV - 100mV signal will triger the cmos logic levels?

author: Zero999
author_rank: Super Contributor
timestamp: February 17, 2011, 10:21:47 pm
content: Not normally but I've biased the first stage as a linear amplifier with plenty of gain which is fed into the Schmitt trigger with Vdd*0.1V of hysteresis.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 17, 2011, 10:44:06 pm
content: Quote from: Hero999 on February 17, 2011, 10:21:47 pmIt looks like I'm too stupid for thisI thought when you put output of NOT to input it will start oscilating.So I can just get cmos NOT gates and I should be OK?Do I need to put there some protection? Like zener diode. And some current limiter resistor? (it needs to go into instrument cluster without any change like minimal curent and voltage diference, so my device needs to be transparent to the car, if you know what I mean)

author: Zero999
author_rank: Super Contributor
timestamp: February 17, 2011, 11:03:52 pm
content: The 10M resistor biases the NOT gate into its linear region giving it negative feedback so it acts like an analogue amplifier. The other two not gates have positive feedback which causes hysteresis.What's the maximum voltage from the sensor? There isn't any need to add zener protection, if in doubt connect a 10k resistor in series with the input to limit the current.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 17, 2011, 11:14:48 pm
content: Quote from: Hero999 on February 17, 2011, 11:03:52 pmPerhaps 2V max but it's car environment and usually I try to protect the input from high voltage spikes (inducted from something), or just noise etc... And protect the car as well I don't want to buy new ECU just because my device draws to much current from ECUs signals etc... Like I don't trust that 12V power line will be perfectly stable and will have no over voltage peaks. So somehow I try protect everything from everything device from a car, car from a device.

author: Psi
author_rank: Super Contributor
timestamp: February 18, 2011, 01:03:19 am
content: I always put a 15V TVS diode across the power for any circuit i put into my car.It will absorb any spikes and keeps things from being damaged.Also, if im interfacing with something sensitive i use an optoisolator just to be safe

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 18, 2011, 02:08:23 am
content: I don't have inverters in cmos (just ttl). I found on ebay NOR gates. It will be OK if will just wire both inputs together and use them as NOT in your schematic?

author: oPossum
author_rank: Super Contributor
timestamp: February 18, 2011, 08:18:20 am
content: CD4049UB is one of the best chips for a circuit like that. The more complex CMOS gates are not well suited for linear applications.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 18, 2011, 02:54:00 pm
content: Quote from: oPossum on February 18, 2011, 08:18:20 amI was looking in the TI datasheet and the lettering after CD4049 are just different packaging etc...so when I get CD4049UBE like this onehttp://cgi.ebay.ie/2-x-CD4049UBE-CD4049-4049-Hex-Buffer-Converter-/270510389202?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item3efbacf7d2I should be OK?If I understand right the first stage is not about detecting voltage high enough to trigger it as HIGH, but it's about voltage low enough to be considered as LOW, right? And the signal si DC so I will put some generic diode in series to filter the negative part of signal ( I won't miss it, I want to count pulses I will be able to it with positive half as well).

author: Eliminateur
author_rank: Regular Contributor
timestamp: February 18, 2011, 03:16:10 pm
content: truhlik, letme see if i understand:1) sensor aries freq by speed](since it's a coil and a moving magnet on the wheel that's ok).2) but it also varies amplitude -spcially lower- at low speedsSo to measure speed, you need to use your AVR as a freq counter.....Why not use a opamp as amplifier to get a nice signal and after that a schmitt-trigger or a simple voltage comparator or zero crossing-detector(there are examples in opamp datasheets), i think with low offset opamps(like the opa277 / 177 series from TI) you can build a zero-crossing detector for 50mV signals, and then you count the output of the ZCD as frequency=velocity!

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 18, 2011, 04:13:57 pm
content: Quote from: Eliminateur on February 18, 2011, 03:16:10 pmExactly that I want to do, calculate speed from frequency, just I was surprised that the amplitude is changing so much. Actually it no surprise at all, just I was naive enough and blindly hoping it will be easierIt looks like the signal is differential (I have another wire, I didn't probe it, but it looks like diferential), So I could feed booth of the to the opamps inputs.

author: Eliminateur
author_rank: Regular Contributor
timestamp: February 18, 2011, 04:20:29 pm
content: yeah, but even if it changes, a precision(DIP, nothing SMD) opamp with 50uV offset -even a 1mV standard opamp would suffice for you, no need to use differential- and since output always crossed zero no matter what amplitude/speed, then a zero cross is better imho than a low-level comparator(and less error prone on weird waveforms).The issue is that i don't know how a ZCD behaves if the input is.. flat 0(car stopped), maybe it will output a continuous high, which thinking back wouldn't be an issue since it doesn't changes

author: Zero999
author_rank: Super Contributor
timestamp: February 18, 2011, 07:07:27 pm
content: Quote from: truhlik_fredy on February 18, 2011, 02:08:23 amYes, of course you can do that.Quote from: oPossum on February 18, 2011, 08:18:20 amThe CD4049 doesn't bias at half the supply because it has asymmetrical outputs, the CD4069 or even a NAND/OR gate is better for this application.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 18, 2011, 10:56:15 pm
content: Quote from: Hero999 on February 18, 2011, 07:07:27 pmThanks. And can I use this circuit to protect yours? (I used parts what I have avaible)

author: Zero999
author_rank: Super Contributor
timestamp: February 19, 2011, 09:52:30 am
content: There's no need for any diodes, the 10k resistor on its own is fine. CMOS gates have internal clamping diodes which limit the input voltage to 0.6V above or below either supply voltage rail.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 19, 2011, 01:13:39 pm
content: Quote from: Hero999 on February 19, 2011, 09:52:30 amThank you very much. I saw your Poor mans opamp, that is nice too

author: Zero999
author_rank: Super Contributor
timestamp: February 19, 2011, 03:19:06 pm
content: Yes, except I wouldn't use is as an op-amp, it's not that good. You need to bear in mind there's a big difference between op-amps and comparators.Here's a paper which deals with this:http://www.electro-tech-online.com/attachments/datasheets-manuals-parts/30559d1245492465-looking-quad-op-amp-chip-op-ampsascomparatorsv1.pdf

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 19, 2011, 05:17:34 pm
content: Quote from: Hero999 on February 19, 2011, 03:19:06 pmNice paper, I like the big "don't" in capitalsThanks

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 24, 2011, 07:36:17 pm
content: Hi guys. Thanks for all suggestions, I was digesting them, then I look into theory why the thing work like they work. And from them I got ideas for different approaches etc... And now I thing I have something usable.So I was playing around with couple ideas what I got from people and I think I came up with blend of almost all of them in one circuit. I made it on my workbench and I think it's working quite well. I didn't had any function generator but 50Hz hum noise saved me. It's everywhereas input I have just floating 0.5m cable around and even when tried to touch compensation reference on my scope (1khz) my body acted like transmitter and I was able to detect it on my input and make nice 1Khz square from it. This design started as differential opamps setup, but then I noticed that mine opamp under this condition was not able to handle AC (negative signal) so then I went different way.First I have 33k resistor, then 5.1V zener diode and then TVS 37V diode. Then it's going into first stage of opamps. It's configured to make about 4x gain I added this first stage just because my second stage had hysteresis around ground. I wanted to have LOW trigger around ground so I was able to do it, but consequence was very awkward values for resistors and then switching feedback from LOW to HIGH and back went very slowly and the raise/fall was noisy so it wasn't making purpose what I wanted and it triggered multiple times while it was falling etc... So I made first stage amplifier and then second stage could have more reasonable values for hysteresis. I ended up with 520mV for HIGH (divided by 4 it's 130mV in original signal) and 80mV for LOW (20mV in original signal), firstly I had much lower LOW trigger but I had problems with it again, but now I think because the amplified signal had almost perfect 0V while the original signal even on opamps input was able to swing little bit into negative. But now on output of second stage I have almost usable signal, I don't have false triggers but on the output the fall is jiggered and noisy (it's not clear and nice line). So it goes into third stage with different hysteresis setup to be sure the noise wont bounce different levels in MCU while it's falling etc... so third stage is 2.88V for HIGH and 2V for LOW and I thing if I should put 1k or even 680 instead 1.3k feedback resistor to have bigger difference in trigger levels (what you think guys?). And now I think I got TTL compatible output, the HIGH from opamp was 4V instead 5V but it was much cleaner, raises and falls too etc... (the noise was gone, but the raise/fall curve had tendency to wait in middle for a while and then continuing to raise/fall, perhaps because of the feedback switching) Just to be sure I feed it into inverters the first stage of the inverter got me 5V on HIGH instead 4V and the raise/fall is almost straight line (no waiting in the middle), then the output is feed to second stage of inverter and now the fall/raise time is 3x to 10x faster than fist stage (now 70ns fall time and 120ns raise) and the base voltage is constant while on first stage was small swing when it drooped to low. Now it's very nice square and 100% TTL.All parts used are available, so I made it from everything what I found in junk box, if something is overkill and could be done with cheaper/alternative device then I don't mind to use this ones, just because I have them on hand and if you guys give me OK on this design I will make same as it's on picture, just I will make it on small PCB and add couple thing like jumpers to be able to ignore fist stage and then jumper for 2 alternative second stages, one like on the picture and another one almost the same just with potentiometer so I could make small variations with 2 jumpers and 1 potentiometer. And then I will try it in real condition how it's working. Just I'm curious if there is something wrong and asking just for big troubles. Perhaps I should lower the feedback resistor on 3th stage etc...Best regards Anton. And again thank all of you for all advices.PS: Sorry for my scribe I just painted it in photo editor.

author: Zad
author_rank: Super Contributor
timestamp: February 24, 2011, 08:00:41 pm
content: Personally, I would start by filtering the signal with at least an RC pair, and preferably an LC pi tank. Obviously, the knee frequency would be well above the frequency generated at maximum expected vehicle speed.

author: ruku
author_rank: Contributor
timestamp: February 24, 2011, 11:03:20 pm
content: Thinking of just a simple solution...Does the frequency go to 0 Hz when you come to a stop? Could you use a low pass filter to treat the signal like PWM, and measure the average value (DC)?

author: vl400
author_rank: Regular Contributor
timestamp: February 25, 2011, 07:47:37 am
content: The LM1815, as well as a few equiv chips from other manufacturers, works great for reading reluctor sensors on vehicles. I also use these on cam and crank trigger circuits. They are not cheap but are a variable gain zero crossing detector with a one shot output and work at very low voltage levels when the VSS or engine are rotating slowly.

author: Zero999
author_rank: Super Contributor
timestamp: February 25, 2011, 09:08:47 pm
content: It looks overkill to me. Did you try the circuit I posted using a few logic gates? if it doesn't work it can be tweaked.All of that can be done using a single comparator IC such as the LM393 or LM311.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 25, 2011, 10:33:44 pm
content: Quote from: Hero999 on February 25, 2011, 09:08:47 pmYour design is in the to-do as wellAnd the last solution what I want try is with MAX9924, it on the way and I desperate to get it ASAP because I'm curious how well it will work.QuoteI don't argue, but that chips I have on hand, and don't have lm393 / lm311 .

author: Zero999
author_rank: Super Contributor
timestamp: February 25, 2011, 11:14:36 pm
content: It can also be done with a LM324 and half as many resistors. It's basically the same with the LM393 except you need to add a pull up resistor to the output and can omit the protections diodes which are built-in to the IC.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: February 26, 2011, 08:47:40 pm
content: Quote from: Hero999 on February 25, 2011, 11:14:36 pmI'm little worried about that part (pull up, or feedback), I felt much more in comfort when there is a sort of buffer, still the signals need to go to another instrument etc..

author: Zero999
author_rank: Super Contributor
timestamp: February 26, 2011, 08:59:18 pm
content: I either forgot to attach the schematic to my previous post or there was a problem with the server.Here's what I had in mind. If you opt for the LM393, you save the diodes but need an extra pull-up resistor.

author: Eliminateur
author_rank: Regular Contributor
timestamp: February 28, 2011, 05:35:37 pm
content: truhilik, looking for parts to design a circuit for naother project, i found something that might interest you:http://www.national.com/ds/LM/LM193.pdfpage 11very simple zero-crossing detector with a jelly-bean LMx93 series comparator

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: March 02, 2011, 04:49:46 pm
content: Quote from: Hero999 on February 26, 2011, 08:59:18 pmThanks I will order LM393 and I will try it later, now I received the Maxim 9924 samples so I want to try them out first.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: March 02, 2011, 04:52:06 pm
content: Quote from: Eliminateur on February 28, 2011, 05:35:37 pmThanks that nice, I was thinking about zero crossing earlier, I will order LM193 as well. It looks like to be good idea to have couple different kinds of opamps, I can't stock just LM324 and hope that everything will be solvable with it.

author: truhlik_fredy
author_rank: Regular Contributor
timestamp: March 27, 2011, 10:02:06 pm
content: I want just go back and thanks for everyones suggestions. Today I finished and tested the design with the Max9924 (the uMax 10 is not the easiest to solder) and it works just beautifully. I wanted to test all approaches suggested, but now it impressed me so much that I will keep this design. I will test all others, but just when I will be bored and be curious just to see how they works. But definitely for everyone else in similar situation, the Max 9924 is very good choice to go, I used the reference design for A2 mode.