The stepper motor has many parameters that can be controlled like -:
1. Direction of rotation
2. Speed of rotation
3. Angle of rotation
4. Number of revolutions
The Arduino can control all these parameters. It can
• Rotate stepper motor CW or CCW
• Vary its speed in RPM
• Rotate motor at specific angle
• Rotate motor to desire number of revolutions
The project given here demonstrates how to vary the speed of stepper motor and number of revolutions of it using IR remote (like TV, DVD, AC, STB etc) with the help of Arduino. The project uses a normal set top box (STB) IR remote, TSOP IR sensor, stepper motor driver chip and Arduino UNO board. Anyone can use any type of IR remote. Just he has to change the remote codes in the Arduino sketch (program) for the remote. This procedure is also described here while explaining the operation. So let us see how this is done. First, see the circuit diagram followed by its description and operation.
CIRCUIT DESCRIPTION
As shown in the figure, the circuit is built using 3 components only an Arduino board, IR sensor and stepper motor driver chip ULN2003A.
• The sensor TSOP1738 has 3 terminals (1) Vcc (2) Gnd and (3) output. Its Vcc terminal is given 5 V from board and Gnd terminal is connected to the ground of board. The sensor output is connected digital input pin 12 of arduino board.
• Digital pins 8 to 11 of board drives 5 wire unipolar stepper motor through ULN2003A chip. These pins are connected to inputs of UNL2003A chip and outputs of UNL will drive stepper motor coils as shown.
• The stepper motor and ULN2003A chip are given external 5 V supply.
Here is the snap of circuit arrangement.
Fig. 1: Prototype of Arduino and IR Remote based Stepper Motor Controller
CIRCUIT OPERATION
First, we have to decide, which are the different buttons of IR remote, that we will use to control a stepper motor. We want to perform following actions.
1. Rotate the motor to desire number of revolutions like 1, 2, 3… likewise
2. Increase/decrease speed of motor
I have used set-top box (STB) remote that has many buttons like 0-9 digit buttons, volume control buttons, channel up/down buttons, arrow key buttons etc. From all these buttons I have selected following 7 buttons for different operations.
Fig. 2: Table listing IR Remote buttons and respective functions in Stepper Motor Control
That means when any digit button between 1 to 5 is pressed, the motor will rotate that many revolutions. And that is also at selected RPM. This RPM can be varied from 25 to 125 using volume up and volume down button.
After deciding the buttons next is to decode the codes of these buttons. As we know when any button is pressed from remote, it will send one code and based on this code the action is performed. So to decode these codes I have used IRremote library for arduino, readily available on the internet.
So download the library and use an example to decode the codes of remote buttons. Upload the program into arduino microcontroller and connect IR sensor as shown in the figure. Now point the remote control towards IR sensor and press the button. Open serial monitor and you can observe the code of pressed button in form of numbers. Note down the codes of required buttons like I have noted the codes as per the following table -:
Fig. 3: Table listing IR Remote buttons and respective IR Codes
In the arduino sketch above codes are used corresponding to button pressed to perform an action as per the previous table. Now let us see the actual operation.
The stepper motor used here is having 7.5o step resolution – means it will rotate 7.5o per 1 pulse. So it will rotate complete 360o revolution when 48 pulses are applied (7.5×48 = 360). So to rotate motor 1 revolution, 2 revolutions, 3 revolutions….. we have to apply pulses in multiples of 48 like 96, 144, 192…
The speed of the motor is calculated in RPM from the equation.
Speed in RPM = 60000 / (pulse time period × 48)
Note :
60 RPM = 1 RPS
1 RPS means – 1 revolution in 1 sec – means 48 pulses in 1 sec – means the frequency of pulses is 48 Hz – means the time period of pulses is 1/48. So as the time period of pulses is changed in mili seconds the RPM of motor is changed as
60 / (pulse time period in sec × 48) / 1000 – that means
RPM = 60000 / (pulse time period × 48)
• The arduino board is given supply through USB and motor and ULN chip is given supply through an external power supply.
• Initially, the motor is stopped and the message is displayed on serial monitor as “IR remote controlled stepper motor”
• Now when digit 1 button is pressed from remote, the motor will rotate 1 revolution and the message is displayed on serial monitor as “motor will rotate 1 revolution”
• Similarly, when any of the digit buttons is pressed the motor will rotate that many revolutions and the message is displayed on the serial monitor.
• When volume up button is pressed, the delay applied between pulses is decreased and RPM is calculated from the above-given equation. The new RPM is displayed on the serial monitor as “motor speed increased to xx RPM”.
• Similarly, when volume down button is pressed, the delay applied between pulses is increased and RPM is calculated. The new RPM is displayed on the serial monitor as “motor speed decreased to xx RPM”.
• After increasing or decreasing the speed (RPM) again when any button 1 to 5 is pressed the motor will rotate at a new speed.
Project Source Code
###
#include <IRremote.h> int IRpin = 12; // pin for the IR sensor IRrecv irrecv(IRpin); decode_results results; int motor_speed_del = 25,motor_speed=50; void setup() { Serial.begin(9600); Serial.println("IR Remote controlled stepper motor"); irrecv.enableIRIn(); // Start the receiver pinMode(8,OUTPUT); // stepper motor pins as outputs pinMode(9,OUTPUT); pinMode(10,OUTPUT); pinMode(11,OUTPUT); } void loop() { while(!(irrecv.decode(&results)));// if no button is pressed, wait until no //code is received if (irrecv.decode(&results)) //when code is received { if(results.value==2210) // if button 1 is pressed { Serial.println("Motor will rotate 1 revolution"); rotate_motor(1); // rotate motor 1 revolutions } else if(results.value==6308) // if button 2 is pressed { Serial.println("Motor will rotate 2 revolution"); rotate_motor(2); // rotate motor 2 revolutions } else if(results.value==2215) // same for button 3, 4 and 5 { Serial.println("Motor will rotate 3 revolution"); rotate_motor(3); } else if(results.value==6312) { Serial.println("Motor will rotate 4 revolution"); rotate_motor(4); } else if(results.value==2219) { Serial.println("Motor will rotate 5 revolution"); rotate_motor(5); } else if(results.value==6338) //if volume up button is pressed { if(motor_speed_del>10) motor_speed_del-=5; //decrease the delay Serial.print("Motor speed increased to "); motor_speed = 60000/(motor_speed_del*48);// calculate RPM Serial.println(motor_speed); // display RPM } else if(results.value==6292) // if volume down button is pressed { if(motor_speed_del<50) motor_speed_del+=5; //increase delay Serial.print("Motor speed decreased to "); motor_speed = 60000/(motor_speed_del*48); // calculate RPM Serial.println(motor_speed); // display it } delay(200); // wait for 0.2 sec irrecv.resume(); // ready to receive next code } } // function to rotate stepper motor void rotate_motor(int r) { int x; for(x=0;x<r*12;x++) // rotate motor desire number of rotations { digitalWrite(8,HIGH); delay(motor_speed_del); digitalWrite(8,LOW); digitalWrite(9,HIGH); delay(motor_speed_del); digitalWrite(9,LOW); digitalWrite(10,HIGH); delay(motor_speed_del); digitalWrite(10,LOW); digitalWrite(11,HIGH); delay(motor_speed_del); digitalWrite(11,LOW); } }###
Circuit Diagrams
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.