Shop OBEX P1 Docs P2 Docs Learn Events
Main Loop Speed? — Parallax Forums

Main Loop Speed?

Hi Guys,

The three timers in the 'has_packet' part of the following code are true 'every time' because the loop does not run fast enough to decrement the timers back to zero on each pass. The timers just keep counting up. What am I missing here?




pub main

setup ' configure hardware & objects

repeat
if (rx_packet == true)
has_packet
oktimer.set(-OK_TIMING)

else
dropped_packet
etimer.set(-ERR_TIMING) ' blip red LED

update_error_led
update_rx_led


pub has_packet

if (tremote.millis => 30) ' receive remote packet every 30ms
rx_packet
tremote.adjust(-30)

if (tservos.millis => 20) ' update servo output every 20ms
process_servos
tservos.adjust(-20)

if (tanalog.millis => 5) ' read Encoder & compare position every 5ms
process_encoder
tanalog.adjust(-5)

badpackets := 0 ' clear bad packet counter


Comments

Sign In or Register to comment.