Author Topic: Measuring VSS (SOLVED)  (Read 20113 times)

0 Members and 1 Guest are viewing this topic.

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Measuring VSS (SOLVED)
« on: February 17, 2011, 07:25:51 pm »
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 3600kmh :) so 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.
« Last Edit: March 28, 2011, 09:01:13 pm by truhlik_fredy »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19568
  • Country: gb
  • 0999
Re: Measuring VSS
« Reply #1 on: February 17, 2011, 09:14:43 pm »
It's pretty easy to make an amplifier and Schmitt trigger from CMOS logic gates.
 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #2 on: February 17, 2011, 10:15:29 pm »
CMOS logic gates.

But the 50mV - 100mV signal will triger the cmos logic levels?
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19568
  • Country: gb
  • 0999
Re: Measuring VSS
« Reply #3 on: February 17, 2011, 10:21:47 pm »
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.
 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #4 on: February 17, 2011, 10:44:06 pm »
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.

It looks like I'm too stupid for this :) I 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)
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19568
  • Country: gb
  • 0999
Re: Measuring VSS
« Reply #5 on: February 17, 2011, 11:03:52 pm »
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.
 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #6 on: February 17, 2011, 11:14:48 pm »
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.

Perhaps 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.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: nz
Re: Measuring VSS
« Reply #7 on: February 18, 2011, 01:03:19 am »
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
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #8 on: February 18, 2011, 02:08:23 am »
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?
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1421
  • Country: us
  • Very dangerous - may attack at any time
Re: Measuring VSS
« Reply #9 on: February 18, 2011, 08:18:20 am »
CD4049UB is one of the best chips for a circuit like that. The more complex CMOS gates are not well suited for linear applications.
 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #10 on: February 18, 2011, 02:54:00 pm »
CD4049UB is one of the best chips for a circuit like that. The more complex CMOS gates are not well suited for linear applications.


I was looking in the TI datasheet and the lettering after CD4049 are just different packaging etc...so when I get CD4049UBE like this one http://cgi.ebay.ie/2-x-CD4049UBE-CD4049-4049-Hex-Buffer-Converter-/270510389202?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item3efbacf7d2 I 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).
 

Offline Eliminateur

  • Regular Contributor
  • *
  • Posts: 179
  • Country: ar
  • Electronic's Technician
Re: Measuring VSS
« Reply #11 on: February 18, 2011, 03:16:10 pm »
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 speeds

So 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!
 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #12 on: February 18, 2011, 04:13:57 pm »
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 speeds

So 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!

Exactly 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 easier :)

It 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.
 

Offline Eliminateur

  • Regular Contributor
  • *
  • Posts: 179
  • Country: ar
  • Electronic's Technician
Re: Measuring VSS
« Reply #13 on: February 18, 2011, 04:20:29 pm »
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
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19568
  • Country: gb
  • 0999
Re: Measuring VSS
« Reply #14 on: February 18, 2011, 07:07:27 pm »
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?
Yes, of course you can do that.

CD4049UB is one of the best chips for a circuit like that. The more complex CMOS gates are not well suited for linear applications.
The 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.

 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #15 on: February 18, 2011, 10:56:15 pm »
Yes, of course you can do that.

Thanks. And can I use this circuit to protect yours? (I used parts what I have avaible)

 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19568
  • Country: gb
  • 0999
Re: Measuring VSS
« Reply #16 on: February 19, 2011, 09:52:30 am »
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.
 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #17 on: February 19, 2011, 01:13:39 pm »
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.

Thank you very much. I saw your Poor mans opamp, that is nice too :)
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19568
  • Country: gb
  • 0999
Re: Measuring VSS
« Reply #18 on: February 19, 2011, 03:19:06 pm »
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
 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #19 on: February 19, 2011, 05:17:34 pm »
 

Offline truhlik_fredyTopic starter

  • Regular Contributor
  • *
  • Posts: 62
Re: Measuring VSS
« Reply #20 on: February 24, 2011, 07:36:17 pm »
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 everywhere :D as 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.
« Last Edit: February 24, 2011, 08:32:50 pm by truhlik_fredy »
 

Offline Zad

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: gb
    • Digital Wizardry, Analogue Alchemy, Software Sorcery
Re: Measuring VSS
« Reply #21 on: February 24, 2011, 08:00:41 pm »
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.

Offline ruku

  • Contributor
  • Posts: 25
Re: Measuring VSS
« Reply #22 on: February 24, 2011, 11:03:20 pm »
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)?
 

Offline vl400

  • Regular Contributor
  • *
  • Posts: 62
  • Country: au
    • Delcohacking.net
Re: Measuring VSS
« Reply #23 on: February 25, 2011, 07:47:37 am »
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.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19568
  • Country: gb
  • 0999
Re: Measuring VSS
« Reply #24 on: February 25, 2011, 09:08:47 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf