RPM sensor pulse converter
electricsmith
Posts: 20
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.
Comments
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
Stefan
http://forums.parallax.com/showthread.php?p=859156