View previous topic :: View next topic |
Author |
Message |
Gerhard
Joined: 30 Aug 2007 Posts: 144 Location: South Africa
|
c-code for pwm that ramps up with time(soft starter) |
Posted: Sun Sep 02, 2007 5:12 pm |
|
|
Hi
I am looking for some sample program to start a dc motor on a single output that will start the motor very slowly and then speed it up until full speed. Any ramp time is fine. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Mon Sep 03, 2007 12:47 pm |
|
|
Interesting question, anybody has a idee? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 03, 2007 1:08 pm |
|
|
The reason no one answered (I think) is because it's so simple.
1. Setup for PWM. Use a variable to hold the duty cycle, and initially
set it to 0. Call the set_pwm1_duty() function with this variable
as the parameter, to set the duty to 0 at the start.
2. Create a for() loop. Setup the count in the for() loop so it has
the number of steps that you want it to take, before it gets up to
full speed.
3. Inside the for loop, put a set_pwm1_duty() statement, with the
duty cycle variable as the parameter. Then put a delay_ms()
statement after that, with the amount of time that you want it
to wait for each step of the "ramp up" period.
4. Put a continuous loop at the end of the program with a while(1);
statement (with nothing in it).
Then run it. |
|
![](templates/subSilver/images/spacer.gif) |
Gerhard
Joined: 30 Aug 2007 Posts: 144 Location: South Africa
|
|
Posted: Mon Sep 03, 2007 1:16 pm |
|
|
THANKS PCM
I KNOW SOMETIMES EASY THINGS LIKE THAT MIGHT FRUSTRATE YOU PRO'S BUT THIS IS A NEW FIELD FOR ME SO EVEN KNOWING ABOUT THE PWM FUNCTION WOULD HAVE BEEN A BONUS FOR ME.
THANKA |
|
![](templates/subSilver/images/spacer.gif) |
icesynth
Joined: 03 Sep 2007 Posts: 32 Location: Edmonton, Alberta
|
|
Posted: Mon Sep 03, 2007 5:01 pm |
|
|
Give us a couple days to answer, waiting one day is a fairly short time in a forum. BTW, I think you forgot caps lock on
How high of a current are you running into the DC motor? I agree that using the built in PWM functions are good, but have you thought about current feedback as well?
I am using a CSLA2CD ( Digikey 480-1994-ND ) hall effect current sensor for one of my DC compressor motor drivers. The motor runs at about 10A, 48VDC, and I have the main supply wire for the motor looped twice through the ferrite of the current sensor for better resolution, and the output of the sensor going into the PIC ADC Input.
On initial startup, the PWM is set to off, and for my application, I let the duty cycle increase until an average current of about 14A is reached, and as the motor speeds up, the current will go down, so the duty cycle increases until the current is below the 14A set point, where the duty cycle increases until it is at maximum ( always on ) and the compressor runs normally.
This is mainly used because the power source can't handle a huge rush of current. It also works because the compressor never starts under load.
But for PWM information, look at /examples/EX_PWM.C in your CCS directory for examples of using PWM.
Just ideas...
--Chris Burchett-- |
|
![](templates/subSilver/images/spacer.gif) |
|