PWM for DC motors

Thread Starter

Dritech

Joined Sep 21, 2011
907
Hi all,

I want to control 2 DC motors (not at the same time) using the PIC18f PWM module. The two motors are:

http://www.gimsonrobotics.co.uk/GLA-S_linear_actuator.html

http://www.ebay.com/itm/GW31ZY-12V-...aterpillar-drive-Stepping-Motor-/400569511394

I decided to use a PWM frequency of 20KHz. This way I will eliminating any jerks and at the same time eliminating any humming noise.

Is this a good choice? Also, I read that the higher the frequency gets, the lower the torque will be. Is this true?

Any help will be appreciated.

Thanks in advance.
 

MaxHeadRoom

Joined Jul 18, 2013
30,654
The second motor appears to be a stepper motor?
IMO, you don't need to go as high as 20khz to avoid any switching noise?
Max.
 

tshuck

Joined Oct 18, 2012
3,534
The second motor appears to be a stepper motor?
The listing does say that, but the picture only shows 2 wires...I've learned that most people on Ebay don't know what they are talking about when they write their item descriptions. Dritech, how many wires have we got on the back?
IMO, you don't need to go as high as 20khz to avoid any switching noise?
Max.
Most people can't hear anywhere near that high frequency, but it is a safe bet that no one can hear above it.

More important are the characteristics of your motor drivers.
 

Thread Starter

Dritech

Joined Sep 21, 2011
907
Hi,

Thanks for the replies. No the second motor is a normal brushed DC motor. I don't know why it is labeled as stepping motor.

So is there any drawback in increasing the PWM at 20KHz? Will I see a decrease in torque?

As an H-bridge drive I am going to use 2pcs BTN7970. The datasheet of this driver states that the maximum PWM capability is up to 25KHz, so that is suppose to work fine with a 20KHz PWM.
 
Last edited:

Thread Starter

Dritech

Joined Sep 21, 2011
907
Also, what is the Prescaler in PWM? Apparently with the PIC18f one can set the Prescaler to either 1, 4 or 16, but I am not sure what is its function.
 

w2aew

Joined Jan 3, 2012
219
The biggest downside of using higher frequencies for PWM control is that the switching looses will be higher, thus wasting power that would normally be used to drive the motor. It's probably best to experiment with the actual motors in the application. Choose a frequency that is high enough to minimize audible noise. There's generally no benefit going any higher in frequency than that.
 

MaxHeadRoom

Joined Jul 18, 2013
30,654
Also, what is the Prescaler in PWM? Apparently with the PIC18f one can set the Prescaler to either 1, 4 or 16, but I am not sure what is its function.
The prescaler works as it does with any of the timers, and scales the PWM period of the clock used.
The 18F manual for your Pic will detail it.
Max.
 

Thread Starter

Dritech

Joined Sep 21, 2011
907
The prescaler works as it does with any of the timers, and scales the PWM period of the clock used.
The 18F manual for your Pic will detail it.
Max.

Hi,

I did read the PIC18f datasheet but still I cannot fully understand the use for a prescaler. Lets assume that I use a prescaler of 1 and then change it to 16. What difference will I see?
 

MaxHeadRoom

Joined Jul 18, 2013
30,654
A prescaler of 1 uses the actual freq of the osc or timer used to produce the PWM freq, a post scaler of 16 will divide that frequency by 16.
If you look up the PWM section of the manual, it should show the exact formula to calculate the PWM period, the formula includes the prescale value.
Max.
 

Thread Starter

Dritech

Joined Sep 21, 2011
907
Thanks MaxHeadRoom.

I managed to configure all settings, except bits CCP1M3:CCP1M0 of register CCP1CON. I am using the PWM in a single output configuration so I cannot really understand how to set the pins as active-low or active-high. What difference does this make?

1100 = PWM mode: P1A, P1C active-high; P1B, P1D active-high
1101 = PWM mode: P1A, P1C active-high; P1B, P1D active-low
1110 = PWM mode: P1A, P1C active-low; P1B, P1D active-high
1111 = PWM mode: P1A, P1C active-low; P1B, P1D active-low
 

MaxHeadRoom

Joined Jul 18, 2013
30,654
I have never had to configure those registers, but the way I interpret it is that the four configurable PWM outputs can be active high or low, low when signal content=0 or high when signal content=0.
IOW the ability to simply invert the normal PWM signal.
This is the way I read it.
Max.
 
Top