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

  • Could you post the code file?
    Is this spin?
    Windows 10 Home:
    Propeller Tool 1.3.2, BASIC Stamp Editor 2.5.4, Javelin Stamp IDE x.x.x, Arduino IDE, PST
    Hardware:
    BASIC Stamp Board of Education, Propeller Board of Education, Propeller Project Board, Propeller Mini

    Me, a programmer in English class, asking for grammar help: “What is the syntax for this statement?”
Sign In or Register to comment.