You are on page 1of 30

SECTION ONE

1.0 INTRODUCTION TO CONTROLLERS AND ACTUATORS


1.1 INTRODUCTION TO CONTROLLERS
Engineering has always been concerned with the relationship between inputs and
outputs in systems and processes. This is mainly driven by the desire to obtain
desired outputs which demands an understanding of these relationships and
underlying connections among the variables of a system or process. Once these
connections have been exposed, a desired output can be obtained by modifying the
values of one or more inputs to the process. Although, the output can only be
controlled within a range of possible values as a perfectly accurate control action is
complex and improbable since it would require taking into consideration all
input(s) irrespective of the level of their contribution.

However, control mechanisms were designed that could automatically adjust the
system’s input variable(s) in order to restrict the output to a tolerable range from
the desired output level. These control mechanisms were collectively referred to as
control systems. A control system is an interconnection of components that can
interface with a system in order to achieve a desired response (output) [1].

Most control systems employ a feedback mechanism such that the actual output at
any given interval is measured and compared against a desired value. These are
known as closed-loop control systems [1]. Here, any deviation produced is used to
generate an error signal and sent to a component called the actuator which directly
applies the correction on the system. The former action is performed by a
controller (or sometimes called a control device). The block diagram of a typical
control system is shown in plate 1.1.

1
Fig. 1.1: Block Diagram of a Typical Control System [1]

Modern control systems now employ semiconductor devices as intelligent


controllers. These devices allow for more precise control action with a lot of
advantages such as higher accuracies, higher speed and greater resolution and they
also offer increased flexibility and ease of interfacing with other systems. Fig 1.2
shows how these devices represented as computers have replaced traditional
control devices in control systems.

Fig. 1.2: Block diagram of a Computer Control System [1]

Ideally, computers as used in Plate 1.2 represents a whole range of semiconductor-


based devices ranging from microprocessors, microcontrollers, application specific
integrated circuits (ASICs), and a host of other programmable logic devices -
electronic devices capable of computing. This report looks at how the computer-
actuator link can be created specifically using the Raspberry pi microcomputer
(sometimes called a microcontroller) and motion actuators. A microcomputer is a
computer built on a microprocessor.
2
1.2 NEED FOR ACTUATORS
Actuators are responsible for performing the control action. They are simply
devices that accept control signals (electrical, pneumatic, or hydraulic) and
produce physical reactions. These physical reactions could be in the form of light,
motion, heat, sound etc., which gives rise to the different classifications of
actuators. For example: light actuators such as light emitting diodes (LEDs) can be
used for indication, the intensity of the light they emit depends on the current level,
sound actuators produce sounds depending on varying voltage levels, motion
actuators produce motion when activated. Although, this report is focused on
electrically activated actuators.

Actuators are necessary because they provide a way of physically interacting with
a system [2].

1.3 DEVELOPMENT OF CONTROLLER-ACTUATOR LINK


Originally, mechanical devices were used as controllers. These controllers could
perform proportional control action, proportional-integral (PI) control action or
proportional integral derivative (PID) control action.

James Watt developed the first controller ‘the flyball governor’ which could
control the speed of an engine by regulating its fuel intake [1]. The all-mechanical
device utilized the movement of two fly balls to manipulate a shaft which then
opens the fuel intake valve or closes it. The controller-actuator link here was a
combination of the mechanical linkage between the flyballs and the intake valve.
These systems were inefficient as they depended on the system for their source of
energy. As time progressed, pneumatic control devices were developed.
Controllers in this case were still mechanical devices, the difference was they were
pneumatically powered and generated pneumatic signals to drive actuators. This
implies that they could be driven by an external pressure source thereby reducing

3
the problem of taking energy from the system. However, they were limited in
performance since they were based on mechanical parts.

Finally, modern control systems were developed based on electric and electronic
components. Semiconductor devices were used as controllers and actuators were
electrically activated as described earlier. These devices were programmed to
generate signals corresponding to the desired control action.

