View Full Version : RPM sensor pulse converter

12-22-2009, 10:51 PM
I'm building a circuit to convert pulses read from a motor shaft·using a·hall effect sensor·that outputs·30 pulses per revolution.· My circuit needs to·read that signal·and convert it to an output·of 100 pulse per revolution.· I'm having trouble trying to create the software and need some advice.· I'm attempting to read the pulse on and off times using ctra and write those in microseconds to variables.· found code in obex that does something similar.· I need to revise those values to new microsecond values at the new pulse rate and then output them.· Since the output pulses occur faster than the input pulses, I'm running into issues and assume I need to do some type of averaging to smooth out the output changes.· Any help or advice or pointing to similar type coding would be much appreciated.

Erik Friesen
12-22-2009, 11:04 PM
It will depend some on how accurate this needs to be. For example, does 300 revolutions have to output exactly 1000 pulses?

12-23-2009, 12:32 AM
The simplest would be to to put out 3 pulses for the first 2 input pulses and 4 pulses for the third input pulse. I am of course assuming that an average of three pulses is ok, and that the output pulses do not have to be equally spaced in time. The time between the input pulses could be right shifted 2 bits to give the delay between output pulses.

12-23-2009, 01:39 AM
It is being used just to read the RPM of the motor, and the RPM doesn't need to resolve below 1 RPM and wouldn't need to be read above 400 RPM. The need for the 100 pulse per revolution has to do with compatibility to an existing system. It is understood that the 30 pulses per revolution provides the needed accuracy for the RPM measurement, however the individual I'm providing this to insists on having the signal converted to an equivalent 100 pulse per revolution signal. If we had 1/10 RPM accuracy, I assume that would mean we would need to keep accuracy of 30 pulses in resolving to 100 +/-5 pulses out. I guess I could work the acceleration into it to help smooth the output.

12-23-2009, 02:55 AM
Cog 1 determines rpm via the 30/rev signal smoothing the result via a Kalman filter (There's one in Obex). This result drives Cog 2's output of a 100/rev signal.

12-23-2009, 04:35 AM
Hello ElectricSmith,

welcome to the forum.

The solution depends on the precision you need.

For example if these pulses are just to show the rpm on a rpm-meter
it doesn't matter if the ratio is a tiny bit away rom exact 100/30.

If you use these pulses for an incremental positioning system, every single pulse counts.

I have an idea which might work. The propeller has counters that can count independend from code-execution
You count 2 or 3 incomming pulses and measure the time that passed. So from this time you have a base to calculate
the waittime for the higher outputfrequency. Now if the frequency changes to lower values this is no problem at all.
The time of the next 3 pulses corrects the output-frequency alone.

If the frequency goes up the counter might count more than 3 pulses but then the time and the number of pulses
delivers a base to calculate the new (waittime) and output-frequency.

If you can do this in spin depends on the precision you need and the maximum-frequency that occurs

If you post information about these details the forum can make suggestions on how to solve this

best regards


12-23-2009, 05:08 AM
Download my code from the last post here.. You can probably tap into the ECU to read this signal