I am playing with variable speed control for a dc motor. My idea is to pwm the enable pin of the LD293 chip. I monitored the pwm 2 pin with a scope and an excellent pulse is displayed showing the mark / space of the various steps.
However, trying to reduce the coding with a for - next loop I met some very odd results
Using this;_
results are good. Changing the gosub routine to this :-
doesn't work.
Am I doing somethin wrong, or is there perhaps a tie-up between pwm timing and loop stepping.
The picture shows the sertxd information
However, trying to reduce the coding with a for - next loop I met some very odd results
Using this;_
Code:
init:
pwmout 2,249,50 ‘ set pwm duty
main:
low 0:low 1
pause 1000
low 0:high 1
gosub speed
low 1: high 0
gosub speed
pause 2000
goto main
speed:
pwmduty 2,200 ‘ set pwm duty
pause 1000 ‘ pause 1 s
pwmduty 2,400 ‘ set pwm duty
pause 1000 ‘ pause 1
pwmduty 2,600 ‘ set pwm duty
pause 1000
pwmduty 2,800 ‘ set pwm duty
pause 1000 ‘ pause 1 s
pwmduty 2,1000 ‘ set pwm duty
pause 1000 ‘ pause 1 s
return
Code:
loopy:
for b0 = 200 to 1000 step 100
sertxd (#b0,cr,lf)
pwmduty 2,b0
pause 1000
next b0
goto loopy
Am I doing somethin wrong, or is there perhaps a tie-up between pwm timing and loop stepping.
The picture shows the sertxd information
Attachments
-
23.1 KB Views: 10