HOW TO READ variable reluctance sensor (vr) for speedometer

hi. i am trying to use the arduino as a car ECU, to read values. So far so good. BUT, when it comes to speed, i have a problem. appreantly, the speed sensor is a variable reluctance sensor. unfortunetly, i dont know much about how does it work... i tried to read its signal with the library found here :
FreqMeasure Library, for Measuring Frequencies in the 0.1 to 1000 Hz range, or RPM Tachometer Applications . but i face the following problem :
when i monitor the speed, nothing really shows as long as i move. instead, all comes up when i stop. also, the frequencis, have nothing to do with each other (fro 1hz to 100000hz without chaningig speed)..

the speed sensor outpouts 2 cables wich go to the car ECU. from that wires i take the signal. the positive, goes to the pin to be read. Do i need any spacial IC to make the signal readable?
as you can see i dont really know where to begin, so any help would be appreciated!!

You need to pass the signal from the sensor through a least a comparator before the Arduino can process the signal. You might be able to use the analog comparator that is built in to the Arduino. Alternatively, use an external comparator IC such as LM393.

so... the sensor has two wires. i suppose that those two would be used to arduino for the analog comparator?? but what would the sketch look like? i cant seem to be able to find a docomuntation...

settra:
so... the sensor has two wires. i suppose that those two would be used to arduino for the analog comparator?? but what would the sketch look like? i cant seem to be able to find a docomuntation...

Once the sensors signal has been converted to a reliable digital signal then you would process the signal in your arduino as a simple frequency input signal. So any arduino frequency counter type library, function or sketch could be your guide. Try goggling arduino frequency counter and see what the cat drags up.

Lefty

settra:
so... the sensor has two wires. i suppose that those two would be used to arduino for the analog comparator??

Yes. Is the sensor still connected to the ECU? If so, I suggest you measure the DC voltage on each wire (they should be the same) when the engine is running, and check that it is in the range 0 to 5V. Also connect a resistor in series with each of the analog comparator inputs (I suggest about 47K) to protect the inputs from under- and over-voltage.

settra:
but what would the sketch look like? i cant seem to be able to find a docomuntation...

The analog comparator is described in the atmega328p datasheet. The simplest approach is probably to program it to generate interrupts.

well i am prety srue, that , since my car dosent have An ECU, all the work is being done to the instruments panel. BUT i have removed it, so the answer is that, its not connected to the "Ecu" . the only voltage i can see, is a small AC voltage that depends on the rev of my engine (maybe noise from the alternator??) .
i tried doing something simplier, i connected the two wires to the analog inputs, and had them show up their values. the one always had 0 and the other had 50, witch varaied from 100 to 500 when i was moving BUT, not according to my speed... after some time of moving it would drop to 50 and so on...

Are you certain that's the speed sensor and not the rev counter? A small AC voltage whose amplitude and frequency increase with the speed of rotation of the sensor is exactly what you should get from a variable reluctance sensor.

Are both connections to the sensor isolated from ground? If so, you need to connect one side to ground or to a bias voltage (depending on what sort of comparator you use).

Nope. the rev counter uses a hall effect sensor, wich i have arledy read... strange thoguh they use a diferent type if sensor for speed!. i dont think its isolated from the ground, since everything in the car is connected to ground... u sed i sould see a rising AC voltage?? exept the noise from the rev, i dont see anychange at AC when speeding... Any chance it could be enother type of sensor? but i dont think there are any others, expet hall effect...

Use a multimeter to measure the resistance between the two connections (both ways round), and to measure the resistance from each connection to ground (again, both ways round). From the results, we should be able to tell if it is a variable reluctance sensor.

so. i bought a LM393. but i cant really figure out how it works... any help??

If it is a variable reluctance sensor, then the attached schematic should work. Set the Arduino input pin mode to INPUT_PULLUP.

Did you measure the sensor with a multimeter as I suggested?

[EDIT: altered schematic]

