Gramps
Senior Member
Almost got this working correctly but, PWM will not stop when using a pwmduty C.1,0 command.
The manual says:
Function:
Generate a continuous pwm output using the microcontroller’s internal pwm
module. also see the HPWM command, which can produce the equivalent of
pwmout on different output pins.
Information:
This command is different to most other BASIC commands in that the pwmout
runs continuously (in the background) until another pwmout command is sent.
Therefore it can be used, for instance, to continuously drive a motor at varying
speeds. To stop pwmout issue a ‘pwmout pin, off’ (=pwmout pin,0,0) command.
The PWM period = (period + 1) x 4 x resonator speed
(resonator speed for 4MHz = 1/4000000)
The PWM duty cycle = (duty) x resonator speed
To stop pwmout issue a ‘pwmout pin, off’ (=pwmout pin,0,0) command.
BUT
Instead of off we get very low speed "knock".
Appreciate a hand here,
thanks ,Gramps
The manual says:
Function:
Generate a continuous pwm output using the microcontroller’s internal pwm
module. also see the HPWM command, which can produce the equivalent of
pwmout on different output pins.
Information:
This command is different to most other BASIC commands in that the pwmout
runs continuously (in the background) until another pwmout command is sent.
Therefore it can be used, for instance, to continuously drive a motor at varying
speeds. To stop pwmout issue a ‘pwmout pin, off’ (=pwmout pin,0,0) command.
The PWM period = (period + 1) x 4 x resonator speed
(resonator speed for 4MHz = 1/4000000)
The PWM duty cycle = (duty) x resonator speed
To stop pwmout issue a ‘pwmout pin, off’ (=pwmout pin,0,0) command.
BUT
Instead of off we get very low speed "knock".
Appreciate a hand here,
thanks ,Gramps
Code:
;High and Low Limit pot for stearing arm
#picaxe 28X2
#no_data
#no_table
#terminal 9600
symbol speed_control = C.7
symbol val = w1 ; word (16-bit) user variable
symbol pwmPin = C.1
init:
pwmout C.1, 199, 719
main:
readadc C.7, val ; read 10-bit ADC into variable w1
SerTxd( "PWM output rate", #val, CR, LF ) ;display the rate
pause 100
If val < 40 then pwmduty C.1,0
endif
If val < 50 then pwmduty C.1, 239
endif
If val > 60 then pwmduty C.1, 719
endif
If val > 200 then pwmduty C.1, 239
endif
If val > 225 then pwmduty C.1,0
endi
goto main