Code to control output On and Off pulse times with pots

Visser

Active member
Thank you for the info
I will remove the zener. It was there for protection if pot goes to zero
I will try the voltage divider with a 2k2 in series with a 2k pot. That will ensure I never get more than 5V on the adc input if input voltage goes to 16V which will never happen
And then I can fine tune
There was a dry joint on the board on the pic supply. I also replaced the igbt with a big fet. FDA032N08 . The heatsink runs cold while the motor gets hot. I wanted to use an 18V isolated supply chip and mosfet driver but that doesn't seems to be necessary. Driving the fet straight from 5V works good

 

Attachments

Last edited:

Visser

Active member
Hi
I need to get pwm out when an input pin goes high and vice versa on an 8M
I have this code but don't know how to simulate it.
Will it work ?


#Picaxe 08M
SYMBOL SENSEPIN = PIN1
MAIN:
DO
LOOP UNTIL SENSEPIN = 1
DO
pwmout 2, 49, 99 ; 20000Hz at 50% @ 4MHz
LOOP UNTIL SENSEPIN = 0
GOTO MAIN
 
Last edited:

AllyCat

Senior Member
Hi,

PWMOUT is basically a Hardware function, but the Simulator is primarily for Software emulation. All the simulator does is to mark the PWM output pin in a Green colour, maybe with a "square wave" symbol inside.

You don't need to put the PWMOUT instruction inside a loop. First execution of the command starts the PWM output and then you can stop the output with a PWMOUT pin , OFF , or re-issue the command with a Duty Cycle value of 0 (zero) or 200 (or greater) depending how you want the PWM to be disabled.
Code:
#Picaxe 08M
SYMBOL SENSEPIN = PIN1
MAIN:
DO  :  LOOP UNTIL SENSEPIN = 1
   pwmout 2, 49, 100             ; 20000Hz at 50% @ 4MHz
DO  :  LOOP UNTIL SENSEPIN = 0
   pwmout 2 , OFF
GOTO MAIN
Cheers, Alan.
 
Top