well, after all, i did not got to solved it... i figured, instead of trying to translate audi's boolcrap, it was easier to just build a speedometer. and that i did. one magnet on the wheel, and one hall effect sensor, (like 2 euro at total). but thanks allot for your help anyway!!

Hi All - First Post! I'd like to start out by saying that this is a great community with a handful of standout contributors, and I'd like to thank them for that. I am not a programmer, and I have very limited knowledge with circuits and hardware, but I have learned quite a bit in the little bit of time I've been tinkering. I've been lurking for a couple of weeks and have successfully built a couple of the components for my project modifying some code and using schematics from this site.

With that said, I'm trying to count RPM's using the crankshaft position sensor from an engine. The sensor has a magnet inside, and reads a splined shaft. I hooked it up using the schematic that dc42 provided a couple of posts back, but I'm not getting any readings.

I tried a few different RPM sketches I've found and modified, but with my lack of coding knowledge I'm pretty much stumbling around in the dark. To top it off, I'm not sure if my problem lies with the code or components.

Without an oscilloscope, is there a way of finding out if I'm getting the right signal out of the LM393 to feed into the Arduino?

Regarding the circuit I posted, if you don't have it connected to an Arduino input that has the internal pullup resistor enabled, then you will need to connect a pullup resistor from the output to the positive supply.

To see if it is working, connect a multimeter between the output and ground, to measure the voltage. If there is no input, the voltage should be close to zero or close to the supply voltage. With an input, the average voltage will move away from that value, maybe a little, or maybe to around half the supply voltage.

If the output from the sensor is very small then you may need to reduce the value of the 10K resistor.

Thanks dc42, I'll try it when I get home. I don't have any specs from that CPS I'm using, but with a 21 tooth sprocket spinning about 2800 RPM's, I'm seeing around 18V output. I'll be measuring up to 8,000 RPM's. Do I need to find out how much voltage that sensor will put out at the max RPM's to determine the needed resistors?

I set the pullup on the pin and I'm at least getting some numbers. The numbers follow speed, but there seems to be all sorts of interference. Turning on or off the fluorescent light above the bench changes the output. Like I said before, I'm a total newb with both the hardware and software side of things. I've got someone coming over this weekend to help me out, but I'm enjoying getting familiar with it in the mean time.

With an input voltage from the sensor that large (18V), you should add a diode (1N4148 or similar) between the inverting input of the comparator and ground (cathode side connected to ground) to limit the maximum positive voltage input.

To get ride of the interference from the light:

  • keep the wiring between the 100K input resistor and the comparator input short, that point is sensitive to noise pickup

  • reduce the value of the 1M resistor. Lower will decrease the sensitivity. Too low and the circuit won't work at low RPM.

Many thanks again dc42. I'm guessing that at the 8000 RPM range, I'll be seeing quite a bit more voltage. This is only a guess, but it could be 40-50v. Will this diode still be OK? I can always use a smaller tooth sprocket to bring that back down to a more acceptable level. Now I just have to wait another six hours to get home to try your suggestions.

Off to the parts store again to pick up that diode

kracer20:
Many thanks again dc42. I'm guessing that at the 8000 RPM range, I'll be seeing quite a bit more voltage. This is only a guess, but it could be 40-50v. Will this diode still be OK? I can always use a smaller tooth sprocket to bring that back down to a more acceptable level. Now I just have to wait another six hours to get home to try your suggestions.

Output voltage should be proportional to frequency, so at 8000rpm will be about 50V based on your reading of 18V @ 2800rpm. The current through the 100K resistor will only be about 50V/100K = 0.5mA. The 1N4148 is rated at something like 200mA, and the LM393 is rated at 50mA input current when the input voltage is below ground. So no problem as long as you fit that diode.

Can I know what specific type of speed sensor do you use? Also, do you know any other speed sensor can I use for arduino? I have a project about measuring speed using any type of speed sensor in arduino. Hoping for your good and immediate response. Thank you!