Author Topic: how to measure the speed of wheels? Which algorithm?  (Read 28354 times)

Offline mr_g

  • Full Member
  • ***
  • Posts: 205
  • BHP: 9
how to measure the speed of wheels? Which algorithm?
« on: February 15, 2010, 03:17:33 pm »
I have an intellectual dilemma, on creating algorithm for traction control module. Approximately I have:

700hz front approx 100kmph
430hz rear approx 100kmph

And twice as many pulses (interrupts) in the processor ... Let the processor run at 8MHz or 16MHz if necessary (the same as in VEMS v3)...

So, if I count the pulses per second, I would have each measuring 1 second late... This is not usable for TCM...

If I measure the time between 2 pulses, around 0.7ms, there will be an error in recalculation of the time in the speed will be greater...

What I thought was to measure the duration of 10 or 50 pulses... This would come in the time of 7ms or 35ms... Delay of 35ms for TCM electronics is not so bad, and the error would have been 10 or 50 times less then measuring only one pulse...

Or combine all those undergarments like every 0.1s, measure number of pulses, and meassure last pulse that didn't complete?

BTW, at 16MHz, 1 clock stroke is less than a micro-seconds, so I think that the processor must be fast enough to do 4 wheels and an algorithm for reducing the torque...

How does VEMS measure speed of a wheel or a speed of a engine?  ???

Offline dnb

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 837
  • BHP: 19
Re: how to measure the speed of wheels? Which algorithm?
« Reply #1 on: February 18, 2010, 05:04:42 am »
Count the teeth using the "time between n teeth" method and use a Kalman filter to smooth the speed.  A simple alpha filter with short memory would be sufficient.

N could even be 1 using this method because you will average out the timing errors.

Offline mr_g

  • Full Member
  • ***
  • Posts: 205
  • BHP: 9
Re: how to measure the speed of wheels? Which algorithm?
« Reply #2 on: February 18, 2010, 05:41:49 pm »
The error when converting time into a speed could be great in my opinion... And ATmega128 doesn't have hardware divider...

Does anybody know how VEMS do it?

Offline dnb

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 837
  • BHP: 19
Re: how to measure the speed of wheels? Which algorithm?
« Reply #3 on: February 19, 2010, 02:10:24 am »
The error when converting time into a speed could be great in my opinion...

That's why you smooth it with a sensible filter!

Let's assume you count clock cycles between wheel teeth:

If you use software interrupts on a processor running at 8Mhz, there are 11428 full clock cycles between wheel speed teeth.  It is unlikely more than a handfull of cycles will go "missing" between cycles.  500 clock cycles is only 4% at this speed, and at slower wheel speeds it is a considerably smaller percentage. 
I doubt this will cause too many problems with errors.

And if you're worried then have an "association test" as part of your filter - eg limit the maximum amount the wheel speed can change between sample windows, or simply throw the sample you suspect away and "coast" the last good speed.

Offline GintsK

  • Hero Member
  • *****
  • Posts: 1257
  • BHP: 50
Re: how to measure the speed of wheels? Which algorithm?
« Reply #4 on: February 19, 2010, 02:29:11 am »
IMO analogue electronics could be less compicate:
http://www.national.com/ds/LM/LM2907.pdf
and then back to desired frequency (if necessary) with
http://www.national.com/mpf/LM/LM231.html#Overview


Offline dnb

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 837
  • BHP: 19
Re: how to measure the speed of wheels? Which algorithm?
« Reply #5 on: February 19, 2010, 03:07:56 am »
I used a LM2917 for my TVR tacho.  They work pretty well but noise may be prove to be an issue in some applications.

Offline mr_g

  • Full Member
  • ***
  • Posts: 205
  • BHP: 9
Re: how to measure the speed of wheels? Which algorithm?
« Reply #6 on: February 19, 2010, 05:31:51 pm »
If you use software interrupts on a processor running at 8Mhz, there are 11428 full clock cycles between wheel speed teeth.  It is unlikely more than a handfull of cycles will go "missing" between cycles.  500 clock cycles is only 4% at this speed, and at slower wheel speeds it is a considerably smaller percentage. 
I doubt this will cause too many problems with errors.

time dividing to get the speed will take many clock cycles as ATmega doesn't have clock divider...

But thanks anyway... I would need this to calculate average consumption.. ;)

Offline dnb

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 837
  • BHP: 19
Re: how to measure the speed of wheels? Which algorithm?
« Reply #7 on: February 20, 2010, 03:03:43 am »
Not sure what you mean.  ATmega has at least one 16bit counter.  Use this (in a free-running mode) to count clock cycles between interrupts triggered by the wheel speed sensor.  (All the interrupt code would need to do is a subtraction of 2 numbers, check if the counter had wrapped and add a constant if so)

Outside of the interrupt, you can work out the speed from the time period - it doesn't matter really how long this takes since it will only affect latency, not accuracy.

Are you saying you've used up all the timers?

Offline lost

  • Sr. Member
  • ****
  • Posts: 325
  • BHP: 2


Offline rob@vems.co.uk

  • Hero Member
  • *****
  • Posts: 3115
  • BHP: 49
    • VEMS Forum
Re: how to measure the speed of wheels? Which algorithm?
« Reply #10 on: February 20, 2010, 04:40:14 am »
Would anyone really want to use those connectors on their cars?

Offline mr_g

  • Full Member
  • ***
  • Posts: 205
  • BHP: 9
Re: how to measure the speed of wheels? Which algorithm?
« Reply #11 on: February 21, 2010, 04:11:17 am »
Why not? I'm using them for a five years in about 150 cars in other application without any noticeable problems...



What do you have in mind?

Offline gunni

  • Hero Member
  • *****
  • Posts: 1492
  • BHP: 37
Re: how to measure the speed of wheels? Which algorithm?
« Reply #12 on: February 21, 2010, 05:47:40 am »
I have seen worse in OEM applications

Offline mr_g

  • Full Member
  • ***
  • Posts: 205
  • BHP: 9
Re: how to measure the speed of wheels? Which algorithm?
« Reply #13 on: February 21, 2010, 06:50:17 am »
There is no high currents... The biggest current is 0.5A... So it's up for the task...

It is resistant to mechanical influence as long it is inside the vehicle in dry place.. :D 

Offline dnb

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 837
  • BHP: 19
Re: how to measure the speed of wheels? Which algorithm?
« Reply #14 on: February 21, 2010, 07:02:09 am »
G_man - I use those connectors on my TVR heater controller.  They work fine (and the OEM version used the same connectors)

I think Rob was refering to the PS2 connectors from lost's post.  These don't belong on cars for fairly obvious reasons.