Acceleration from wheel speed - code examples?

Hey guys,

I've got a simple 0-5v pulse on a wheel speed sensor and I'd like to illuminate a series of LED's depending on the change in wheel speed. So if the frequency is changing by +10hz/sec than digitalWrite(pin, HIGH). The problem is I have absolutely no idea how to measure the wheel speed frequency. Does anyone have any links with something similar that I can use an a example?

need spec sheet for the rotation sensor. Any details you can provide?

Hi, sorry I don't. Its a square wave 5 v signal that pulses 40 times per revolution so at 100 mph its still around 3khz

You will need to "sample" at a specific interval (maybe 10% greater then highest estimated speeds Fq?) and calculate your Fq from those readings. This will also give you a reference to calculate the acceleration.("Sample" is generic you could count interupts for instance)

Since it's a nice clean square wave you shouldn't have any trouble connecting it to an interrupt.

In the interrupt, increment a rotation count.

In the main loop, process the rotation count periodically (say once per second).

Processing consists of copying the count into a local variable and then zeroing it (so the interrupt can carry on incrementing without affecting your calculations).

Compare the current count against the count from the last sample to see whether the signal is faster or slower than last time. This is your 'acceleration' value.

Do any scaling necessary to convert the acceleration into meaningful units and then do whatever you need with it.

Save the current count for use next time.

Hi, Are the 40 pulses per revolution equally spaced, if so I have some code that will do, if not you can modify it easily enough.

Let me know

Duane B

rcarduino.blogspot.com

Hey Duane, That would be awesome.. In fact I was on your blog last night. I was going to email you but didn't know how best to get a hold of you. Thanks a bunch.

Hi, What type of sensor is it that you are using to get 40 pulses per revolution ? Its not counting spokes is it ?

I have no idea how complex the rest of your application is but I have an idea that using a simple counter IC to reduce the number of pulses per revolution might be helpful.

Using a counter together with an AND gate you could generate a single pulse to the Arduino for every 40 sensor pulses. There are several advantages to this -

1) The Arduino is free to do a lot more work, we have reduced the interrupt load to be 40 times more efficient 2) The code will not need to be optimised to the nth degree 3) The maths can be much less sophisticated to calculate frequency (revs) and the rate of change from a single pulse per revolution

Duane B

rcarduino.blogspot.com

Hey Duane, Its just a little hall effect sensor on a factory car whose original intention was to work the ABS system. The car has been since converted to a race car and does not have abs.

I'd love to dig threw your code if you wouldn't mind sharing! Thanks for the help!

Hi, As you know from my blog, I have used the Arduino to measure the wheel speed on my RC Cars, the wheels generate a single pulse once per revolution giving me a maximum rate of 68 pulses per seconds. I expect the same code would also work for you and your much higher frequency pulses however it may require some tuning.

Now, I think it might be interesting to collaborate with you to get something suitable running for your application, my only reservation is that I am not that excited by the end goal of the project as you have currently described it - 'I'd like to illuminate a series of LED's depending on the change in wheel speed' is there more to it or is there some higher purpose that is being served by these LEDs ?

Also how about a picture of the car and a little bit about what you use it for just because I (and others might ) am interested regardless of whether I can help out or not.

Duane B.

Hey Duane, I sent you a PM. I'm not sure if it sent though. Let me know if you didn't get it.

Hi, I received and replied to the PM, I know that PM's were not working recently, so if you don't get it, let me know here.

Duane B