start:
pause 1000
low 0 ; pin 6 goes low - enable
main:
readadc10 0, w5 ; read 10-bit resolution from pin 17 - ADC0
if w5>1023 or w5<0 then main
if w5<486 then moveL ; 512-5%
if w5>538 then moveH ; 512+5%
pwmout 3, 0, 0 ; switch off PWM - pin 9
high 2 ; Forward OFF
high 1 ; Reverse OFF
goto main
moveL:
w3 = 2 * w5
low 2 ; Forward ON - pin 8 LOW
pwmout 3, 255, w3 ; PWM ON ..
goto main
moveH:
w3 = 1023 - 2 * w5
low 1 ; Reverse ON - pin 7 LOW
pwmout 3, 255, w3 ; PWM ON ..
goto main
end
w3 = 1023 - 2 * w5
w5 = 2 * w5
w3 = 2047 - w5
start:
symbol DUTY = w0
symbol LIMIT = w1
pause 1000
DUTY = 512
low 0 ; pin 6 goes low - enable
main:
readadc10 0, w5 ; read 10-bit resolution from pin 17 - ADC0
readadc10 1, LIMIT ; read 10-bit resolution from pin 18 - ADC1
if w5>1023 or w5<0 then main
if w4>1023 or w4<0 then main
if w5<486 then moveL ; 512-5%
if w5>538 then moveH ; 512+5%
stopLH:
pwmout 3, 0, DUTY ; switch off PWM - pin 9
high 2 ; Forward OFF
high 1 ; Reverse OFF
goto main
moveL:
if LIMIT < 20 then stopLH ; low dead-band
DUTY = 2 * w5
low 2 ; Forward ON - pin 8 LOW
pwmout 3, 255, DUTY ; PWM ON ..
goto main
moveH:
if LIMIT > 1000 then stopLH ; high dead-band
w5 = 2 * w5
DUTY = 2047 - w5
low 1 ; Reverse ON - pin 7 LOW
pwmout 3, 255, DUTY ; PWM ON ..
goto main
end
PWMOut 3, 249, Duty
Poke $12, $05 ' provides a pre-scale of 1:4
PWMOut 3, 249, Duty
Poke $12, $06 ' provides a pre-scale of 1:16
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?