1.4 RASPBERRY PI AS A CONTROLLER


The most fundamental requirement of being a controller is the ability to generate
control signals. Raspberry pi is a microcomputer invented in the United Kingdom
(UK). Being a computer, it can act as a controller by executing a suitable program.
It can interface with input and output devices, so it can receive feedback from
sensors (in case of closed-loop control systems) and send out signals to actuators
which are connected to it as output devices. A more concise review of Raspberry pi
computers is done in section two.

4
SECTION TWO
2.0 OVERVIEW OF BASIC COMPONENTS AND RELATED
WORKS
2.1 OVERVIEW OF BASIC COMPONENTS
Electrically activated motion actuators are ubiquitous in most modern control
systems. Such actuators include; electric motors and solenoids. These devices are
operated by electric signals and they can be found in automatic assembly lines,
generators, control valves, robotic systems and whatnots. Knowledge of how these
actuators operate is necessary in developing control strategies.

2.1.1 ELECTRIC MOTORS

Direct Current (DC) Motors: A DC motor is an electric device that converts DC


electrical energy into mechanical energy. Motors can be classified as motion
actuators since they produce rotational motion when under the influence of a
source of electrical energy. Motion (rotational motion) in a DC motor is produced
by a torque which is generated from the interactions of the electrically-induced
magnetic field of the rotor (or armature) windings and the field windings of the
stator (stationary conductor). Torque is defined as rotational force. The rotor, being
free to move, rotates due to the generated torque as indicated by the laws of
electromagnetism. To ensure that the motor spins is unidirectional, a commutator is
used [3]. DC motors are ideal for control applications due to two important
relationships being linear:
1. The relationship between the applied DC current and the torque produced.
2. The relationship between the voltage across the motor’s terminals and the
speed of the motor.

5
When the current through the motor is reversed, the direction of rotation also
reverse according to Fleming’s left-hand rule. DC motors can be brushed or
brushless. Brushed DC motors use a conductor (brush) – thick orange line close to
the shaft in plate 2.1 - to pass current to the armature winding.

Plate 2.1: Brushed DC Motors [5]

Servo-motors: Servo motors are regular motors equipped with a control circuitry.
The control circuitry senses error based on the angular difference between the
current position of the motor’s shaft and the desired position due to the control
signal received. Position is sensed using a potentiometer. The error signal is then
used to correct the motor’s output (shaft position).
Servos can be either DC or AC and they are used for accurate angular positioning.
Usually, they are controlled by pulse-width modulated signals where the width of
the pulse determines the angular displacement of the shaft [3]. They are widely
used in robotics and small models as they are easily controlled using just three
wires, Power, Ground and Signal Control [5] as seen in plate 2.2

6
Plate 2.2: Block diagram of a servo motor [5]

Stepper motor: Stepper motors are quite different from DC motors in that they do
not rotate but step. Internally, steppers consist of a rotor with permanent magnet
teeth and a stator having electromagnet (has electromagnetic coils) teeth [5].
When a coil is energized, it acts like a magnet and the rotor moves to align with it.
This is known as a step. Since each coil can be separately energized, the rotor can
be made to go through one revolution by sequentially activating the coil pairs.
Thus, an integer number of steps makes a full rotation. In that way, the motor can
be rotated (stepped) through a precise angle known as the step angle as shown in
plate 2.3.

This makes stepper motors ideal for precise motion control, since every position
can be approximately determined in a number of steps from the initial position. A
revolution can be divided into 4 – 400 steps, although 24, 48 and 200 steps are
commonly used. By dividing a complete revolution by the number of steps, the
degree change per step can be found. For example, a 200-step motor will have a
step degree change of 360/200, i.e. 1.8° step angle.

7
Plate 2.3: A step motor having 4 poles and a step angle of 15°[5]

