pwmout for controling the motor

Alext123

New Member
Hello all,
I'm very new to pic progreaming and just purchased PICAXE VSM.
I want to build a circuit to run a 12 volts motor with external power 12 V supply.
However I want to provide 12 volts to the motor for 5 sec, then 6 volts for 10 sec and finally 4.5 volts for 20 sec and repeat the cycle again and again.

I'm thinking to use PWMOUT to change the voltage.
Am I in the right track?
Can some one help me as how the code should look like?

Thanks
Alex
 

cdngunner

Senior Member
Not to be a pain in the ass.....
I think a good place to start is to learn how to use the search function. I have not been here for very long myself, but this topic has almost been beaten to death around here. Do a search, lots of good stuff.

edited: What the heck was i on?:eek:
 
Last edited:

Alext123

New Member
Hello all,
I used VSM to design a PWM circuit to control the speed of motor.
Looks like it is working, but it seems that is not quit synchronized.
I'm using the following code to test it

MAIN:
pwm 2 ,255, 200
pause 2000
pwm 2, 128, 200
pause 2000
pwm 2, 64, 200
pause 2000
GOTO MIAN

Based on the above code. I'm staring with full speed for 1 sec, then pause 2 sec, reduce the speed to ½ and so on.

When I run the code in debug mode, I see when for example pwm 2 ,255, 200 get executed, the speed becomes lower RPM, and sometimes when
pwm 2, 64, 200 get executed the speed becomes higher RPM.
Any idea as what is going on?

by the way what should happen to the speed during the pause 2000? Should it stop or should it continue with whatever speed that it was running?
 

Attachments

Last edited:

premelec

Senior Member
PWM vs PWMOUT

do you mean to use PWMOUT as the title of this thread suggests? Your code shows PWM which is a different animal - [see Manual 2].
 

Alext123

New Member
well for now I'm using pwm. Based on my code and circuit, do you see anything wrong with it?
Why am i see a strange behavor?

Thanks
Alex
 

Andrew Cowan

Senior Member
The PWM command outputs short series of pulses - your code sends out 200 PWM pulses, then waits two seconds.

If you use the PWMout command instead, the motor will continue to run during the 2 second wait.

Andrew
 

eclectic

Moderator
@Alext

It might be a good idea to

1. Read Manual 2, page 158

2. Then use the Wizard in Programming Editor
PICAXE > wizards > pwmout

3. Keep the same Period and gradually reduce the Duty

A simple example:

Code:
Pwmout 2, 100,400  ; full
pause 2000

Pwmout 2, 100, 200 ; slower
pause 2000

Pwmout 2, 100 , 100 ; slower
Addition I'll leave it to others to explain Mosfets and Pwm

e
 
Last edited:
Top