Vous êtes sur la page 1sur 11

Chapter 13

Industrial Application
Industrial application using microcontrollers involves analog data processing and
control of electrical machines. Following figure shows the basic functional blocks
may be used to automate industrial process or applications.

Feedback Signal

System Under
Control

Analog
Control Signal

Electrical/
Electro-mechanical
Drive

ADC or
Signal Convarter

Analog Signal

Analog Input

Sensor /
Transducer

Digital Input

MPU/MCU

Digital Control
Signal

DAC or
Signal Convarter

From the above figure we can see that the two main interfacing parts are-

ADC for analog sensors


Electrical or electro-mechanical drive

13.1 Interfacing and programming ADC


ADC is a must to measure any analog voltage. All the analog sensors such as
temperature sensor, light sensor etc., produce equivalent voltage (or current in
some cases) as a measure of the sensed parameter. As 8951 does not contain
any ADC in it, we need to interface an ADC externally. The most common ADC is

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 1

the ADC080X. Where ADC0804 is an 8-bit single channel SAR (Successive


Approximation Register) type parallel ADC. ADC0808 is an eight channel version
of ADC0804. Following figure shows an ADC0804 connected with the 8951
MCU.

The analog voltage is applied to pin 6 and the result is available at pins 11
through 18. We will connect pin 1 and 2 (Chip Select and Read) to ground so that
the chip is always enabled. (If you wanted to use more than one ADC you could
use
this
pin
to
control
which
chip
is
currently
enabled).
Connect pin 7 (Vin-) to ground. The ADC0804 includes an internal oscillator
which requires an external capacitor and resistor to operate. Connect the 150 pF
capacitor from pin 4 (CLOCK IN) to ground and the 10k ohm resistor from pin 4
to pin 19 (CLOCK R). Here the ADC0804 is functioning in free-running mode. We
can also control the sampling rate by connecting the WR, INT and RD pins of the
ADC with other port pins, which is shown in the following figure.

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 2

Here the free running mode has been implemented for simplicity both in the HW
and SW. Detail operation of ADC0804 is out of scope of this chapter, pls., refer to
the datasheet of ADC0804.
Following example code can be used for free-running operation of ADC0804.
MOV A,P0

;saving data ADC to Accumulato

To use the ADC in programmable mode, we need to follow the following steps,
which are implemented in the following example codes.
-

Enable ADC0804 (optional, by using CS pin)


Start conversion by pulling down WR
Wait for end of conversion, polling INT pin
Read ADC value by pulling down RD pin
Disable the ADC0804 for power saving

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 3

rd equ P1.0
wr equ P1.1
cs equ P1.2
intr equ P1.3

;Read signal P1.0


;Write signal P1.1
;Chip Select P1.2
;INTR signal P1.3

adc_port equ P2
adc_val equ 30H

;ADC data pins P2


;ADC read value stored here

org 0H
start:
acall conv
acall read
mov P3,adc_val
sjmp start
conv:
clr cs
clr wr
nop
setb wr
setb cs
wait:
jb intr,wait
ret
read:
clr cs
clr rd
mov a,adc_port
mov adc_val,a
setb rd
setb cs
ret

;Start of Program
;Start ADC conversion
;Read converted value
;Move the value to Port 3
;Do it again
;Start of Conversion
;Make CS low
;Make WR Low
;Make WR High
;Make CS high
;Wait for INTR signal
;Conversion done
;Read ADC value
;Make CS Low
;Make RD Low
;Read the converted value
;Store it in local variable
;Make RD High
;Make CS High
;Reading done

13.2 Sensors
A sensor is a device that responds to a physical stimulus (as heat, light, sound,
pressure, magnetism, or a particular motion) and transmits a resulting impulse (a
signal relating to the quantity being measured). For example, certain sensors
convert temperature into a change in resistance. Following are some sensors-

LDR: Light dependent Resistor


Thermo-couple: produce voltage with rise of temperature
Temperature sensor (LM35, active temperature sensor)
Pressure sensor
Hall sensor: for magnetic field strength

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 4

Following figures show how to connect LDR and LM35 with an ADC.

