help with RPM maths

buntay

Senior Member
Hey all having issues with some maths.
heres the setup

a prox that sences 8 bolts and i need to hold a 200rpm using an output based in the "count" input.
so heres what i have so far.
1 rpm = 8 bolt "counts" in 1 min, 4 bolt counts in 30 sec, 2 bolt counts in 15 seconds.

running the "count" option is not feasable for 15 seconds due to every thing else that has to be done by the software and this RPM will be varying plus Picaxe only works with whole numbers.

So I guess the question I have is how do I get a reliable and accurate RPM range of 0 to 300 out of 8 "counts" in the shortest time possable.

I am not a mathamatition and any help would be greeeeaaaaatly appreaciated

Buntay
 

srnet

Senior Member
Sorry, I have read that post a few times, its not at all clear to me what you are trying to do.

prox - whats a prox ?
hold a 200rpm - eh - with what ?
bolts - whats a bolt ?

Any chance we could also have a view of the code ?
 

buntay

Senior Member
Prox= proximity sensor that is counting the bolts on a flywheel that needs to hold 200 rpms under a given load. Think of a variable speed drill turning a flywheel. If you put a brake on the flywheel it will slow down unless you add more power to the drill. That is just an example of what i am trying to do..... hold a certain revolution per minute by applying or removing power on a load......a crude cruise control. I hope that helps and no it has nothing do do with an automobile. It is proprietary software for a proprietary project so i would rather not divulge too much info to it actual application
 

hippy

Technical Support
Staff member
Instead of thinking of it in terms of how many revolutions per minute, think of it in terms of time of each revolution.

T seconds = 60 / rpm
 

hippy

Technical Support
Staff member
Yes PULSIN will get you time between bolts.

Because you aren't interested in the actual RPM, just need to keep it at a target RPM, you don't even need any maths. You can work out what the time between bolts should be, then depending on if time read is too long, speed it up, if too short, slow it down. You'll likely want some hysteresis and/or damping in the final version but getting poof of concept code working should be fairly easy.
 

g6ejd

Senior Member
RPM COUNT PULSEIN
300 2400 42
275 2200 45
250 2000 50
225 1800 56
200 1600 63
175 1400 71
150 1200 83
125 1000 100
100 800 125
75 600 167
50 400 250
25 200 500
0 0 0

You'd get better results with a count, I've assumed a 4MHz PICAXE or 10uS per unit.
 

hippy

Technical Support
Staff member
RPM COUNT PULSEIN
300 2400 42
Are you sure with the PULSIN ? I make it ...

300 RPM / 60 = 5 RPS = 0.2 seconds per revolution

0.2/8 = 0.025 seconds between bolts

0.025s = 25ms = 25000us = 2500 result at 4MHz / 10us

For 60 RPM, 1s per rev, 0.125s between bolts = 12500 result
 

g6ejd

Senior Member
RPM Count Pulsein
300 40 2500
275 37 2727
250 33 3000
225 30 3333
200 27 3750
175 23 4286
150 20 5000
125 17 6000
100 13 7500
75 10 10000
50 7 15000
25 3 30000
12 1 62500

Thanks Hippy, I must slow my clock down to get less missed brain cycles ... :)

COUNT for 1 Sec. is no good, thanks for pointing that out. Extending that to 10-secs. whilst inside the budget, would likely take too long to complete within the 17-secs budget.
 

boriz

Senior Member
10 seconds is worse. The point is that to get the quickest update, you measure the time interval, not the count. Seconds per bolt instead of bolts per second.

@200 RPM, a bolt passes the sensor every 37.5mS.

PULSIN should work.
 

boriz

Senior Member
Specifically...

At default 4MHz, 10uS per unit, 37.5mS = 3750.

So a PULSIN result of <3750 means too fast. >3750 means too slow.

Actual control will require some finesse though. It's a feedback system and simple too high / too low might result in throttle oscillation.

The gold standard solution is a very complicated PID algorithm, but depending on the behavior of the machine, something much simpler might suffice.
 

buntay

Senior Member
I understand how to make it work with pulsin and yes i can make it work but thats not the only issue.
The device is in a remote location and I access it via the internet and knowing the actual rpm is required to diagnose if there is a problem with the device. Its kinda like industial automation meaning 10% function and 90% safety.

Now i know I can do this the long way by buying a rpm meter and do my counts with a verified rpm and count time and cycle it with a bunch of "if w1= X then w2 = y....serout w2" but then I end up with alot of used program space and would like to reserve that space for future software upgrades. where as there has to be a formula to get me within a rpm or 2.

I havent played with "tables" yet....could this be an option? or am I still useing program space and slowing down the over all prosses.
 

SAborn

Senior Member
Now i know I can do this the long way by buying a rpm meter and do my counts with a verified rpm and count time and cycle it with a bunch of "if w1= X then w2 = y....serout w2" but then I end up with alot of used program space and would like to reserve that space for future software upgrades. where as there has to be a formula to get me within a rpm or 2.
Im not sure where the problem is or what you really want to do, the information about the project is being drip feed to us making a clear picture very difficult to understand.

For starters lets see if we can get some basic understanding of the full project without giving too much away.

What picaxe chip is used??

How will the data be sent to the internet, and what data will be sent via the internet.

Is the monitored RPM actually used to control the speed of the device or is it just for visual display.


I dont see where the problem of program space is a concern unless there is a lot you are not telling us, as to take a pulsin reading and convert it to a digital RPM value should only be a few lines of code.

The same sort of method to what you asked in your original post, is what i use to read wind speed from an anemometer and RPM from wind turbines, both use pulsin to read the speed, in some cases the speed is displayed on a LCD and other cases its sent to a computer for data logging.

Without knowing what or how the data will be used in your case its hard to make suggestions, but for my purposes when the data is logged, we take the raw pulsin count values and send that to the PC, and use the PC to do the calibration and all the number crunching, due to the fact there is no math limitation with a PC and no speed restrictions.
 

hippy

Technical Support
Staff member
there has to be a formula to get me within a rpm or 2.
Absolutely and from post #10 you can see how the value read by PULSIN was determined as to what it should be for a specific RPM ...

300 RPM / 60 = 5 RPS = 0.2 seconds per revolution
0.2 / 8 = 0.025 seconds between bolts
0.025s = 25ms = 25000us = 2500 result at 4MHz / 10us

You simply reverse that, if you get a reading of 2500 then ...

2500 = 25000us = 25ms = 0.025 secs per bolt
0.025 * 8 = 0.2 secs per revolution
1 / 0.2 = 5 RPS
5 RPS * 60 = 300 RPM

So the maths is ...

RPM = 60 / ( 8 * (PULSIN/100000) )

RPM = ( 60 * 100000 / 8 ) / PULSIN

RPM = 750000 / PULSIN

That's not possible to calculate using the provided PICAXE maths commands because it exceeds 16-bits but you can divide top and bottom by the same value ...

RPM = (750000/K) / (PULSIN/K)

And for K = 12 ...

RPM = 62500 / ( PULSIN / 12 )

So ...

PulsIn PIN, 1, w0
w1 = w0 / 12
w2 = 62500 / w1
SerTxd( "PULSIN=",#w0, 9 , "RPM=",#w2, CR,LF )

You will also find previous discussion on converting a PULSIN value to an RPM on the forum so a search ( top right of page ) is probably in order.
 

buntay

Senior Member
Thanks Hippy,

That was what I was looking for....not using counts is fine but the math is explained to work with pulsin.
Getting the answer is easy, but why the answer is? .........way better :D
 
Top