With my millisecond values are integers, I don't expect 100% accuracy. Using PBP, how do I get from say, 16mS to 62Hz ?
Scott
With my millisecond values are integers, I don't expect 100% accuracy. Using PBP, how do I get from say, 16mS to 62Hz ?
Scott
You can write a subroutine to determine the RPM from the z value. If to the nearest 100rpm is acceptable, this is the relevant data:
If you need help on how to write a subroutine to do this then let me know and i can help you out.Code:z rpm ------------------------- <10 out of limits 10 6000 11 5500 12 5000 13 4600 14 4300 15 4000 16 3800 17 3500 18 3300 19 3200 20 3000 21 2900 22 2700 23 2600 24 2500 25 2400 26 2300 27 2200 28-29 2100 30 2000 31-32 1900 33-34 1800 35-36 1700 37-38 1600 39-41 1500 42-44 1400 45-48 1300 49-52 1200 53-57 1100 58-63 1000 64-70 900 71-80 800 81-92 700 93-109 600 110-133 500 134-171 400 172-240 300 241-400 200 401-1200 100 >12000 out of limits
I had a few spare mins so i wrote up a subroutine that would work. Im sure its not the most elegant piece of code, but it will do what you want just fine.
It will take the z value and store a relavant value into rpm. The value in rpm will be in hundreds of rpms. So if you write the value of the variable rpm to your lcd, followed by "00" it will display in rpms.
If rpm=0 after the subroutine has run then the input was out of range.
Code:convert_to_rpm: IF z<10 THEN rpm=0 IF z=10 THEN rpm=60 IF z=11 THEN rpm=55 IF z=12 THEN rpm=50 IF z=13 THEN rpm=46 IF z=14 THEN rpm=43 IF z=15 THEN rpm=40 IF z=16 THEN rpm=38 IF z=17 THEN rpm=35 IF z=18 THEN rpm=33 IF z=19 THEN rpm=32 IF z=20 THEN rpm=30 IF z=21 THEN rpm=29 IF z=22 THEN rpm=27 IF z=23 THEN rpm=26 IF z=24 THEN rpm=25 IF z=25 THEN rpm=24 IF z=26 THEN rpm=23 IF z=27 THEN rpm=22 IF z>27 AND z<30 THEN rpm=21 IF z=30 THEN rpm=20 IF z>30 AND z<33 THEN rpm=19 IF z>32 AND z<35 THEN rpm=18 IF z>34 AND z<37 THEN rpm=17 IF z>36 AND z<39 THEN rpm=16 IF z>38 AND z<42 THEN rpm=15 IF z>41 AND z<45 THEN rpm=14 IF z>44 AND z<49 THEN rpm=13 IF z>48 AND z<53 THEN rpm=12 IF z>52 AND z<58 THEN rpm=11 IF z>57 AND z<64 THEN rpm=10 IF z>63 AND z<71 THEN rpm=9 IF z>70 AND z<81 THEN rpm=8 IF z>80 AND z<93 THEN rpm=7 IF z>92 AND z<110 THEN rpm=6 IF z>109 AND z<134 THEN rpm=5 IF z>133 AND z<172 THEN rpm=4 IF z>171 AND z<241 THEN rpm=3 IF z>240 AND z<401 THEN rpm=2 IF z>400 AND z<1201 THEN rpm=1 IF z>1200 then rpm=0 return
Thanks. A bunch of if-thens came to my mind as well. I just was not sure about it. I think I'll try it.
That would work, but that kind of division in PBP would take up a lot more processing time than the IF...THEN statements above.
I may not be understanding something here.
For the basic math, I would have said:
rpm=60000/z
where z is in milliseconds.
My question is: Why would doing that single division take longer than going through multiple IF...THEN statements (40-something of them in the example) until one is found where the condition is satisfied?That would work, but that kind of division in PBP would take up a lot more processing time than the IF...THEN statements above.
Thanks to whomever clarifies this for me!
Last edited by RussMartin; - 5th September 2007 at 06:38.
Russ
N0EVC, xWB6ONT, xWN6ONT
"Easy to use" is easy to say.
Thanks Andy.....kick, kick, kick...
And Russ...equally good insight. I'll kick myself once for you too.
Almost too obvious, I have been away from math for too long.
Kamikaze...I tried your solution and ran into an exceeded address 3fff, if I remember correctly. I got sidetracked and have not investigated that further yet.
Appreciate the input.
Scott
Bookmarks