[Gllug] Data sampling problems

Kens kens at kensnet.org
Sat Sep 17 14:00:06 UTC 2005


Tethys wrote:

>In my spare time, I'm part of the crew for a top fuel dragster[1].
>Lacking the money to buy an off the shelf model, I built us a
>datalogger, so that we can analyze information from the car after
>each run to try and work out what went right and what went wrong.
>(it's an embedded system based around an ARM CPU running Linux --
>naturally :-)
>
>Amongst other things, I'm trying to measure the crankshaft RPM,
>using a sensor and some magnets embedded into the flywheel, with
>the time between pulses being used to calculate the RPM. The
>problem I'm having is that the results aren't consistent. Instead
>of the expected RPM, my results are showing oscillating values
>above and below the expected figure:
>
>	http://www.astradyne.co.uk/ref/crankrpm.png
>
>We're expecting somewhere around 5000 RPM at that point, so taking
>an average of the values recorded gives approximately the right figure.
>
>Any ideas what could be causing that? My initial thought is that my
>sample frequency is too close to the pulse frequency, and that upping
>the sample rate might help, but before I go off on a wild goose chase,
>I just wondered if there might be other explanations.
>
>Incidentally, I'm using a software loop for the delay between samples.
>I initially tried nanosleep(2), but I don't know if it's just the syscall
>overhead or something else, but it was sleeping for too long (I only need
>around 10ms delay, so I'd have thought it should handle that with ease,
>but apparently not).
>
>Tet
>
>[1] This one: http://www.pbase.com/slimboyfat/image/49107232/original
>  
>
If I'm understanding you correctly, assuming there is one magnet and the 
engine is running at 5000 RPM, there will be a short pulse every 12mS. 
That pulse could be quite short depending on the physical size of the 
magnet and the coil (I assume a coil is detecting it).

Exactly what happens then? How do you interface this with the computer?

If the flywheel has a diameter of 12", therfore a circumference of 38", 
at 5000 RPM a 1/4 inch magnet at the edge of the flywheel will take 80 
microseconds to pass the coil. Being practical I wouldn't bank on a 
pulse any longer than 40-50 microseconds. If the flywheel itself is 
magnetised in any other way I'd also expect some interference on the 
incomming signal as well as crosstalk from the ignition system which 
can't be far away. You say there is more than one magnet so that will 
just mean a series of short pulses every 12 mS. (Is capital S the SI 
unit for Seconds?)

It would be good if some external hardware interface then cleaned up the 
pulses and interfaced them to the computer, but I'm assuming that they 
are directly interfaced and the sampling is done in software. I don't 
know how fast an ARM processor is, but to be fairly confident of finding 
the pulses it will need to sample the coil every 25 microseconds or so. 
At 100MIPS that's a sample every 2500 processor instructions. 
Alternatively the pulse could be fed to an interrupt and and a simple 
driver count the interrupts. All this depends what else the processor is 
doing and whether it can sample fast enough or respond to interupts 
quickly enough. I'm speculating here about how the thing is implimented.

The hardware assist approach could count the pulses every second and 
offer the result to the processor in an I/O register to be read at the 
processors leasure.

Does that help any - or am I teaching egg sucking (sorry if I am)

Ken
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list