The stepper motor has four coils, making it a 4-phase motor, with the number of poles on
the stator being eight (2 x 4) which are spaced at 45 degrees intervals. The number of teeth
on the rotor is six which are spaced 60 degrees apart.
Then there are 24 (6 teeth x 4 coils) possible positions or “steps” for the rotor to complete
one full revolution. Therefore, the step angle above is given as: 360°/24 = 15°

Solenoids: The word solenoid is a generic term used to refer to wires wound
around a magnetic core thus forming an electromagnetic. This is shown in plate 2.4
below.

Plate 2.4: Magnetic field lines in a solenoid [5]

8
When energized by an electric source, the wires produce a magnetic field which
can then be used to cause linear motion by attracting or repelling a moving piston.
Solenoids are used as high power on/off switches and can be found in automatic
ignition systems, factory equipment, control valves etc.

2.1.2 RASPBERRY PI

Raspberry is an advanced RISC Machine ARM architecture based single-


board computer series developed by Raspberry Pi foundation. Though originally
intended for educational purposes, Raspberry pi found its way into a lot of
hobbyist and embedded projects mostly due to its high performance offered at a
relatively low cost.
The first Raspberry Pi was released in 2012 [6] and we have had three generations
released so far: Pi 1, Pi 2 and Pi 3. Most of these generations have Model A and
Model B. While Model B and its variants consumes lower power, has better audio
and a better form factor compared to Model A. Model A Pis are targeted at low-
budget users who want the pi's functionality at even lower cost. Model A (costs
around $20 for model A and $25 for model A+) tends to have reduced random
access memory (RAM) and ports like universal serial bus (USB) and Ethernet. The
first Pi board, Raspberry Pi B, cost around $35 and had a single-core 700MHz
central processing unit (CPU) and just 512MB RAM [7]. It offered only two USB
ports for connectivity and 26 general purpose input and output (GPIO) pins. Later
models had 40 GPIO pins. The latest Pi model, Raspberry Pi 4, shown in plate 2.6,
has a CPU which clocks at 1.4GHz, variants of this model are built with 1GB, 2GB
and 4GB RAM. Price of this model is $35. A spin-off version, Raspberry Pi zero
built on a single-core processor (other models have quad-core processors), was
priced at $5. This is because it offers reduced functionalities and interfaces.

9
Typical features of Raspberry pi boards
● Quad-core ARM processors (except for Pi zero models which use a single-
core processor)
● Universal serial bus (USB) ports: 2 or 4 (depending on the model)
● Peripherals: General purpose input and output (GPIO) pins, and HAT ID bus
● Power source: 5V via microUSB or GPIO headers
● Other feature are shown in plate 2.5.

Plate 2.5. Features of Raspberry pi 2 [6]

The Pi board is powered by a 5V DC source which can be connected via


microUSB or GPIO power headers. Power consumption in Raspberry Pi peaks at
1.34A for Pi 3 and 800mA at 5V. Peak power occurs during booting. Moreover,
Raspberry Pi operates a 3V logic. This means that a high or logic 1 is indicated by
a voltage of about 3.3V. This is especially important since most peripheral devices

10
operate on the more common 5V logic. In this case, a level converter would be
used to match the logic. GPIO pins are for interfacing input and output devices and
they can only source a maximum of 50mA [6]. Drivers would be needed to meet
higher current requirements. Also, a microSD card serves as the primary memory -
this is also where it looks for the operating system (OS). The microSD is slotted
into the SD card slot.

2.2 REVIEW OF RELATED HARDWARE CONTROL PROJECTS WITH


RASPBERRY PI
Control programs to run on Raspberry Pi were developed for regular DC motors
and servo motors in [3]. This was made possible by an understanding of operating
principles of the motors. For interfacing the motors, the motor driver L293D was
employed. It was compatible with the 3.3V logic of raspberry pi and was able to
provide enough power to run the motors. A similar IC, L298D is reviewed in
section three. Moreover, it had an operational voltage range of 4.5V to 36V which
was suitable for the 6V PERMAX DC motor used. The control programs were
developed based on RPi.GPIO GPIO access library which is a library of functions
to access and control GPIO pins.

