Making a RPM meter using a old computer mouse and a BS2
theruss007
Posts: 7
Hi. I bought a Basic Stamp 2 about a year ago to build a robot and never used it·since. Now I am planning on using it to measure rpm. My plan is to use the geared disk on an·old computer·mouses to produce pulses from a IR LED to a Phototransistor·that the BS2 can count and tell me the pulses per minute.The gear·would make aprox.·40 pulses per revolution. I know theres a way to do it using the pulsin command, but how do I get it to be a rate of how many pulses per minute. Can the BS2 do math because I would use·that ability to·tell me how many revolutions per minute instead of pulses.I would I start the programming. I plan on using this from a sterling engine to a common 12v motor.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I posted my reply there.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
"The mouse parts should do for the input. The stamp can do integer math (whole numbers) and you can probably count the pulses in one second multiply by 60 and devide by the pulses per revolution."
My only problem is I don't know how to do all of that. The only programing I did with the BS2 is try, and build a robot that failed to work(it spun in circles).
So how do you do it. The simple math stuff I am sure I can look up, but the count the pulses per second I have looked up, and have had no luck on.
Name var word
Name2 var word
Name3 var word
top:
Count 5,1000,Name
Name*60= Name2
Name2/(number of pulses per revolution)=Name3
debug Name3
goto top
WOuld that be anything near what I want it to do?
Name2=Name*60
and
Name3= Name2/PPR
Remember that the stamp truncates and does integer math only, so always multiply first and divide last for best accuracy, just as you have done.
FYI, you could also do it all with the one variable in one step:
count 5,1000,Name
Name=Name*60/PPR
It's OK to use a variable in equation to redefine itself, like:
X=X+1 or Y=(Y*7)/(Y+7)
A mindblower, huh? Just remember it's like
(new Z value)=(old Z value)*(math manipulation)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."