Table of Contents

Actuators

 General audience classification icon  General audience classification icon
Actuators are devices that can do a physical action to the surrounding world. Most actuators are based on one of the forms of electric motors, sometimes directly, sometimes using a gearbox and advanced control logic.
An electric motor is an electromechanical device which can turn electrical energy into mechanical energy. The motor turns because the electricity in its winding generates a magnetic field that inducts the mechanical force between the winding and the magnet. Electric motors are made in many variants, of which the simplest is the permanent-magnet DC motor.

DC Motor (One Direction)

DC motor is a device which converts direct current into mechanical rotation. DC motor consists of permanent magnets in the stator and coils in the rotor. Applying the current to coils creates an electromagnetic field, and the rotor tries to align itself to the magnetic field. Each coil is connected to a commutator, which supplies coils with current, thus ensuring continuous rotation. Some motors have a tachometer functionality as the loopback signal that generates a pulse train of frequency proportional to the rotation speed. Tacho signal can be connected to a digital or interrupt input of a microcontroller, allowing for determining actual rotation speed. DC motors are widely used in power tools, toys, electric cars, robots, etc. (figure 1). The connection schematic for a small DC motor is present in figure 2.

 A DC motor with gearbox
Figure 1: A DC motor with gearbox 50:1
 Arduino Uno and DC motor schematics
Figure 2: Arduino Uno and DC motor schematics

Sample code to control a DC motor using Arduino framework is present below:

void setup ()
{
  pinMode(5,OUTPUT); //Digital pin 5 is set to output
  //The function for turning on the motor is defined
  #define motON digitalWrite(5,HIGH) 
  //The function for turning off the motor is defined
  #define motOFF digitalWrite(5,LOW)  
}
void loop ()
{
  motON; //Turn on the motor
}
DC Motor With H-Bridge

The H-bridge has earned its name because it resembles the capital 'H' wherein all the corners are switches, and the electric motor is in the middle. This bridge is usually used for operating permanent-magnet DC motors, electromagnets and other similar elements because it allows working with significantly bigger current devices using a small, driving current. By switching the switches, it is possible to change the motor direction. It is important to remember that the switches must be turned on and off in pairs (figure 3).

 The flow of currents in the H-bridge
Figure 3: The flow of currents in the H-bridge

When all switches are turned off, the motor is in free movement. It is not always acceptable, so two solutions can be implemented. If both positive or negative switches are turned on at the top or the bottom, then the motor coil is shorted, not allowing it to have a free rotation – it is slowed down faster. The fastest option to stop the motor is to turn the H-bridge in the opposite direction for a while.

Neither of these braking mechanisms is good for the H-bridge or the power source because of excessive current appearance. This action is unacceptable without a particular reason because it can damage the switches or the power source.

The motor management can be reflected in the table 1.

Table 1: The Management of the H-Bridge Switches
Upper left Upper right Lower left Lower right Motor work mode
On Off Off On Turns in one direction
Off On On Off Turns in another direction
On On Off Off Braking
Off Off On On Braking

The complicated part is implementing and controlling the switches mentioned above, usually as relays or appropriate power transistors. The biggest drawback of relays is that they can only turn the engine on or off. Transistors must be used if the rotation speed needs to be regulated using the pulse width modulation. The MOSFET-type transistors should be used to ensure a large amount of power.
Nowadays, the stable operation of the bridge is ensured by adding extra elements. All elements can be encapsulated in a single integrated circuit, e.g. L293D (figure 4).

 The L293D microchip and its representation in the circuit
Figure 4: The L293D microchip and its representation in the circuit

The L293D microchip consists of two H-bridges and is made for managing two motors. It has separate control pins for the left and right branches, avoiding the power short circuit if connected properly.
An example schematic diagram of connecting the chip to the Arduino Uno board can be seen in figure 5.

Using a PWM signal allows control of the rotation speed.
 Arduino Uno and L293D H-bridge schematics
Figure 5: Arduino Uno and L293D H-bridge schematics

The example code to control the L293D chip is presented below:

int dirPin1 = 7;    //1st direction pin
int dirPin2 = 8;    //2nd direction pin
int speedPin = 5;   //Pin responsible for the motor speed
 
void setup ()
{
  pinMode (dirPin1,OUTPUT);  //1st direction pin is set to output
  pinMode (dirPin2,OUTPUT);  //2nd direction pin is set to output
  pinMode (speedPin,OUTPUT); //Speed pin is set to output
}
 
void loop ()
{
  analogWrite(speedPin, 100); //Setting motor speed
  //Speed value can be from 0 to 255
 
  int motDirection = 1; //Motor direction can be either 0 or 1
 
  if (motDirection) //Setting motor direction
  {//If 1
    digitalWrite(dirPin1,HIGH);
    digitalWrite(dirPin2,LOW);
  }
  else
  {//If 0
    digitalWrite(dirPin1,LOW);
    digitalWrite(dirPin2,HIGH);
  }
}
Linear actuator

