Hairy Animal
Member
I'm getting back into PicAxe programming having been away from it for over a year (so having to relearn much stuff again).
Working now on a throttle controller for our boat, I want to occasionally (every two or three seconds) send a variable representing the percentage of maximum throttle setting via SEROUT to an RF transmitter (NKM2401) without slowing down the main program loop to ensure that a change in the joystick position, which controls the motor speed, is rapidly monitored and passed through to the DAC to control the motor speed.
I found some very useful code which will undoubtedly do what I want in an existing thread from 2015 ('Time' Command question) but in experimenting with the 'time' variable myself, I found a strange anomaly which it would be nice to have an explanation for please?
Using the simple code below, everything works as I would expect, monitoring the time variable itself and the other variables, 'time' increments once a second. But if I comment out the PULSOUT line, 'time' only increments once every 5.5 seconds approximately.
Why?
Thanks, Charles Lyne
Working now on a throttle controller for our boat, I want to occasionally (every two or three seconds) send a variable representing the percentage of maximum throttle setting via SEROUT to an RF transmitter (NKM2401) without slowing down the main program loop to ensure that a change in the joystick position, which controls the motor speed, is rapidly monitored and passed through to the DAC to control the motor speed.
I found some very useful code which will undoubtedly do what I want in an existing thread from 2015 ('Time' Command question) but in experimenting with the 'time' variable myself, I found a strange anomaly which it would be nice to have an explanation for please?
Using the simple code below, everything works as I would expect, monitoring the time variable itself and the other variables, 'time' increments once a second. But if I comment out the PULSOUT line, 'time' only increments once every 5.5 seconds approximately.
Why?
Thanks, Charles Lyne
Code:
;
#picaxe 20M2
;
init:
symbol time_ex2 = w2 ; word variable for monitoring the time
symbol time_ex3 = w3 ; word variable for monitoring the time
symbol Stp_LED = B.6 ; Use a logical name for the o/p pin.
setfreq m4
;
main:
debug
time_ex2 = time ; allow the time to be seen by the debugger
LET time_ex3 = time_ex2 / 5 ;
PULSOUT Stp_LED,500 : PAUSE 1000
GOTO main
end