PWMOUT Headscratch

3buns

New Member
Hi, long time reader, first time poster.

I'm using a PICAXE08M as a soft start for a DC lamp, code below. I am having a curious problem at the end of the timing cycle, when the second ramp finishes the PWM output go low briefly, long enough to cause a definate dark flash. I have found if I limit the duty cycle value to 250 the program is faultless, this however doesn't give me my desired end value (70%).
The manual says that the duty cycle shouldn't be more than 4x the period, my desired value of 280 is not, so I cannot see what I am doing wrong.

Any tips in the right direction are gratefully recieved.
Many thanks, 3buns.

Code follows:

'softstart_lamp.bas
'Kurt Nunn - 30/12/2009
'Revision 1.0
'History:
'Pinout
' +ve +-v-+ gnd
' Serial In | | Serial Out
' N/C | | LED 'timeout'
' N/C +---+ PWMOUT

symbol quickstep = b0
symbol slowstep = b1

quickramp:
'Quick Ramp 5% to 10% over 2 seconds
for quickstep = 20 to 40
pwmout 2,99,quickstep
pause 50
next quickstep


slowramp:
'Slow Ramp from 11% to 70% over 120 seconds
for slowstep = 44 to 280
pwmout 2,99,slowstep
pause 500
next slowstep


last: high 1 'Light Timeout LED
pwmout 2,99,280
goto last

end
 
Last edited:

eclectic

Moderator
A byte value (b) can only have a value up to 255

See Manual 2, page 10


You need a Word value instead.

Try this please

Code:
#picaxe 08M

symbol quickstep = b0
symbol slowstep = W1 ;  changed from b1 **************

quickramp:
'Quick Ramp 5% to 10% over 2 seconds
for quickstep = 20 to 40
pwmout 2,99,quickstep
pause 50
next quickstep


slowramp:
'Slow Ramp from 11% to 70% over 120 seconds
for slowstep = 44 to 280
pwmout 2,99,slowstep
pause 500
next slowstep


last: high 1 'Light Timeout LED
pwmout 2,99,280
goto last

Welcome to the Forum

e
 

3buns

New Member
Hi eclectic, how could I have missed that one, to think I had a similar PIC related problem years ago with a byte vale rolling over from FF. Many thanks for pointing out the obvious!

Regards, 3buns.
 
Top