A bidirectional DC motor, usually controlled with an H-bridge and equipped with thread gear, can be used to implement the linear actuators.
Linear actuators used to be equipped with end position detectors such as switches, or eventually, their end positions can be detected with overload detection. A simple linear actuator is present in figure 6.

 Low voltage linear actuator
Figure 6: Low voltage linear actuator
Stepper Motor

A certain angle or step can move stepper motors. The full rotation of the motor is divided into small, equal steps. Stepper motor has many individually controlled electromagnets; turning them on or off makes a motor shaft rotate by one step. Changing the switching speed or order can precisely control the rotation's angle, direction or speed. Because of their exact control ability, they are used in CNC machines, 3D printers, scanners, hard drives, etc.
A popular stepper motor is present in figure 7 and its controlling circuit in figure 8.
An example of use can be found in the source [1].

 A stepper motor
Figure 7: A stepper motor
 Arduino Uno and stepper motor schematics
Figure 8: Arduino Uno and stepper motor schematics

The example code:

#include <Stepper.h> //Include library for stepper motor
 
int in1Pin = 12; //Defining stepper motor pins
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;
 
//Define a stepper motor object
Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);  
 
void setup()
{
  pinMode(in1Pin, OUTPUT); //Set stepper motor control pins to output
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
 
  Serial.begin(9600);
  motor.setSpeed(20); //Set the speed of stepper motor object
}
 
void loop()
{
    motor.step(5); //Rotate 5 steps
}
Servomotor

The servomotor includes the internal closed-loop position feedback mechanism that precisely controls its position angle. To set the angle, the PWM technique is used. Additionally, it is possible to control the speed of angle change, acceleration and deceleration of the rotation.
Servomotors have limited rotation angles depending on their type, e.g. 90, 180 or 270 degrees. A typical servo is 180 degrees (usually a bit lower). Servo powering depends on size; micro servos are typically between 4.8V and 6V. Larger servos require higher voltage and more current to operate.
There are two standards for controlling servos, so-called “analogue” and “digital”. Analogue servos are controlled with a PWM signal of 50Hz (20ms period), while digital servos, even if backwards compatible with analogue, can be controlled with a PWM signal up to 250Hz. A duty cycle (a ratio between HIGH and LOW) controls servo position. We focus below on analogue servomotors, controlled with a 50Hz PWM signal, but the transition to digital ones is straightforward.

Digital servos used to have individual configurations of the control signals, and it is necessary to refer to the documentation of the particular model for correct timings.

From the figure 9, it can be seen that the length of the servomotor impulse cycle is 20 ms, but the impulse length itself is 1 ms or 2 ms. These signal characteristics are true for most enthusiast-level servomotors but should be verified for each module in the manufacturer specification, e.g. to obtain a full rotation of 180 degrees, it may be necessary to go beyond standard 1ms↔2ms duty cycle.
The servomotor management chain meets the impulse every 20 ms, but the pulse width shows the position the servomotor has to reach. For example, 1 ms corresponds to the 0° position but 2 ms – to the 180° position against the starting point. When entering the defined position, the servomotor will keep it and resist any outer forces trying to change the current position. The graphical representation of the control signal and its impact on the position of the servomotor is presented in image 9.

 The pulse width modulated signal for different positions of servomotor
Figure 9: The pulse width modulated signal for different positions of servomotor

Just like other motors, servomotors have different parameters, where the most important one is the time of performance – the time necessary to change the position to the defined position. The best enthusiast-level servomotors do a 60° turn in 0.09 s. There are three types of servomotors:

Unfortunately, using Arduino, the servomotor is not as easily manageable as the DC motor. For this purpose, a special servomotor management library, “Servo.h” has been created. Using PWM signal in other MCUs may involve the use of hardware or software timers and may impact other features as the number of hardware timers used to be limited. Thus, “Servo.h” implementation may vary between microcontrollers and SDKs.

Sample standard servo is present in figure 10 and connection in figure 11.

 A servomotor
Figure 10: A standard servomotor
 Arduino Uno and servomotor schematics
Figure 11: Arduino Uno and servomotor schematics

The example code to control a servo:

#include <Servo.h> //Include Servo library
Servo servo; //Define a Servo object
 
void setup ()
{
  servo.attach(6); //Connect servo object to pin D6
  servo.write(90); //Set position of servo to 90°
  Serial.begin(9600);
}
 
void loop ()
{
  servo.write(110); //Set position of servo to 110°
  delay(200); //wait for 200 ms
  servo.write(70);//Set position of servo to 70°
  delay(200); //Wait for 200 ms
}