calculation revolution time
mikea
Posts: 283
in Propeller 1
I have built a pov clock setup. I'm not sure if the code i have will calculate the revolutions correctly because the light on pin 12 doesn't shut off.
CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 pub n |lapstart,lapfinish,lap dira[2..12]~~ 'leds dira[30]~ 'hall sensor lapfinish:=0 repeat waitpeq(%000000000000000000000000000000, |< 30, 0) 'Wait for Pin 30 to go low (hall sensor goes by magnet) lapfinish:=cnt 'mark finish time of one revolution lapstart:=cnt 'mark start time of next revolution lap:=(lapstart-lapfinish) 'calculate revolution time outa[12]~~ 'turn light on waitcnt(lap/2) 'lights on 1/2 lap outa[12]~ 'light is off
Comments
Andy
waitcnt(clkfreq/2+cnt) waits always half a second, I think this is not what you want.
Andy