buntay
Senior Member
Hello again friends,
I am about losing my mind on this one cause the code should work but virtually none of it is correct.
What am I missing?
Heres what I am trying to do,
I am working with RPM's using the "count" method, I have a proximity sensor connected to a 12v coil of a relay with a 10k resistor keeping the input pin low till pulled high by the 5v going through the switch on relay. all voltages have been checked and re-checked and then checked again
I would like to take 4 rpm readings and give me the average of those 4 readings.
here is the code and resulting data. chip is a 20x2
What am I missing?
Thanks for any input
Buntay
I am about losing my mind on this one cause the code should work but virtually none of it is correct.
What am I missing?
Heres what I am trying to do,
I am working with RPM's using the "count" method, I have a proximity sensor connected to a 12v coil of a relay with a 10k resistor keeping the input pin low till pulled high by the 5v going through the switch on relay. all voltages have been checked and re-checked and then checked again
I would like to take 4 rpm readings and give me the average of those 4 readings.
here is the code and resulting data. chip is a 20x2
Code:
'picaxe 20x2
setfreq m8
main:
w0=0 'start with a word 0 value of 0
for b0=1 to 4 'start a loop of 4
sertxd ("count of 4 ",#b0,cr,lf) 'tell me which count of 4 I am on
count b.6, 4700, w0 'count a switch and place in word 0
sertxd ("value ",#w0,cr,lf) 'give me the value of the count
w1= w0 + w0 'take word 0 and add it to the previous word 0
sertxd ("new value ",#w1,cr,lf) 'give value of word 1
next b0 'end of loop
w2 = w1/4 'once the loop is finished divide word 1 to give me average of the 4 counts
sertxd ("average " ,#w2,cr,lf) 'tell me the average and line feed
sertxd (cr,lf)
sertxd (cr,lf)
sertxd (cr,lf)
sertxd (cr,lf)
sertxd (cr,lf)
sertxd (cr,lf)
goto main
'THIS IS THE RESULTING TRANSMITTED DATA
'count of 4 1 'never changes from one
'value 233 '@ a little more than the 4 seconds value it should be around 12-16 (I can hear the relay ticks and in one second its about 3-4)
'new value 466 'is always double of the wrong rpm
'average 116 'the average of wrong rpm
What am I missing?
Thanks for any input
Buntay