Similarly, authors in [4] utilized the ULN2003A (reviewed in next chapter) to


boost the low power control signals from the Raspberry pi module. This was in
order to interface a four coil stepper motor – 2BYJ-48, a 5V stepper motor. There
are seven input and output pins on the ULN2003A. Four of the input pins were
connected to the GPIO pins of a Raspberry pi 3 module while the corresponding
outputs of the four inputs were connected to the four coils of the stepper motor as
shown in fig. 2.1. They made the motor step by applying square wave pulses to the
windings in turns. By alternating this sequence, the angular displacement and
direction of rotation of the motor can be controlled [4].
11
Fig. 2.1: Controlling a 4-phase stepper motor using Raspberry Pi 3A [4]

Apart from motors, other actuators or hardwares can be controlled using a


raspberry pi module. The authors in [8] showed the process of controlling a LED
light using the Raspberry Pi module. The procedure they offered is as follows:

1. Installing the Raspberry Operating System (or any other compatible


operating system)
2. Booting up the Pi and setting it up like a regular computer (desktop mode) or
via remote login (secure shell mode)
3. Turn off the Pi once booting up is successful to avoid damaging the pi
4. Make the circuit connections
5. Once correctly connected, boot up the pi
6. IN DESKTOP MODE:
a. Launch Python IDLE to enable you enter the control code (program)
b. Import GPIO libraries and write the main program
c. Run the program by selecting Run>Run module from the editor
7. IN SECURE SHELL (SSH) MODE
a. From the command line, create a new script in Nano.
b. Enter the same program as in 6b.
c. Press Ctrl-X and then Y to save the program.
d. Run the program by using the command python program_name.py
12
SECTION THREE
3.0 INTERFACING AND CONTROLLING MOTION
ACTUATORS WITH RASPBERRY PI
3.1 INTERFACING RASPBERRY PI WITH EXTERNAL COMPONENTS
As a microcomputer, raspberry pi can interface with external devices. Most of the
interfacing requirement is done through the GPIO pins. The process of interfacing
requires; setting up the raspberry pi, setting up the GPIO pins, connecting drivers
(if necessary) then connecting the device using the appropriate GPIO pin(s). This is
illustrated in fig. 3.1.

Set up the Raspberry pi

Connect the hardware device to be controlled


to the pi board (interfacing it properly)

Import GPIO libraries and write the


main control program

Execute program

Fig. 3.1: Setting up pi board for controlling hardware devices

3.1.1 Setting up the Raspberry pi

Assuming you purchased a new raspberry pi, the first thing to do is to install the
operating system (OS). Raspberry pi supports several operating systems such as:

● Raspbian (the most commonly used OS)

13
● RISC OS
● Windows IOT
● Arch Linux ARM
● LinuTop
● Open-Source Media Center (OSMC) etc. [8]

New Pi boards do not come pre-installed with any OS, instead new-out-of-the-box
software (NOOBs) are provided via an SD card. NOOBs are actually a variety of
operating systems from which the user can make their choice. Alternatively, the
OS can be downloaded from the internet and written to an SD card (raspberry pi
loads its OS from the SD card attached to SD card slot) [6]. The whole process is
summarized in fig. 3.2.

14
Purchase pi board

Does the board


come with SD NO
card containing
the NOOBs?

YES

Are the
given OS NO
desired?

Download OS from the internet


via Windows or Linux computer

YES
Write to SD card

Slot in the SD card into the SD


card slot of the pi board

Connect power

Boot the pi

Fig. 3.2. Installing an OS in Raspberry pi

15
Standard power supply to a raspberry pi is 5V 2/2.5A. This can be provided by the
means stated earlier.

3.1.2 GPIO pins of Raspberry pi

Although older models feature 26 GPIO pins, newer models now possess 40 GPIO
pins. These pins are driven by a 3.3V rail and rated at about 17mA [6]. This is
different from the power headers where we have two 5V pins (pin 2 and pin 4) and
the 3.3V power lines which can source up to 500mA. This however depends on the
pi’s model.

