PWM frequency for motor control

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am working on project where dc motors are used.
Power will be regulated by PWM, but I have problems with setting the PWM frequency. If I choose 1.6 kHz, motor produces audible sound efects. So I tried to increase frequency, but at 8kHz the motor has so little power, that it doesn't start moving , only draws current.
Where is the problem (could it be caused by the time constant, since motor is LR circuit, or something else)?
Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thats it. The Current has to build up in the armature during the pwm on time. Curtis Golf cart controllers operate at 1.5KHz... Big L has a big time constant

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fox64 wrote:
If I choose 1.6 kHz, motor produces audible sound efects.

Yep! That will be quite noisy. I'm currently using an 18.000KHz PWM frequency in "Locked Anti-Phase" mode. It's so quiet, I can't hear it at all. My high frequency hearing must be going...

I have full bi-directional control from Zero RPM to 3,000 RPM. This is using 10 bit fast PWM, driving an LMD18201 full bridge (50 VDC @ 3 Ampere rating but, operating at 24VDC). The range is: 0% PWM = -3,000 RPM, 50% PWM = Zero RPM, 100% PWM = +3,000 RPM. It is currently controlled via an ADC input and a 10K Ohm, ten turn precision wire-wound potentieometer. It works, very, very smooth. The advantage of "Locked Anti-Phase" is, self breaking. The disadvantage is, 511 speed steps forward and 511 speed steps reverse; rather then the full 1024 speed steps forward or reverse. Not a big loss for my application. Another advantage is, direction is controlled directly with the PWM data and, not an additional control bit.

Fox64 wrote:
So I tried to increase frequency, but at 8kHz the motor has so little power, that it doesn't start moving , only draws current.

Then you can't be actully using PWM. By it's very nature, PWM turns on the drive signal, more or less, thru some pre-established range - 0% to 100%, 1mS to 2mS at a 50 Hz repitition rate, etc...

If you are trying to drive a brushed DC motor with the typical hobby servo frequencies - 1mS to 2mS, that isn't good as, the duty cycle is only a range of 5% to 10%. Typically not enough to move the motor very fast, or at all if loaded.

More details about your PWM type would be good.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the reply.

Actually I am using L293D H-bridge motor controller. I don't use Locked Anti-Phase mode.
MCU is ATMega8L and PWM mode is set as Phase correct PWM at frequency 1.8kHz, resolution 8-bits(so values <0,255> specify speed). Direction is changed by reversing polarity.
And yes, it looks like the motor is brushed dc motor.

My problem is, that when I for example set the PWM value 180 with frequency 1.8kHz motor is under load moving with some speed, but at higher freq. it moves slower. So I can't get at the frequency near 20kHz.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have a scope? Whats the output of the bridge look like into the motor? Into a resistor about the same R as the motor? (Should see a square wave, should go 0% on OCR-0 to 100% OCR=255). Can you measure the R and L of the motor?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Without schematic, code, etc..., I can't really be of more help as, I don't really know what you have set up.

With the AVR, I have always used FAST-PWM as, FAST-PWM is 10 bit and, that fits perfectly for use with the internal 10 bit AVR ADC. With that, I don't really have a lot of experience with Phase-Correct PWM; though, I don't think it is really any different then FAST-PWM, other then inverting the PWM drive signal and, possible use of multipul registers to set the limits ot the repitition rate of the PWM duty-cycle and frequency.

EDIT:
I'm attaching the code that I have been developing and a schematic. It might give you some alternative ideas. Incedentally, this is on the work bench and running, as I write this...

