pwmduty in prog editor

kevrus

New Member
just a quick question as I cant find the answer with a search, should the PWMDUTY command work in the editor as i,m getting syntax error?


this is the command line, 28x1 device selected:

pwmduty 1,50,b0 'alter duty cycle on pwmout as set by b0 (throttle position)

thanks
 

eclectic

Moderator
Kev.

From manual 2

init:
pwmout 2,150,100 ‘ start pwm
main:
pwmout 2,150,150 ‘ set pwm duty
pause 1000 ‘ pause 1 s

'pwmduty 2,150,50 ‘ set pwm duty **** Doesn't pass.

pwmduty 2 , 50 'PASSES syntax test and simulates ***

pause 1000 ‘ pause 1 s
goto main ‘ loop back to start

It looks like a mini typo in the manual.
e
 
Last edited:

kevrus

New Member
Thanks Eclectic,
now why didn't I think of that, there's no need to specify the period again as that is already set when issueing the initial PWMOUT command and that doesn't change hence the use of PWMDUTY ...obvious now...
 

BCJKiwi

Senior Member
Yes, a typo in the example,
the command descriptioin is correctly given as;

Code:
pwmduty
  Syntax:
  PWMDUTY  pin,duty cycles
Which I can confirm works well.
 
Yes, a typo in the example,
the command descriptioin is correctly given as;

Code:
pwmduty
  Syntax:
  PWMDUTY  pin,duty cycles
Which I can confirm works well.
I am also having syntax errors, no matter if I write in capitals or lower case, it indicates that the comma is the problem!!!
I am also using the example shown on both pages 138 & 140, PWMOUT and PWMDUTY. The line with PWMOUT (with commas) is accepted.....So how can a comma be wrong on another line?
Thanks in advance for any help offered.
I am using a Laptop with XP Pro.
der fisherman
 

Technical

Technical Support
Staff member
The current manual, v6.8 page 138 is correct

init:
pwmout 2,150,100 ‘ start pwm
main:
pwmduty 2,150 ‘ set pwm duty
pause 1000 ‘ pause 1 s
pwmduty 2,50 ‘ set pwm duty
pause 1000 ‘ pause 1 s
goto main ‘ loop back to start

 

Technical

Technical Support
Staff member
Note that pwmduty is only supported on some PICAXE chips - see part 2 of the manual. For 08M etc. you have to use multiple pwmout commands.
 

tiscando

Senior Member
Is it OK on a 14M to: ?

Code:
#picaxe 14m
symbol CCPR1L = $13    ;on a PIC16F684
 
pause 100
readadc 4,b0             ;This will read 0~255 (full range)
w1=b0*2 and %11111100    ;0~510, keep 2 LSBs in CCP1CON 0
pwmout 2,127,w1 ;start PWM
 
 
main:
pause 50
readadc 4,b0       ;This will read 0~255 (full range)
b2=b0 /2            ;mask high duty bits
poke CCPR1L, b2      ;change duty
           ;not changing lower duty bits in CCP1CON yet.
sertxd (#b2,13,10)
goto main
to mimic PWMDUTY?
I'm going to try this anyway. EDIT: and it works! :)

It won't be damaging or glitchy, will it? (no problems so far)
 
Last edited:
Top