Skip to main content

Practical Projects for Engineering Students-9

Induction Motor Speed & Direction Controller
Controlling a motor with an Arduino is relatively easy. In addition to simply spinning the motor, you can control the position of the motor shaft if the motor has a rotary encoder.
Faraday's Law states that:
Any change in the magnetic environment of a coil of wire will cause a voltage (emf) to be “induced” in the coil.
This explains how generators are able to produce voltage. This is mechanical energy to electrical energy conversion. Motors operate in reverse of generators; they convert electrical energy to mechanical energy. In motors,  current is fed into the armature winding which creates a magnetic field that interacts with the magnetic field created by permanent magnets in the stator. The interaction between two magnetic fields causes the armature to rotate.


Circuit Diagram
There are many different types of motors, including:
  • Direct Current (DC) motors (the one that I'll be using in this tutorial).
  • Alternating Current (AC) motors.
  • Brushless DC (BLDC) motors.
  • Brushless AC (BLAC) motors.
A rotary encoder is a device that converts the angular position or motion of a shaft or an axle to an analog or digital code. There are two types of rotatory encoders:
  • Incremental encoders. An incremental rotary encoder outputs pulses only while a motor is rotating. To determine the shaft position using an incremental encoder, you must know the starting position and the use external circuitry to count the number of output pulses.
  • Absolute encoders. An absolute rotary encoder outputs a digital code corresponding to the rotation angle. There is no need to count pulses to know the position of the motor shaft. You need only read the digital output of the encoder.
In this project, we are using an incremental rotary encoder. The figure below shows a typical rotary encoder.



An H-Bridge is an electronic circuit that enables a microcontroller, such as an Arduino, to control the movement of a motor. A microcontroller cannot be connected directly to a DC motor because the microcontroller cannot supply the high current required by the motor. The H-bridge contains the high-current switches needed for motor control. These switches are controlled by signals from the Arduino.
An H-bridge allows a motor to be moved forwards or backwards. The direction is determined by the sequence of control signals from the Arduino.
Motor speed is determined by setting the duty cycle of the control signals. This type of speed control is called pulse-width modulation. The motor will run at full speed when the duty cycle is 100%. When the duty cycle is 0%, however, the motor will stop and will no longer move.
For this tutorial, we have designed and built an H-bridge that uses the following components:
  • TIP 142 and TIP 147 transistors
  • Diodes
  • Green Connectors
  • Optocouplers
A simplified diagram of the H-Bridge is shown:

A fabricated H-bridge module is used for this tutorial. You can find a lot of schematics for H-bridge circuits in the web, but if you don't want to build you own, you can use a L298 IC.

Equipment required

The following equipment was used for this experiment

  • Lipo Battery 11.1V 
  • Arduino ATmega 2560
  • H-Bridge (self-fabricated or IC L298) 
  • motor with encoder
  • jumpers (as required)
  • Green Connector (aka L-connectors)
  • 6 pin connector (for motor specifically)
  • Wheel (optional for visible motion of motor shaft)

Steps:

1.  Gather all parts required:


Motor


Close-up picture showing the motor encoder pins


Arduino Mega 2560

6-pin Connector for motor

Green Connector


Battery


H-Bridge



Jumpers


3-pin Connector for H-Bridge

Wheel (optional)

2.  Connect the jumper to the battery and then power up the H-bridge with the battery:


3. Connect the 3-pin connector to the H-Bridge module then connect the H-Bridge module to Arduino following this connection:
  • Arduino 13 --> PWM
  • Arduino 12 --> Forward
  • Arduino 11 --> Reverse 

5.  Now connect the 6-Pin connector to the motor and connect then connect the motor to the H-bridge module.
Don't forget to connect the motor power pins to the H-Bridge power pins. The motor encoder pins labeled  Hall VCC and Hall GND should be connected to the Arduino 5V and GND pins. Finally, connect motor encoder output channel CH.A to Arduino pin number 21. The connections are shown below:



A closer look of the Arduino pin connections:


6.  Now connect the Arduino to your computer or laptop for programming:


 

Code for Checking Encoder Manually

int encoderValue=0;
void count(void); // code for counting the increasing values of encoder ticks void setup()
{
Serial.begin(9600);
pinMode(21,INPUT);
attachInterrupt(2,count,FALLING);
encoderValue=0;
}
void loop()
{
Serial.print("Starting\n");
// to print encoder value on the screen Serial.print("Encoder Value="); Serial.println(encoderValue);
}
void count()
{
encoderValue++;
}

To download the code click below:
 Code Download

Code for Running Motor till Encoder Specific Counts


//defining Pins names for the code
int pwm=13; int forward=12; int reverse=11;
int encoderValue=0; void count(void); void setup()
{
Serial.begin(9600);
pinMode(21,INPUT);
attachInterrupt(2,count,FALLING);
encoderValue=0;
}
void loop()
{
digitalWrite(pwm,1);
digitalWrite(forward,0);
analogWrite(reverse,140);
Serial.print("Starting\n");
delay(3000); Serial.print("Encoder Value="); Serial.println(encoderValue); while(1)
{
// to print encoder value on the screen Serial.print("Encoder Value="); Serial.println(encoderValue); //Setting value of encoder
//defining the while statement condition if(encoderValue<5000)
break; // loop will break as soon as encoder value reaches 5000 or above digitalWrite(forward,1);
digitalWrite(reverse,0);
analogWrite(pwm,150);
}
digitalWrite(forward,1);
digitalWrite(reverse,1);
analogWrite(pwm,255);
}
void count()
{
encoderValue++;
}
To download the code click below:
 Download Code

Conclusion

Encoders are devices that can be attached to any rotary or linear device to track the motion and orientation of the device. Here we used an absolute rotary encoder to both control the motor speed and shaft position.

Videos



Please share and like our facebook page- 
 Like us on facebook

Comments

Popular posts from this blog

Practical Projects for Engineering Students-8

Soldier Health & Position Tracking System The soldier Health and Position Tracking System allows military to track the current GPS position of soldier and also checks the health status including body temperature and heartbeats of soldier. The System also consists extra feature with the help of that soldier can ask for help manually or send a distress signal to military if he is in need. The GPS modem sends the latitude and longitude position with link pattern with the help of that military can track the current position of the soldier. The system is very helpful for getting health status information of soldier and providing them instant help. The nation’s security is monitored and kept by army, navy and air-force. The important and vital role is of soldiers who sacrifice their life for their country. There are many concerns regarding the safety of the soldier. Soldiers entering the enemy lines often lose their lives due to lack of connectivity, it is very vital fo

Introduction to robotics .............. Part-3 (Automation)

Automated Portable Hammering Machine Hammering is the most widely used industrial as well as construction activity. Hammering or screws, metal sheets, parts etc requires a lot of time and effort. So here we propose an automated hammering system that allows for fully automatic hammering process. This allows for accurate, fast and automated hammering wherever and whenever needed using a 12V battery. The person just needs to insert workpeice and start the hammering machine. This machine can be used for automatic hammering work as and when needed. We here use a dc motor in order to move the hammer. The DC motor consists of a pulley attached to it which is connected to a larger pulley for efficient power transfer and to increase torque. This large pulley is connected to a shaft that has a connecting rod attached to it. This rod is used to achieve lateral motion from the spinning shaft. We now connect the other end of hammer to this connecting rod through a mid swinging arrangement i

Introduction to robotics .............. Part-2

Line Follower Robot Our Line Follower Robot Line followers are one of the most prominent kinds of robots. They have existed for a very long time, however, the technologies used for building them have changed rapidly. Earlier, controller boards the size of bricks were used, but now they have shrunk and become tremendously powerful. Now, technology allows you to build a line follower in just under 10 minutes if you have the parts for it. So enjoy building this quick and easy line follower. Have fun with this DIY hacking tutorial! Required Materials Hardware : 1.       Arduino  / Arduino Clone or make your own  custom Arduino board . 2.       Two continuous rotation servo motors like this:  Continuous rotation servo . 3.       A ball caster:  Ball caster . 4.       An infrared sensor array like this:  Pololu QTR-8A IR sensor array  OR a set of six  IR Leds  and  Detectors . 5.       Resistors:  1K  and  10K . 6.       Two  robot wheels , select wheels after chec