Picaxe Encoder wheel timing
June 5, 2010
I am using the code below to monitor 2 encoder wheels connected to (pin4 left motor QRD1114 & pin3 right motor QRD1114) on my latest 28x1 picaxe project . It works fine .
My question is :- how can i calculate how long the code takes to execute?
b5=pin4 b6=pin3 check the encoder pins
if b5 != b2 then inc b1 b2 = b5 endif b1 is my incrementing encoder variable off left motor
if b6 != b4 then inc b3 b4 = b6 endif b3 is my incrementing encoder variable off right motor
(on the arduino there is a millis() command which can be used to give a rough guide to code execution times)
I ask this because if the encoder wheel is faster than the code (complete code loop) then i will be missing pulses, i dont want to miss my "pulses"
I started off by using setint (interrupt) command, however that led me up the garden path, so now i am stuck with monitoring the pins for any change of state.
EDIT:- The Video below is a taken with my highspeed camera (400 frames/sec) - you can see i have marked a black arrow on the wheel (opposite side has the encoder markings) . The black arrow stays pretty constant pointing at the motor pinion.