13.3 Transducers
A transducer is a device that converts one type of energy to another. The
conversion can be to/from electrical, electro-mechanical, electromagnetic,
photonic, photovoltaic, or any other form of energy. While the term transducer
commonly implies use as a sensor/detector, any device which converts energy
can be considered a transducer.

13.4 Digital inputs


Digital input can be a digital voltage level and rising or falling edge of pulses.
These signals can be from any digital sensors like optical sensors, zero-crossing
circuits or from any switches. These pulses can be input to an interrupt pin,
external counter pin or any port pins. Third option requires extra code to retrieve

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 5

data from the pulse. Following figures show some pulse and switch connected
with the 8951 interrupt pin and port pins respectively.

13.5 Electrical, electro-mechanical drives


Drives are required to drive any electrical loads. Relays or solenoids are used to
switch on-off any high-power load like light, fan, motor etc. Sometime buzzer or
loudspeakers are also need to be drive using some power driver like BJT.
MOSFETS are also used to drive high-power DC load. Following figures show
some drive circuit with their load.

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 6

13.6 DC Motor control


DC motor control is a frequent application of MCU. There is various type of DC
motor used with MCU. We need to control their direction, speed or simply on and
off. We will discuss mainly two basic type of DC motor that can be interfaced with
MCU easily. The first one is a Permanent Magnet DC motor and the second one
is the Stepper motor. Following figures show the basic connection for speed and
direction control of PM-DC motor and Stepper Motor.

Figure showing the principle to control the direction of a PM-DC, which can be
done by changing the polarity. Following figure shows a circuit that can both
control the direction and speed of a PM-DC motor. Controlling speed of a PM-DC
motor can be done by controlling the applied voltage. To control the voltage we
can use simple PWM implemented in the MCU by SW or the Timer. The principle
of controlling the voltage is same as a buck-converter, where the RMS value
depends on the duty-cycle of the switching pulse, which is-

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 7

Vo=Vi (Ton/T)
Where, Ton is the on-time and T is the period of the switching pulse.

Following figure shows a circuit that uses a IC containing the bridge driver for the
PM-DC motor. This IC can also be used only for speed control of two PM-DC
motor.

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 8

Controlling of Stepper motor is little bit software dependent. We can use the
same bridge driver or the IC L293 to control the speed and direction of a Stepper
Motor. Stepper motor speed depends on the frequency of the switching pulse
rather than the pulse-width. Direction of the Stepper depends on the sequence of
the excitation of the coils. By changing excitation process from half-step to fullstep, speed can be increased twice.

13.7 AC Motor control


AC motor control by MCU is bit complicated, we can do it mainly by controlling
the applied voltage or by controlling the frequency of the voltage. The first way is
easier than the second way. The first one is SW intensive and the second one is
HW intensive
In the first way we need to control the switching angle of an AC-Switch (Triac or
SCRs) synchronously with the input voltage or the load current. Thus, we need a
zero crossing detector or a zero-current switching circuit with some SW control.

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 9

The second way requires multiple converter stages which are AC-DC converter,
DC-AC inverter. In this way we can control the speed by controlling the DC
voltage output of the first stage keeping the frequency fixed of the second stage.
Or, we can vary the frequency, while keeping the DC voltage fixed. By varying
both the DC voltage and the frequency of the AC output is also possible with
more advantages and complexity in the SW.
Some basic circuits for AC motor control are shown in the following figures.

Simple Zero crossing detector.

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 10

13.7 Robotics Application


Robotics application is completely based on MCU. Any robotic system consists of
following three basic parts-

Mechanical Structure and moving components


Sensors, drives and motors or hydraulics or pneumatics
Central control, intelligence and communication

The first part is out of the scope of this book. The second part is similar as
described in the earlier section of this chapter. The third part is mainly the SW
algorithm that is used to control the total system or functions of a Robot. For a
simple Robotic system like a locomotive, following algorithms are very common-

Obstacle detection by light sensors


Line follow by light sensors
Friction or obstacle detection using mechanical feedback
Color detection using color sensor
Linear motion control (also depends on mechanical design)

Other than the above control, some intelligence may also be required, which are
not in the scope of this book. Following figure shows a simple block of a Robot
implemented using 8951 MCU.

MMI (i51 Industrial application) - Ehsan ur Rahman

Page 11

Vous aimerez peut-être aussi