Attachment(s): 

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Inductance of the motor (in idle state) is 0.7mH, resistance 2.5ohm. (I didn't consider non-linearity.)
So time constant tau is 0.280ms.
And there is my idea...however I am not sure about it.

The equation for the current is (U/R)*(1-e^(-t/tau)) so current through motor rises exponentially.
PWM freq is 1.8kHz,period T=0.555ms.
If PWM is 50:50 (value 128) the "on time" in the one T is t=0.555/2=0.278ms. In this case, the current at the end of on time is (U/R)*0.629 amp. Higher PWM freq results in lower t, which implicates lower maximal current. Due to this I think time constant is base of the problem.

//*****************BEGIN INIT PWM***************

	//non-invert PWM mode, 8x prescaler, phase correct
	TCCR1B |= (1 << CS11); //8x prescaler
	TCCR1A |= ( (1<<COM1A1) | (1<<COM1B1) | (1<<WGM10) );

	//set pwm outputs low (zero speed)
	OCR1AH = 0x00;
	OCR1AL = 0x00;
	OCR1BH = 0x00;
	OCR1BL = 0x00;

//*****************END INIT PWM*****************

void setPWM(uint8_t speed)
{
	cli();
					
 	OCR1BH = 0x00;
	OCR1BL = speed;
		
	sei();
}

void mot2Reset(void)
{
	setPWM(180);								
	PORTC |= (1 << MOT2_CH2);				//set direction
	PORTC &= ~(1 << MOT2_CH1);			//set direction
	while( (PIND & (1<<MOT2_INDEX_SWITCH)) );  	//wait until index switch closed
	setPWM(0, 2);								//stop motor2
	
}



Schematics

Attachment(s): 

Last Edited: Fri. Aug 10, 2007 - 08:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This:

   //set pwm outputs low (zero speed) 
   OCR1AH = 0x00; 
   OCR1AL = 0x00; 
   OCR1BH = 0x00; 
   OCR1BL = 0x00; 

//*****************END INIT PWM***************** 

void setPWM(uint8_t speed) 
{ 
   cli(); 
   OCR1BH = 0x00; 
   OCR1BL = speed; 
   sei(); 
}

Can be changed to this:

   //set pwm outputs low (zero speed) 
   OCR1A = 0x00; 
   OCR1B = 0x00; 

//*****************END INIT PWM***************** 

void setPWM(uint8_t speed) 
{ 
   cli(); 
   OCR1B = speed; 
   sei(); 
}

Also, your version of:

void setPWM(uint8_t speed) 
{ 
   cli(); 
                
   OCR1BH = 0x00; 
   OCR1BL = speed; 
       
   sei(); 
}

has only one formal parameter specified, yet in the function call:

   setPWM(180, 2);

you are supplying two formal parameters.

What did you want to accomplish that you have neglected to include within the suspect function declaration?

You didn't bother to specify a specific controller type so, I didn't bother to looking into your timer initialization...

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

Last Edited: Fri. Aug 10, 2007 - 07:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

5 time constants for the current to get to max... 1.4ms.... 700Hz pwm freq?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

microcarl wrote:
This:

   //set pwm outputs low (zero speed) 
   OCR1AH = 0x00; 
   OCR1AL = 0x00; 
   OCR1BH = 0x00; 
   OCR1BL = 0x00; 

//*****************END INIT PWM***************** 

void setPWM(uint8_t speed) 
{ 
   cli(); 
   OCR1BH = 0x00; 
   OCR1BL = speed; 
   sei(); 
}

Can be changed to this:

   //set pwm outputs low (zero speed) 
   OCR1A = 0x00; 
   OCR1B = 0x00; 

//*****************END INIT PWM***************** 

void setPWM(uint8_t speed) 
{ 
   cli(); 
   OCR1B = speed; 
   sei(); 
}

Also, your version of:

void setPWM(uint8_t speed) 
{ 
   cli(); 
                
   OCR1BH = 0x00; 
   OCR1BL = speed; 
       
   sei(); 
}

has only one formal parameter specified, yet in the function call:

   setPWM(180, 2);

you are supplying two formal parameters.

What did you want to accomplish that you have neglected to include within the suspect function declaration?

Oh, sorry. I had simplified function before posting in the forum. I have forgot to delete parameter. Originally there are two motors.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

L293 datasheet specifies a maximum of 5 kHz. Maybe all current being drawn is shoot-throught from the H-Bridge.

Felipe Maimon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will try a scope to see what is on the motor terminals.