I am reading a tacho out line from an engine ECU with pulsin, scaling it, then displaying it on an LCD screen. I have had it working with the following code...
in the higher RPM, the resolution drops, so I figured if I was to change my calculations to be ... rpm = 3000000 / rpm ... then the resolution would increase.Code:PULSIN PORTD.6,1,rlow PULSIN PORTD.6,0,rhigh rpm = rhigh + rlow rpm = rpm / 50 rpm = 60000 / rpm if rpm = 65535 then rpm = 0 endif ... lcdout $fe,$ca,dec rpm,"rpm "
However when I make it ...
The result is roughly 32370rpmCode:PULSIN PORTD.6,1,rlow PULSIN PORTD.6,0,rhigh rpm = rhigh + rlow tbase = 50 * 60000 rpm = div32 rpm if rpm = 65535 then rpm = 0 endif
when the revs are increasing, the displayed rpm decreases, and visa-versa... but when the rpm is steady (at idle, or held steady at any RPM) the displayed rpm settles back to 32370
Is there something I am missing here? I am successfully using DIV32 many more times in my code for other functions.
Also I thought I might be overflowing the DIV32 integer (but according to my manual I am not) so I thought I would try....
This results in 0 being displayed all the time.Code:PULSIN PORTD.6,1,rlow PULSIN PORTD.6,0,rhigh rpm = (rhigh + rlow) / 10 tbase = 500 * 600 rpm = div32 rpm if rpm = 65535 then rpm = 0 endif
At idle, rlow, and rhigh (which are identical) read approximately 1400 each, which when I do my maths on paper, (either method I have shown) comes out to approximately 1071rpm which would be correct
Could somebody more intelligent or more observant than I please help me?
Also might add I'm using a 16F877A





Bookmarks