There
are some types of DC (Direct Current) motor frequently used in
industrial field. They are ‘ordinary’ DC motor - that can be
driven by giving electric current to its terminals directly,
Brush-less DC motor, stepper motor, and servo motor. Other than the
‘ordinary’ DC motor, the rest mentioned must be driven by
electric signal, either by using analog or digital one. Servo motor
has PWM (Pulse Width Modulation) signal and stepper motor needs bits
patterns which are usually provided on the data-sheet.
This
post will discuss about combining function of stepper and servo motor
using stepper motor, by ‘combining’ I mean just to manipulate
steps on the stepper to rotate according to the degree of rotation
given, and not ‘combining’ its signal – PWM and bit patters. Of
course by doing this way, it has its own limitation, like the
rotation of the stepper is not exactly like a ‘rotation degree’
value we give to it, because a range of degree value is 0 to 360
while a stepper has varying degree value per its step e.g., 1.8
deg/step. If there is a specification of 1 (one) or less degree per
step, it will be perfect to control the rotation.
So
the first thing that we need to do is to prepare the hardware and
software needed; they are L298 IC for current gain of our stepper
motor, an Arduino Uno board for controlling the signal, and the
library that is linked bellow. For the hardware, a proteus simulation
is used. Figure 1 bellow is our schematic circuit.
Figure 1. Simulation of Stepper as Servo motor |
As
seen on the figure above, there are three devices connecting each
other: they are an Arduino Uno, Motor driver L298 IC, and a bipolar
stepper motor.
Get
the library on github:
There
may be one asking “Do we need this L298 IC driver anyway?”. for
this simulation only, we may not need to use that driver, without
this driver – in other words the motor pins are directly connected
to the Arduino pins – the simulation will keep working. But for the
real world, don’t do that!, it may break your Arduino pins. Since
one of functions of this driver is to ‘buffer’ electric current
supplied to the motor, or simply as a current gain.
Next
is to our Arduino sketch
#include "Stp.hpp"
/* Note:
* for servo mode, the set-point (on 0 degree) must be defined first
* before driving any stepper motor
*/
//asume that our stepper motor here has specification of
//1.8 degree of rotation in each its step, each spec of stepper
//motor may differ
//1.8 degree per step; in servo motor mode
Stp motor(1.8,MODE_SERVO);
void setup(){
motor.toPins(4,5,6,7); //pin configuration
motor.spin_speed(100); //delay (in milli second) per step
}
void loop(){
//asume that on the hardware, a set point (of 0 degree)
//position has been set. So that the stepper can move
//around 0 deg to 360 deg consistently
motor = 5; //turn 5 degree
delay(1000);
motor = 16; //turn 16 degree
delay(1000);
motor = 30; //turn 30 degree
delay(1000);
motor = 12; //turn 12 degree
delay(1000);
motor = 1; //turn 1 degree
delay(1000);
}
On
our Arduino sketch above, the comments and variable names will be
self-explanatory. But two things to note here are on line:
motor.toPins(4,5,6,7);
//pin configuration
the
numbering of these pins must be in sequence based on the stepper
connection or the output of the L298 IC driver. For example, 4 to
IN1, 5 to IN2, 6 to IN3 and 7 to IN4. You cannot do this way: 5 to
IN1, 4 to IN2, 7 to IN3 and 6 to IN4, this configuration will break
the steps of stepper rule that is on the data-sheet. Also for the
connection of the stepper terminals to this driver, must be connected
in sequence.
The
second one is that the motor itself must have a set point. The set
point I mean here is its reference rotation. Therefore if any step
has a any slip in rotation, the next degree value we give will not be
achieved. So for this library to be ideal, the steps of motor may not
slip.
0 Comments
Post a Comment