28x1 and pwmduty

russbow

Senior Member
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;_
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
results are good. Changing the gosub routine to this :-

Code:
 loopy:
for b0 = 200 to 1000 step 100
sertxd (#b0,cr,lf)
pwmduty 2,b0
pause 1000
next b0

goto loopy
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
 

Attachments

inglewoodpete

Senior Member
Russ, A small tip for your code.

Low 0: Low 1

code be replaced with:

Low 0, 1

The result is exactly the same. The code just looks a little neater.

Peter
 

lbenson

Senior Member
A bug has been reported relative to "LOW #,#,#" and "HIGH #,#,#"--has it been repaired in the latest version of the program editor?
 
Top