GPIO pins are integrated into the circuit board of the computer. Their behavior can
be controlled by the user to allow them to read data from sensors, and control
components like LEDs, motors, and displays.

Plate 3.1: GPIO pins in raspberry pi 3

16
3.1.3 Overview of some GPIO pins

1. Power pins:
a. 5V pins (pins 2 and 4)
b. 3.3V (pins 1 and 17)
c. Ground (pins 6, 9, 14, 20, 25, 30, 34 and 39)
The power pins (can be used to power peripherals and at the same time
supply power to the pi board. The amount of current that can be sourced
to peripherals depends on what is left after the pi board has met its power
needs. Most models draw about 2A on booting, but only require about
750mA when running. Therefore, if a 2.5A power supply is used, the
maximum current that peripherals can draw without affecting the pi is
1.7A. Placing 5V on the 3.3V lines would fry the pi board.
2. Pulse width modulation (PWM) pins:

Software PWM is available on all pins save the power headers. Hardware
PWM available on GPIO12, GPIO13, GPIO18, GPIO19. Note:
distinction between pin 12 and GPIO12 as indicated in plate 3.3***.
PWM finds extensive use in controlling devices such as electric motors.

3. Serial peripheral interface (SPI)


SPI is a common interface found on most devices (sensors, liquid crystal
display (LCD) drivers, EEPROM modules etc.). There are two sets of
GPIO pins designated for SPI communication:
a. SPI0: MOSI (GPIO10); MISO (GPIO9); SCLK (GPIO11); CE0
(GPIO8), CE1 (GPIO7)
b. SPI1: MOSI (GPIO20); MISO (GPIO19); SCLK (GPIO21); CE0
(GPIO18); CE1 (GPIO17); CE2 (GPIO16)
4. Inter-integrated circuit (I2C) pins:

17
I2C requires two pins, serial data line (SDL) and a serial clock line
(SCL). This is provided by GPIO2 and GPIO3 pins respectively.

5. Universal Asynchronous Receive and Transmit (UART) pins:

GPIO14 and GPIO15 are designated for UART communication.

6. Programmable GPIO pins:

Of the 40 GPIO pins, 26 (GPIO2 to GPIO27) can be programmed. Out of


this number some have specific functions, leaving just 17 GPIO pins

3.1.3 GPIO libraries

GPIO libraries are basically pre-written programs that allow you access and control
the GPIO pins. Several libraries exist but the most popularly used and up-to-date
libraries are RPi.GPIO (default raspberry pi GPIO library), wiringPi, GPIO zero
and pigpio.

3.2 MEETING VOLTAGE AND CURRENT REQUIREMENTS OF


ACTUATORS
Actuators need higher voltage and draw more current that the raspberry pi can
source. To drive actuators will require an intermediate component that will receive
instructions from the raspberry pi and switch the actuator appropriately. This can
be achieved by using drivers. Drivers allow for low power signals from
microcontrollers to control high power devices. For electric motors, a motor driver
might be used to amplify the low power signals from the microcontroller.
Solenoids on the other hand are best actuated by a relay module which provides
both isolation and can switch high power circuits. The voltage and current demand
of the solenoid will determine the relay module to use. Relays can switch 12V or
24V solenoids comfortably and source currents greater than 1A. However, most
18
relay modules are not compatible with the 3V logic of raspberry and they require
more current than the GPIO pins can source. This will require connecting a
switching element between the GPIO pin and the relay or a dedicated relay driver.
This is shown in fig. 3.3.

Motor Relay
(DC and
stepper) Solenoid

Fig. 3.3. Interfacing devices with a microcontroller

A driver in its basic form is a switching and amplifying transistor which could be a
bipolar junction transistor (NPN or PNP), MOSFET or transistors in Darlington
configuration to meet high current requirements. Driver ICs have also been
developed to minimize the use of discrete components and provide easy
interfacing.

19
Fig. 3.4: Circuit showing the use of MOSFET in switching relays [9]

The flyback diode in fig. 3.4 is to protect the transistor from damage due to reverse
current.

3.2.1 Motor drivers

Motor driver circuits act as current amplifiers. For DC motors, drivers consist
basically of switching elements arranged in an H-bridge. This allows for the motor
to be rotated in both directions by selectively turning on the switching elements.
This alternates the voltage between the terminals, and hence causes the current to
flow in the reverse direction which causes change in direction of rotation. A basic
structure of an H-bridge is shown in fig 3.

Fig. 3.4: Basic schematic diagram of an H-bridge [10]

20
Fig. 3.5: Nature of the H-bridge during forward and reverse rotation respectively [10]

Braking can be achieved in two ways:

1. Switching off all the transistors. This will cause the motor to gradually
come to a halt.
2. Applying an equal voltage to both sides of the H-bridge. This will
cause a sudden halt.

The diodes in the circuit of fig. 3.4 protects sensitive electronics of the driver from
damage due to back emf. When motors rotate, they produce a back emf (or reverse
voltage) which opposes the main supply voltage from the driver. If allowed, the
reverse voltage may destroy the transistors or other circuitry.

3.2.2 Stepper and Servo motor drivers

Servo motors are equipped with onboard drivers. Therefore, they do not exceed
driver. They only require a control signal to specify the position of the shaft.
Stepper motors on the other hand, can use the same driver as a DC motor as long
as it can provide the current requirement.

3.2.3 L298D motor driver

The L298D motor driver shown in plate 3.2, works just like every other driver, it
acts as a current amplifier. Internally, it consists of two H-bridge driver circuits. It
21
can drive two brushed DC motors simultaneously, both in forward and reverse
directions. More features of the L298D:

1. Voltage range of 4.5V to 36V for motor


2. Motor's peak current of 1.2A
3. Continuous motor current of 600mA
4. Compatible with Raspberry Pi 3V logic

Plate 3.2: L298D IC

3.2.4 Interfacing with relays and solenoids

Relays require about 50 – 100mA as input. GPIO pins can only source at most
50mA without tripping the module. To enable GPIO pins to interface with relays,
drivers could be used. One popular choice of relay driver is the ULN2003A, shown
in plate 3.3.

22
Fig 3.6: DIP package of ULN2003A IC and the logic diagram

The ULN2003A belongs to the ULN200X family series. It is a signal amplifier so


it can be used as a driver for relay, stepper motors, LED displays, lamps etc. It
consists of seven open pair Darlington transistors which can source currents
between 500mA and 600mA. It can drive seven (7) loads at a time.

ULN2003A has 16 pins in total out of which are:

● 7 Input pins (Pin 1 to Pin 7)


● 7 Output pins (Pin 10 to Pin 16)
● 1 Ground pin (Pin 8)
● 1 COM pin (Pin 9)

23
3.3 CONTROLLING MOTORS ACTUATORS

3.3.1 Software control

The basic steps required to enter code into Raspberry pi has already been itemized
in section two. The working principles of the motion actuators have already been
discussed and how they can be interfaced with the pi board. Now looking at how to
write a program will be based on this understanding.

3.3.2 Controlling a DC motor

DC motors are usually driven by h-bridges or ICs containing H-bridges[3]. The


four switching elements of the h-bridge will be connected to four GPIO pins.
Therefore, by alternating the state of these pins, control can be achieved. A likely
pseudocode of a motor control program is given:

Import GPIO library


If (RPi.GPIO is used) set pin reference mode
If (H-bridge driver is used) set the four output pins
Define forward motion function (by setting the conditions of the output
pins)
Define reverse motion function
Define braking function
Call forward motion function

3.3.3 PWM control of a DC motor

PWM allows a fixed voltage to be varied, depending on the duty cycle. For DC
motors, there is a linear relationship between the voltage and the speed. This
implies with PWM we can have control over a motor’s speed, the speed being
proportional to the duty cycle. Using a pseudocode to show this:

24
Import GPIO library
If (RPi.GPIO is used) Set pin reference style
Assign state for output pins
Set PWM frequency
Assign value for duty cycle and initiate PWM

3.3.4 Control for stepper motors

To step a stepper motor requires activating one pair of its coils [5]. This can be
achieved by commanding the driver to activate the line on which the coil is
attached. The pseudocode of a program to rotate a 4-coil stepper is shown below:

Import GPIO library


Set output pins (according to number of stages of the step motor)
Set all output low, 0
Iterate through the outputs
Select one output and make it high, 1
Select another output
Make the previously selected output low
Make the currently selected output high
Repeat for other outputs
Reset after the last output
End condition

3.3.5 Controlling servo motors

Servo motors are usually equipped with an onboard driver. This simplifies control
as the microcontroller only has to specify the position using PWM control signals
applied via the control wires, the duty cycle of the PWM determines what position
the servo motor will take. The pseudocode of a basic servo control program:

25
Import GPIO libraries
Set PWM output
Set duty cycle and initiate PWM
change the duty cycle (if necessary)

3.3.6 Working with the RPi.GPIO library

There are several GPIO libraries available but RPi.GPIO is the default package
provided on a Raspberry Pi. It contains classes to control the GPIO pins.
RPi.GPIO offers two pin reference styles: board numbering (BOARD) scheme in
which the pin numbers follow the numbers on header P1 i.e., pin 1, pin 2 and so
on [3]. There is also the Broadcom chip-specific (BCM) pin numbers where pin
numbers follow the lower-level numbering system defined by the Raspberry Pi’s
Broadcom-chip brain. Few RPi.GPIO library functions are given below:

GPIO.setmode (GPIO, BCM) -- following BCM pin-numbering


GPIO.setmode (GPIO, BOARD) -- following BOARD pin-numbering
GPIO.setup ([pin], GPIO.IN) -- set pin as input
GPIO.setup ([pin], GPIO.OUT) -- set pin as output
GPIO.output ([pin], GPIO.high or GPIO.low or 1 or 0 or True or False)
Pwm = GPIO.PWM ([pin], [frequency]) – PWM analog output
Pwm.ChangeDutyCycle (75) --- change duty cycle
Include time; Time.sleep (0.25) --- delay for 0.25 seconds

3.4. IMPORTANCE OF STUDY


This study is facilitated by the need to elucidate on the interfacing problem
commonly encountered with interfacing actuators to raspberry pi boards and
provide control solutions specifically for motion actuators such as motors and

26
solenoids. Motors and solenoids are ubiquitous in most embedded and automated
processes. In automatic lock systems for example, a stepper motor can be used to
swing the door open and close or retract the frames in case of sliding doors. Such is
common in access control systems. Access control systems usually require a form
of authentication or verification which is used to selectively grant access [12]. This
is usually based on evaluation of some form of credential such as passcode, radio
frequency identification tag (RFID) tag, biometrics etc.

Evaluating credentials would require interfacing with devices that transform the
credential into readable form known as readers, and also a database of authorized
credentials. When a credential is read and authenticated, the lock is activated and
the door opens. Electric locks are employed in such cases which internally consist
of relays and solenoids. Raspberry pi is capable of performing credential
evaluation as explained above and even controls the locks and automatically opens
the door. This will provide some cost-saving as a dedicated microcontroller won’t
be necessary. Everything can be done with the pi module!

27
SECTION FOUR
4.0 CONCLUSION AND RECOMMENDATION
4.1 CONCLUSION
Raspberry pi can be used to control motion actuators such as electric DC motors of
different types and also activate relays to control actuators. It all depends on how
to interface such devices with the Raspberry Pi board for control and also to ensure
that it is provided with adequate power to operate. A lot of factors come into play
when controlling motion actuators. First is the choice of a driver. It is assumed that
the choice of motor or solenoid is based on the application in which it is to be used.
After choosing a motor or solenoid, interfacing it with Raspberry Pi would require
using an appropriate driver. This means, using a driver that will supply the voltage
and current needs of the actuator. Most drivers such as the L293D can operate over
a voltage range (4.5V to 36V) [3]. However, care must be taken about the current
demand. It is better to choose a driver with a high current-sourcing ability so as to
reduce overheating.

The second important factor is choosing a GPIO library among the pool of
available libraries. RPi.GPIO offers great advantages but is not suitable for real
time applications. WiringPi is another GPIO access library. Modeled after the
Arduino wiring system, it tries to bring the simplicity of arduino wiring to
Raspberry Pi. It is written in C language. GPIO Zero is learner friendly and is best
for learning purposes. Some factors to consider when choosing a GPIO library are:

● Type of application: What type of application is involved? RPi.GPIO is one


the fastest of all libraries but might not perform well in real time applications
due to runtime issues. The constraint of the application is necessary to
determi ne what GPIO library would be best to use.

28
● Support system: Libraries with great support systems are usually advised,
since one may run into issues while working with a library.
● Speed: How fast are library functions executed?

4.2 RECOMMENDATION

Raspberry pi is a great tool for embedded projects but its ability to perform in time-
critical applications is still beneath that of microcontrollers such as Atmel chips
and Arduino boards. A great deal of software and hardware improvements is rather
solicited in this area especially due to the widespread use and availability of
Raspberry Pi.

29
REFERENCES

[1] R. S. Burns, “Advanced Control Engineering,” Ed. Oxford: Butterworth-


Heinemann, 2001, pp. 1-7
[2] Niel Storey, “Electronics. A systems approach,” 6th ed., Ed. Edinburgh:
Pearson Education Limited, 2017, pp. 230 - 237
[3] M. Sustek, M. Marcanik, P. Tomasek, Z. Urednicek, “DC motors and servo-
motors controlled by Raspberry Pi 2B,” MATEC Web of Conferences, 2017
[4] E. Yilmazlar, V. Erdemir, H. Kuscu, Aydun Gallu, “Design Of Stepper
Motor Control Interface With Embedded Systems.” Vol. 14, pp. 17 - 22, June,
2018
[5] Electronics Tutorials Publishers, “Input/Output devices,” Available at:
https://www.electronics-tutorials.ws/io/io_7.html [Accessed 28 Aug. 2019]
[6] S. Yamanoor, S. Yamanoor, "Raspberry Pi Mechatronics Projects," Ed.
Birmingham: Packt, 2015, pp. 66 – 75
[7] Wikipedia contributors, “Raspberry pi,” Available at
https://en.m.wikipedia.org/wiki/Raspberry_Pi [Accessed 28 Aug. 2019]
[8] I. Buckley, "How to Program Raspberry Pi to control LED lights," Avaliable
at: https://www.makeuseof.com/tag/raspberry-pi-control-led/. [Accessed 22 Aug.
2019]
[9] M. D. Okoi, “10 Operating Systems You Can Run on Raspberry Pi in 2019”,
Avaliable at: htttp://www.google.com/amp/s/www.fossmint.com/operating-
systems-for-raspbery-pi/amp/. [Accessed 24 Aug. 2019]
[10] Electronic tutorials publishers, "Relay Switch Circuit," Avaliable at:
https://www.electronics-tutorials.ws/blog/relay-switch-circuit.html. [Accessed 24
Aug. 2019]
[11] Sam, "Motor Driver vs Motor Controller," Avaliable at: https://core-
electronics.com.au/tutorials/motor-drivers-vs-motor-controllers.html. [Accessed 24
Aug. 2019]
[12] A. D. Odu, M. C. Alice, and O. J. Odinya, “Low Cost Removable (Plug-In)
Electronic Password - Based Door Lock” Am. J. Eng. Res. 2017.

30

You might also like