DC Motor

A DC motor is a type of electrical machine that uses Direct Current to rotate the shaft either clock wise or anti clock wise depending on the polarity applied to the motor.

A simple DC motor

The basic principal of operation for a DC motor is when current flows through the armature the electric field of the armature experiences a torque from the magnetic field caused by the rotor thus causes the armature to turn depending on the direction on which the current is flowing through the armature.

Since we know the current is proportional to the magnetic flux and torque, we can use this aspect of the motor ton control the speed of the motor, however the DSPIC30F4011 cannot supply enough current to even make the motors turn slightly, so a “driver chip” is needed, to produce the current levels to make the motor spin.  SN754410NE quad half H-bridge IC will be used.

The SN75441one job is basically take in a logic instruction (ON or OFF) into its input pins from the DSPIC and produce that same logic instruction on its output pins with greater current levels than to that which the DSPIC can produce to help create the desired torque for the DC motor.

First lets start with ON and OFF control of the DC motor to create some simple forwards and backward motion. This Circuit diagram was created with “fritzing“.


// Single Motor On Off Control example for dsPIC30F4011
// Written by Kevin Tighe
// Based on the code written from Ted Burke
// @batchloaf.wordpress.com or @roboted.wordpress.com

#define Second 30000000          // 1 second

//important stuff
#include <xc.h>
#include <libpic30.h>
#include <stdio.h>

//more important stuff
_FOSC(CSW_FSCM_OFF & FRC_PLL16); // Clock speed = 7.5MHz x 16, i.e. 30 MIPS
_FWDT(WDT_OFF);                  // Watchdog timer off
_FBORPOR(MCLR_DIS);              // Disable reset pin

int main(void)
// Make RD0 and RD2 digital outputs
TRISD = 0b1010;
_TRISE0 = 0;                     // make RE a D/IO
// Control motor
        // Forward for 4 seconds
        LATD = 0b0001;          // forwards
        _LATE0 = 1;
        __delay32(Second * 4);

        // Backwaard for 4 seconds
        LATD = 0b0100;         // backwards
        _LATE0 = 0;
        __delay32(Second * 4);



Here is a sample of the motor in operation, I realized after watching the video that I should have added a stop. Enjoy the video!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s