RPM reading
I have looked at the Count instruction and if I wanted to mesure RPM would this work?
Hertz VAR· ·Word
RPM·· VAR·· Word
SCHMITT RB.0
Do
Count RB.0, 250, Hertz
RPM = Hertz * 240
Loop
Or should you sample the input longer say 1000 ms? Would it be accurate at 250 ms sample?
Post Edited (bennettdan) : 6/28/2007 12:05:12 AM GMT
Hertz VAR· ·Word
RPM·· VAR·· Word
SCHMITT RB.0
Do
Count RB.0, 250, Hertz
RPM = Hertz * 240
Loop
Or should you sample the input longer say 1000 ms? Would it be accurate at 250 ms sample?
Post Edited (bennettdan) : 6/28/2007 12:05:12 AM GMT
Comments
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
I am not sure if it really is any more accurate, but the resources required would be so small that I thought it was a better alternative. Although a slave SX that uses COUNT RB.0, 60_000, RPM would be the most accurate.
Another thought was an interrupt that would record every 10 ms (or less), for 10 ms and repeated·100 times to create an RPS figure (or any combo that gives you a total of 1000 ms)·to minimize the resources used.
Bill
So 6,000,000 / (time in 10 uSec units) = RPM
The math is going to be a little tricky, but will be the most accurate.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Pwidth1 VAR Word
Pwidth0 VAR Word
Temp VAR Word
RPM VAR Word
Do
PULSIN RA.0, 1, Pwidth1
PULSIN RA.0, 0, Pwidth0
Temp = Pwidth1 + Pwidth0
Temp = Temp * 1000
RPM = 6000 / Temp
Loop
Post Edited (bennettdan) : 6/28/2007 6:08:41 PM GMT
You cannot take 12000 times 1000 because that will overflow the word variable maximum value of 65535.
Even at 7000 RPMs the period will be 857 in PULSIN counts. And again you cannot take 857 times 1000.
You will need to do a 32 bit division to get RPMs.
I have some code to do 32 bit division, I'll have to see if I can find it.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
What if I drop some zeros from both the 1000 and 6000 and make them 100 and 600 or 10 and 60 the answers would be the same and·would not overflow the Word right?
·Do
PULSIN RA.0, 1, Pwidth1
PULSIN RA.0, 0, Pwidth0
Temp = Pwidth1 + Pwidth0
Temp = Temp *100
RPM = 600 / Temp
Loop
Post Edited (bennettdan) : 6/28/2007 9:48:30 PM GMT
12000 * 10 = 120,000 which is STILL greater than 65535.
Without doing anything fancy the best you could do is:
Do
· PULSIN RA.0, 1, Pwidth1
· PULSIN RA.0, 0, Pwidth0
· Temp = Pwidth1 + Pwidth0
· Temp = Temp / 100
· RPM = 60000 / Temp
Loop
This will give you 5Hz resolution at 500 RPM, but only 1000 hz resolution at 7000 RPM (pretty much unusable).
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
Post Edited (Bean (Hitt Consulting)) : 6/28/2007 11:17:07 PM GMT
Accurate to about 1 RPM @ 7000 RPM.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
It will take a month to sort out the code and understand it but I will give it try.
Let us know if it works for you.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
How did you come up with 12000 being 500RPM and 847 being 7000 RPM?
So 6,000,000 / 500 = 12,000 and 6,000,000 / 7000 = 857
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Having done the rpm count on my boat's engine.
I had to reinvent the sensor due to extremely high cost of the original from Volvo Penta, ( a sturdy magnetic working at 12V rougly 150US$)
I painted black half of the circumference of the fly wheel, the other half is painted white,
and an ir sensor detect the black (or the white as by personal preferences),
I've had help from DR. Tracy Allen for solving the equation necessary, and after several testing,
I've found that if the two halves of the fly wheel are similar enaugh in length, with the measurement of only one half,
the error in the readings was pretty the same than having the two readings.
I acclude the File I've done.
Hope this could be useful........even with the comments in italian language
Best Regards
Stefano
P.S. The program use an DS1603 RTC/elapsed time for taking count of the time the engine is on (maintenace purpose),
An MAX7219 for displaying the time/RPM in a five digits 7 segments LED display,
(with a little trick, the fourth digit is reversed to accomplish the thousand points that in italian notation is on the upper left)
It was developed for the BS2, but I think it could be easily translated for SX28/48 (may be even eliminating the MAX 7219?)
I tried to make the porting to sx but lack of time togheter with being the project already done, tested and made, (plus some lazyness from me).
I never accomplished this task.
Post Edited (ellizard) : 6/30/2007 8:31:31 AM GMT
If I want to use an If Then statement with the rpm word can I use decimal values to compare the rpm variable to. Like this ..
If rpm = 1500 then
High RB.2
Else
Low RB.2
EndIF
If I want to use binary I add a % sign in front of the # and if I use Hex then $ sign infront of the number I want to compare the rpm variable to..Right ?
Can I use any Hall Sensor with that code or does it require the Melexis Hall sensor from Parallax? I have a Ignition system test stand that I would like to test the rpm code, combined with code for dual Max6675's EGT's and an 8 bit LCD tonite.
Thanks
Bill
Post Edited (Capt. Quirk) : 7/1/2007 1:54:10 AM GMT
So on a 4 cylinder engine, reading one high and one low period will give you the time for half of a crank revolution, and most likely will take a full revolution to complete, Bean could chime in on this. Is the SX capable of catching the high and the low imediately following each other or will it need an extra transition to set up for the next capture?
Engines with individual coils per cylinder could go either way, or you could end up reading the time for 2 revolutions for each ignition signal, some motorcycles may fire 4 times per crank revolution but I believe the typical number to be 2.
RPM's is always dependant on engine and ignition design, distributor car engines have a 2:1 gearing on the distributor, crank·triggers dont, motorcycles and single cylinders being primarily crank triggered, and cars depend on the vintage.
None of this is set in stone, it just depends on what your working on, and some of this information may not be perfectly accurate because most of my experience is with motorcycles and older cars. GAF would be the expert in this area. Some day I'll find the spell checker in this thing, till then please excuse the typos.
<My current project is capturing RPM on 4 cylinders up to 15,000 RPM's, and how accurately and conistantly it can be done>
If you were interested in building your own ignition system? It·should be fairly easy to take·Terry's code example, to·set the dwell time and ignition timming per·RPM.
Actually I plan to use it in a few of the auto circuits but right now I am using this code and other examples to control a 4L60E electronic shift transmission so a person can put the modern 4 speed transmission into some older hot rods and other autos projects.
I have the PWM code working and I have the shift solenoids workd out now I plan to use the RPM data to setup shift charts.
ChrisP
I thought about the 2:1 gearing on the distribitor and I shoud be able to divide the Pulsin staement to get teh proper amount of pulses comming into the SX and Beans code should still be accurate. I will try to test it the first part of the week.
I have a Chevy truck that I am adding a little extra power to. I have a manual transmission in it at the moment and I perfer a automatic so I can have a remote start and easy of driving in town crusing around.
The chevy and Ford electronic shift transmissions dont really have that much going on inside they are actually very simple on two shift solenoids and three PWM pressure solenoids and then a set of gear indicator switches.
····················································································· David
Post Edited (dbj) : 7/5/2007 4:19:34 AM GMT