Friday, October 25, 2013

Speed Control of DC Motor using PWM

Pulse-width modulation is an effective method for adjusting the speed and the amount of power delivered to an electrical load.

Components Required




  • ATmega32 microcontroller
  • AVR Programmer Board
  • Crystal
  • Capacitors
  • Motors
  • L293D IC
  • +5V supply
  • Battery equivalent to voltage rating of motor 
  • Breadboard
  • Connecting Wires

  • To know about the L293D motor controller go through the previous blog on Interfacing D.C. Motor with ATmega32 using L293D.
    http://rickruling.blogspot.in/2013/10/interfacing-dc-motor-with-atmega32.html

    Circuit Diagram


    Description

    • PC0 and PC3 are connected to Enable 1 and Enable 2 respectively.
    • PC1,PC2,PC4 and PC5 are connected to Input 1-4.
    • OUT1 and OUT2 are connected to the terminals of first motor and OUT3 and OUT4 are connected to the terminals of the second motor.
    • A crystal is connected to XTAL1 and XTAL2 pins to provide the clock pulse.
    • Reset is connected to +5V.

    Source Code

    /*The following code will make the motor to run at 50% duty cycle*/
    #include <avr/io.h>
    #include <util/delay.h>

    #define F_CPU 1000000UL

    int main()
     { 
    DDRC = 0xFF;                                       //All pins of PORT C as output 
    PORTC = 0x00;                                     //Initially all pins at low output
    PORTC|=(1<<PC1)|(1<<PC4);            //PORT C 1 and 4 as high
    PORTC&=~((1<<PC2)|(1<<PC5));     //PORT C 2 and 5 as low
      /*In order to make the motor to rotate in opposite direction interchange the terminals of the motors (PINC1 and PINC2 for motor 1 and PINC4 and PINC5 for motor 2)*/
       while (1)                                                 //Infinite Loop
       {
          /*ON TIME*/
      PORTC|=(1<<PC0)|(1<<PC3);
          _delay_us(5);
          /*OFF TIME*/
          PORTC&=~((1<<PC0)|(1<<PC3));
          _delay_us(5);
               
       }
       return 0;
    }


    duty cycle = (on_time)/(on_time+off_time)
    duty cycle = 5/10 = 0.5
    To increase the duty cycle increase the delay of on_time and to decrease the duty cycle increase the delay of off_time.

    Practical Limitations of Pulse Width Modulation Motor Control

    Pulse-width modulation is difficult below 25% for motors because they don’t gain the same rotational inertia in comparison to the static resistances of the grease, gearing, and gaps between commutators. A weird aspect of PWM on motors is that it can create audible whining. Basically, if you select a PWM frequency in a human-audible range, the mechanical device will likely oscillate audibly. Increasing the frequency above 20 kHz may silence the motor whining. But, some motors, transistors, or motor driver chips are unable to switch on and off that quickly.


    For more tutorial and information like the Facebook Page 

    Thank You for Reading

    No comments:

    Post a Comment