When talking about simple DC Motors in Microcontroller based system, there are only three tasks we can do: rotate the motor in forward direction, rotate the motor in reverse direction and control the speed of rotation. In this project, we will interface a simple DC Motor with ARM7 based MCU i.e. LPC2148. Here, we will simply change the direction of the rotation of the motor using a Motor Driver IC (L293D). For controlling the speed of rotation of the DC Motor, we will see another project as it involves ADC and PWM concepts. The aim of this project is to control a simple DC Motor with ARM7 LPC2148 with the help of L293D IC.

Circuit Diagram

Components Required

Some LPC2148 Development Boards (like the one used in this project) contains on – board, Motor Driver IC. In that case, all you need to do is connect the motor to the appropriate terminals and provide necessary power supply (separate power supplies for the board and motor driver IC so that we do not over load the power supply). If you are using a stand – alone board (with crystal and USB – to – UART IC), then you might need the following components.

ARM7 LPC2148 based Stand – alone board or ARM7 LPC2148 Development Board L293D Motor Driver IC 12 V DC Motor Push button Power Supply (separate for Motor Driver IC and MCU board) Connecting wires USB – to – Mini USB cable

Circuit Design

The design of the circuit is very simple. We need to connect the L293D Motor Driver IC and push buttons to the MCU board. First is the Motor Driver IC. The L293D Motor Driver IC has a dual H bridge configuration. Hence, it can control two motors simultaneously. But for the demonstration of the project, we will control only a single motor. L293D is available in a 16 – pin Dual in – line package (DIP) form. Out of the 16 pins, pins 4, 5, 12 and 13 are ground pins. All these pins are connected to ground and optionally a heat sink can also be connected. Pins 16 and 8 are power supply pins for the internal logic and drivers respectively. They are connected to 5V and 12V supply. Note: The power supply to the Motor Driver IC must be a different one than the power supply to the MCU board. Pin 1 is the channel 1 and 2 enable pin. It must be connected to 5V. Pins 2 and 7 are the driver inputs for the motor 1. They are connected to P1.18 and P1.19 of the LPC2148 MCU respectively. Pins 3 and 6 of the L293D IC are driver outputs and the motor is connected to these pins. Since we need to control the direction of the motor, we are going to use a push button to decide the direction. A push button is connected to P0.16 of the MCU. Rest of the connections like Crystal, USB – to – UART, etc. will be already made on the development board or stand – alone board. With this, the design of the circuit is complete. Note: The development board used in this project already has all the required components like motor diver, push buttons etc. on it. Hence, there is no need for any extra connections. All we need to do is to connect the motor to the driver output pins of the motor driver IC.

Working of the Project

The aim of this project is to demonstrate the DC Motor control using ARM7 LPC2148 MCU. Since motors draw a significant amount of current, we need a separate IC called Motor Driver IC like L293D for example. The working of the project is explained here. This is a simple project which helps us in controlling the direction of rotation of the motor using LPC2148. When the system is powered on, the status of the button is read by the MCU. As per the program, when the button is not pressed, the motor rotates in forward direction. Whenever the button is pressed, a change in state at the button pin is detected by the MCU and the motor rotates in reverse directions. The project is better understood by analyzing the program which is explained in the next section.

CODE

Understanding the Program

The basic components of the program include PLL for setting up system and peripheral clock and GPIO pins for interfacing with motor and button. First, we will see how to initialize the pins to operate in GPIO mode. By default, all the pins are configured to work as GPIO pins. Hence, we need not do anything specifically. In case we want to explicitly configure the pins as GPIO, then the following commands must be used. The GPIO Tutorial will give more information about the pins. PINSEL0 = 0x00000000; // Making all the pins as GPIO PINSEL1 = 0x00000000; PINSEL2 = 0x00000000; The next module we need to configure is the PLL. PLL Module in LPC2148 MCU is used to set the system clock and peripheral clock as per the user or programmer wishes. The maximum clock frequency for LPC2148 is 60 MHz. By using the following set of instructions, we can set the system clock i.e. CCLK and peripheral clock i.e. PCLK at 60 MHz respectively. More information about the PLL module is explained in the ARM PLL tutorial. PLL0CON = 0x01; // PLL0 module is enabled PLL0CFG = 0x24; // Multiplier and Divider values of the PLL are set PLL0FEED = 0xAA; // Feed sequence for locking the PLL0 at 60 MHz PLL0FEED = 0x55; while (! (PLL0STAT & 0x00000400)); // Waiting for Lock status of the PLL PLL0CON = 0x03; // PLL0 is enabled again and connected PLL0FEED = 0xAA; // Feed sequence for setting the PLL0 as CCLK PLL0FEED = 0x55; VPBDIV = 0x01; // PCLK is set same as CCLK Once the CCLK and PCLK are running at 60 MHz, the final part of the program is to read the status of the Button. After reading the status of the button, we can rotate the motor in either forward direction or reverse direction. Any help would be appreciated. Thank You Comment * Name * Email * Website

Δ

DC Motor Control using ARM7 LPC2148 - 41DC Motor Control using ARM7 LPC2148 - 76DC Motor Control using ARM7 LPC2148 - 79DC Motor Control using ARM7 LPC2148 - 61DC Motor Control using ARM7 LPC2148 - 77DC Motor Control using ARM7 LPC2148 - 34DC Motor Control using ARM7 LPC2148 - 51DC Motor Control using ARM7 LPC2148 - 2DC Motor Control using ARM7 LPC2148 - 20DC Motor Control using ARM7 LPC2148 - 2DC Motor Control using ARM7 LPC2148 - 62DC Motor Control using ARM7 LPC2148 - 89