PWM and 18X

tommo_NZ

New Member
I have a problem getting a 'pwmout' command to work on an 18x Picaxe chip.
e.g. "pwmout 3 , 99, 200"
It only works when followed by, and for the length of a pause command.
I understood it should work continuously in the background until a command
such as "pwmout 3,off" is issued.
I see BeanieBot remarked (see thread entitled 'Help building rc speed controller with picaxe 18x') that the pwm output pin on an 18x chip is output 1, but I have checked the manual and even the editor won't let you set it to any other than output 3.
Am I missing the point here?
tommo_nz
 

eclectic

Moderator
Tommo
try these two programs please

Code:
#rem
;prog 1
#picaxe 18x

pwmout 3,99,200
pause 2000

; then it switches off

#endrem


;Prog 2

#picaxe 18x

pwmout 3,99,200

do
loop
e
 

tommo_NZ

New Member
Thanks Eclectic,
Yes, first example motor runs for two secs and then stops,
2nd example motor keeps running.
So as long as there is some code running the pwm output continues running in the background until stopped with an 'off' command or program execution stops.
Thank you
 

hippy

Technical Support
Staff member
There's always a hidden END command at the end of every program so if the program 'falls off the end' of source code it will execute this END and everything stops. Using the DO:LOOP or using the STOP command prevents the program reaching the END.
 

MikeM100

Member
PWM

Pity the manual doesn't explain this 'feature' of the PWM ! Just started to use PicAxes and I came across this very problem which perplexed me until I deduced what was happening.
 

BeanieBots

Moderator
It might be a little obscure but it is in the manual on page 141 item 5.
"5) pwmout stops during nap, sleep, or after an end command"
 

tommo_NZ

New Member
Yes, I knew as soon as I posted that I should have gone back to the manual, but it is so big (comprehensive) I guess I took the easy way out.

nbw, thanks for the welcome.
 
Top