Top Banner
Technological Studies Systems and Control Students’ Notes Intermediate 2 5718
114

Technological Studies - st-pauls.ea.dundeecity.sch.uk

Apr 04, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological StudiesSystems and Control

Students’ NotesIntermediate 2

5718

Page 2: Technological Studies - st-pauls.ea.dundeecity.sch.uk
Page 3: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Summer 1999

DET:Technological

StudiesSystems and Control

Students’ NotesIntermediate 2

Support Materials������

HIGHER STILL

Page 4: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 1

TECHNOLOGICAL STUDIES

INTERMEDIATE 2

SYSTEMS AND CONTROL

STUDENTS’ NOTES

OUTCOME 1

Page 5: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 2

Page 6: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 3

Outcome 1 - Control Systems

The purpose of this unit is to introduce the operation of control systems.

When you have completed this unit you should be able to:

• recognise and identify common control systems• describe the operation of open and closed loop control systems• make use of systems diagrams and systems technology

Before you start this unit you should have a basic understanding of:

• Block diagrams

Page 7: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 4

IntroductionMany of the devices used in the home or in industry require an electronic controlsystem so that they can operate correctly. A room heater has to be able to switch itselfoff as the room heats up, an oven control’s it’s heating elements to maintain an eventemperature or a printer monitor’s its print cartridge and senses when it is empty.

Electronic control systems all contain the same basic elements, one or more real-worldinputs, one or more real-world outputs, and the signal processing sub-system. A simplesystem with one input and one output can be represented by the following blockdiagram.

,1387 ,1387

75$16'8&(5352&(66

287387

75$16'8&(5

287387

The Input Transducers could be simple digital on/off switches (e.g. a push switch),analogue sensors monitoring the control systems output (e.g. a temp sensor) or anyother sensor that the control system requires (e.g. a water pressure sensor).

The Process sub-system may be a simple circuit based around discrete componentssuch as transistors, or a more complicated system using logic gates ormicrocontrollers.

Motors, heating elements and lamps are all examples of Output Transducers. One ofthe most common output transducers in an electronic control system is a relay.

System DiagramsA complete control system can be represented by a systems diagram. A simple systemdiagram is shown below.

C O N TR O L O U TP U TD R IVERIN PU T O U TP U T

When applied to control systems, a Systems Diagram is a useful way of visuallyrepresenting the desired function of the system.

The systems diagram is a form of block diagram than contains all the subsystems withina dashed box, called the systems boundary. The systems boundary indicates theextent of the control system.

The "real world" input and output conditions of the system are shown as arrowsentering, and leaving, the systems diagram.

Page 8: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 5

Example

A product which has a fairly complicated control system is an automated washingmachine.

A simplified systems diagram of a washing machine is shown below.

C ONTR OLS ET W AS HING

C YCLE

C LE AN C OLDWATER

D IRTYC LO TH ES

H OT D IRTYWATER

C LE ANC LO TH ES

M O TORH EATER

D RUM

P UM P

The function of the washing machine is to process dirty clothes to produce cleanclothes. This is clearly represented within the systems diagram.

Page 9: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 6

Assignment 1

Draw system diagrams for the control systems used in the following devices.

a) A smoke alarm.

b) A drill.

c) A hairdryer.

d) The on/off control on a TV.

Page 10: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 7

e) The water heating system in a dishwasher.A temperature sensor detects when the water requires heating.

Assignment 2

Draw system diagrams for the systems described below.

a) A house alarm system with two door sensors, an arm key and a siren.

b) A temperature monitoring system where a warning lamp lights if the temperaturegets to cold or a lamp test switch is pressed.

� &

Page 11: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 8

Open Loop Control

At the simplest level a control system can process an input condition to produce aspecified output.

A good example of this type of system is a hand-held electric hairdryer. The heatingelement and fan motor are switched on when the appropriate switches are held down.

The system diagram for the hairdryer is shown below.

C O N T R O L O U T P U TD R IV E R

S W IT C HH E LD

D O W N

FA N & H E ATE RS W IT C H E D O N

This is an example of Open Loop Control, where an input is processed to produce anoutput. With the hairdryer example the heater and fan motor are held on until theswitches are released. The air being blown out of the hairdryer is not temperaturemonitored or adjusted - the air is simply just blown out at whatever temperature theheater is capable of achieving.

Page 12: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 9

Another example of an open loop system is an automatic street lamp.

The systems diagram for the street lamp is shown below.

C O N TR O L O U T PU TD R IVER

D ETEC TLIG H TLEV EL

SW ITC HLAM P

O N /O FF

Page 13: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 10

A model of the street lamp can be represented by the following circuit diagram:

V cc

0V

The input to the circuit, light, is processed by the control subsystem to produce anelectrical signal. In this example the potential divider arrangement provides a varyingvoltage signal.

Page 14: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 11

The electrical signal is processed by the output driver subsystem to produce theoutput. In this example the output is light from the signal lamp

An open loop control system represents the simplest and cheapest form of control.However, although open loop control has many application, the basic weakness in thistype of control lies in the lack of capability to adjust to suit the changing outputrequirements.

Page 15: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 12

Closed Loop Control

Closed loop control systems are capable of making decisions and adjusting theirperformance to suit changing output conditions.

Example 1

A personal cassette player is capable of detecting the end of the tape and switching themotor off, hence protecting the tape from snapping (or the motor burning out).

C O N TR O L O U TPU TD R IVER

EN D O FTAP E

Page 16: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 13

Example 2

The central heating in most modern houses is controlled by a thermostat. It senseschanges in temperature and turns off the heating system automatically when therequired temperature is reached. Likewise when the temperature level drops below theminimum acceptable level the heating system is automatically switched back on.

Assignment 3

Copy and complete the systemdiagram for the heating controlsystem.

TEMPCONTROL

SET TEMPLEVEL

Page 17: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 14

Assignment 4

A control system is used in a fridge to keepthe contents at a constant temperature.

For the fridge control system describedabove, copy and complete the systemsdiagram shown below.

TEMPCONTROL

Page 18: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 15

Feedback

All closed loop control systems include a feedback sensing subsystem within thesystems diagram. The control subsystem will process the feedback signal by making a'decision' on whether the state of the output should change.

C O N TR O L O U TP U TD R IVER

FEE D B AC KSE NS IN G

IN PU T O U TP U T

Negative and Positive Feedback

The purpose of closed loop control is to ensure that the output is maintained, asclosely as possible, to the desired output level. In the case of a central heating system,a graph of the temperature in a room might appear as in the graph below.

A C T UA L T E M P E RATU R E

S E T T E M P E R AT UR E

TEM

PERA

TUR

E

T IM E

As can be seen from the graph, the control system is constantly trying to pull thetemperature of the room back towards the set temperature level by reducing the error.This type of control uses negative feedback to reduce the error.

Page 19: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 16

M IC R O P H O N E A M P L IF IE R S P E A K E RA M P L IF IE D

S O U N DS O U N D

A M P L IF IE D S O U N D F E E D BA C K T O S P E AK E R

The opposite effect can be created by reinforcing the error, as can sometimes happenwith public address systems when the microphone is held too close to the speakers. Asound is picked up by the microphone, amplified, and then output through the speaker.The amplified sound is then picked up, re-amplified and so on. The net result is a highpitch sound, which can be represented by the graph below.

A CT U A L S O UN DS IG N AL

R EQ U IR E D S O U N DS IG N AL

S O U N DS IG N AL

T IM E

This is an example of positive feedback. Although positive feedback does have someuseful applications, negative feedback is far more widely used in control systems.

Assignment 5

Explain the following terms when applied to control systems:

a) control diagram, open loop, closed loop,b) negative feedback, positive feedback

Page 20: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 17

Assignment 6

Explain what is meant by the term 'systems diagram'.

Assignment 7

Describe the differences between an open loop and closed loop control system.

Assignment 8

Describe the purpose of the feedback sensing subsystem in a closed loop controlsystem.

Assignment 9

The figures above show two types of electric fire. The second electric fire is a moremodern device fitted with a thermostat.

a) Name the type of control system used in each type of electric fireb) Draw a system diagram for each type of electric fire.c) Name a type of electronic sensor that may used for measuring temperature.

Page 21: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 18

Control Diagrams

When working with control systems a control diagram is often used instead of a systemdiagram.

A heating control system can be represented by the following systems diagram.

C O N TR O L O U TP U TD R IV E R

T E M P E R AT U R ES E N S O R

S E TT E M P E R AT U R E

L E V E L

C O N S TA N TO U TP U T

T E M P E R AT U R E

The system diagram can be redrawn as a control diagram as shown below.

SET TEMPLEVEL

T EMPERAT URESENSOR

.

CONST ANTOUT PUT T EMP

OUT PUTDRIVER

COOLANTPUMP

+-

Page 22: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 19

Error Detection Symbol

This control diagram always includes the ErrorDetection symbol.

This symbol shows how the two signals, the set signal and the feedback signal, willbe compared.

If the feedback signal is higher the output is high.In the system above this would turn the coolantpump on when the sensor was warm.

If the feedback signal is lower than the set signal(+ve) the output is low.

If the feedback signal is greater the output is low.

If the feedback signal is lower than the set signal(+ve) the output is high.

In the system above this would turn the coolantpump on when it was already cold

Page 23: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 20

Assignment 10

A robot arm is to move to a set position.

When in the correct position a sensor will senda signal to the control system and stop the arm.

The control system is shown below.

MOVECOMMAND

POSIT IONSENSOR

.

ARMMOVEMENT

AMPLIFIER DRIVEMOT OR+

-

a) Describe what happens to the system as the arm actuates the position sensor.

b) Explain the function of the error detector.

Page 24: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 21

Assignment 11

For the control situations below draw a control diagram and state whether it is an openloop or closed loop system.

a) An automatic kettle.

b) A microwave oven turntable.

c) A water fill system in a dishwasher.

Page 25: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 1 22

Page 26: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 1

TECHNOLOGICAL STUDIES

INTERMEDIATE 2

SYSTEMS AND CONTROL

STUDENTS’ NOTES

OUTCOME 2

Page 27: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 2

Page 28: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 3

Outcome 2 – Common Applications of Control Systems

The purpose of this unit is to introduce common applications of control systems.

When you have completed this unit you should be able to:

• identify two state (on/off), continuous and sequential control systems• correctly identify the main sub systems of a control system• understand the difference between analogue and digital transducers• select appropriate input transducers for control applications• select appropriate output transducers for control applications• understand common applications of electronic control systems

Before you start this unit you should have a basic understanding of:

• System diagrams• Open and closed loop control

Page 29: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 4

CLOSED LOOP CONTROL

Closed Loop control can take three possible forms:1. Two State (on/off) Control.2. Continuous Control.3. Sequential Control.

Two State (on/off) Control Systems

Two State (on/off) control is used to control simple systems where output devices areto be switched on and off. A typical example is the safety switch often built into therear rubber bumper of modern lorries. If the lorry reverses into an object the switch isactivated, and automatically applies the brakes to stop the lorry.

Another typical two state (on/off) system is a light sensor at the end of a conveyer beltin a production line. When an object reaches the end of the conveyer belt it blocks thelight to the sensor, which then stops the motor so the object does not fall off the end ofthe conveyer belt.

Assignment 1.1

Describe two common devices that use two state (on/off) control. In each case explainwhy two state (on/off) control is appropriate for this type of device.

Page 30: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 5

Continuous Control Systems

Continuous control is used in control systems where the system is operationalcontinuously. A typical example is in a commercial greenhouse, where the temperatureis continuously monitored, and a heater is switched on if the temperature drops belowa certain level.

Example 1

A home security light uses continuous control.The PIR sensor continuously monitors to see if a person is moving in the area. When activatedthe security light switches on until no furthermovement is detected.

This is an example of continuous control.

Example 2

An Industrial Soldering machine hasto keep a bath of solder at a constanttemperature.

Sensors continuously monitor thesolder’s temperature and operates aheater when required.

This is an example of continuouscontrol.

SOLDERBATH

HEATER

TEMPSENSOR

CONTROLLER

CIRCUITBOARD

Page 31: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 6

Assignment 1.2

Describe two devices that use continuous control. Draw the systems using controldiagrams. Show the control system boundary.

Assignment 1.3

Traffic lights at a road junction follow a set sequence of operations. The traffic lightsdo not wait for a start signal but run continuously. The two sets of lights must becarefully programmed so that only one set shows ‘green’ at any time

This system would be described ascontinuous control.

Page 32: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 7

a) Complete the following table to show the correct light sequence for the twosets of lights.

Lights Set 1 Lights Set 2RedRed

Red and AmberGreenAmber

Red

b) Draw a control diagram for the system, clearly identifying all the sub-systems.

Page 33: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 8

Sequential Control Systems

Sequential Control is used to control systems whose outputs are required to follow afixed cycle of events (a sequence) when triggered.

Example 1

A robot arm used to weld car bodies on aproduction uses sequential control. Therobot arm once a car body is in positionfollows a set sequence of movements.

When finished that body is removed andthe robot repeats the sequence whenanother body is sensed.

Assignment 1.4

Draw a control diagram for a robot arm that welds the door frame into the car body.Clearly identify each of the sub-systems within the control diagram.

Example 2

A vending machine follows a preset sequence ofoperations when activated.

Depending on what has been requested then a cycleof operations start and can not be interrupted untilcompleted.

Assignment 1.5

Draw a control diagram for a vending machine. Clearly identify each of the sub-systems within the control diagram.

C ON TRO LLER

C ARS EN S OR

P op

F izzy

K olah

J uice

G inger

Y uk

Page 34: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 9

The Basic Stamp system can be used to run a sequential control system. The BasicStamp controller studied in the next section could be used to control the two examplesof sequential control above. The advantage of a programmable system is that the samerobot can be used to carry out different tasks simply by changing the software withinthe programmable controller. When using discrete electronics it is necessary tocompletely redesign the electronic circuit every time a new robot is required.

Assignment 1.6

The lights at a pedestrian crossing are an example of a sequential control system. Whenthe pedestrian pushes the switch beside the crossing a sequence of events starts.Complete the following table to describe this sequence of events.

Step 1 Wait warning light glowsRed Man warning light glows

Step 2 Green traffic light goes outAmber traffic light comes on

Step 3

Step 4

Step 5

Step 6

Assignment 1.7

Describe three common devices that use sequential control. In each case explain whysequential control is appropriate for this type of device.

Page 35: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 10

Assignment 1.8

For each of the systems described below:i) State which type of control system is used.ii) Draw a control diagram of the system.iii) Explain the purpose of each sub-system within the control diagram.

a) Placing bottle tops on bottles on a production line.

b) Domestic heating system running off a time clock.

c) Pelican crossing.

d) Temperature monitoring system on an aircraft engine.

e) A modem connecting a computer to the Internet.

f) A set of flashing Christmas tree lights.

Page 36: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 11

TRANSDUCERS

Any electronic control system can be broken down into three distinct parts

AE.Int2.O2.fig1

The input and output parts must ‘interface’ with the real world

A transducer is a device that converts one form of energy into another e.g. amicrophone is a transducer that changes Sound Energy into Electrical Energy.

Output TransducersOutput transducers in electronic systems are used to convert Electrical Energy intoanother form that can be detected by the user or used in some other way.

Common Output TransducersThe table gives some examples of common output transducers that you may have metbefore.

Output Transducer Output Energy

BulbLampLED

Light

BuzzerLoudspeaker

Earphone

Sound

MotorPump

Solenoid

Movement

Heating element Heat

Page 37: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 12

Examples of Common Output Transducers

At the output of an electronic system the output transducer converts the electricalsignal in to some other useful form of energy such as heat, light, sound or mechanicalenergy.

Electric Motors

Electric motors convert the electrical signal into rotational kinetic energy. Before amotor is connected to a circuit it is necessary to know the characteristics of the motorin terms of working voltage and the maximum current to be drawn by it in order todetermine the correct choice of driver. The most common and likely choice to drive amotor from an electronic circuit would be the relay.

Solenoids

The solenoid consists of a magnetic core that is free to move position inside a coil.When current flows through the coil and it is energised, the magnetic core is pulledinto the centre of the coil (along the coil axis). This converts the electrical signal intolinear motion. A solenoid is used when in and out motion is required. Solenoidsrequire very large currents in order to produce meaningful force and they are usuallyswitched on and off by using relays.

AE.Int2.O2.fig1c - Circuit symbol for a solenoid

Page 38: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 13

Relay

The relay is not strictly speaking an output device but a switch that can be driven bythe output from an electric or electronic circuit. It is an electromechanical deviceconsisting of two main parts - the operating coil (which is essentially a solenoid) andthe contacts.

AE.Int2.O2.fig1a

DIL REED RELAY

Page 39: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 14

AE.Int2.O2.fig1b - Circuit symbol for a relay

An electric current is sent through the coil that energises it. The coil becomesmagnetic and it attracts a spring-loaded armature that moves the contacts together(Energised position). Switching the supply off to the coil causes the relay to re-set tothe normal (de-energised) position.These contacts can then be used to switch on a very powerful circuit or a number ofcircuits.The relay is a very useful device and is particularly useful for energising devicesthat require substantial amounts of current. It is perhaps the most commonly usedswitch for driving devices that demand large currents.

Two relay circuits are shown below.

SPSTsingle pole single throw

DPDTdouble pole double throw

The SPST is used for any simple control system e.g. controlling a lamp, turning aheating element on etc.

A DPDT relay is ideal for controlling a motor. As can be seen below the motor canrun backwards or forwards.

�Y�Y

,QSXW 6LJQDO

)URP 'ULYHU

02725

V 9 V

�Y �Y

,QSXW 6LJQDO

)URP 'ULYHU

9V

Page 40: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 15

A typical relay will require 6V and approximately 60mA to switch.

Analogue & Digital Input Transducers

An analogue signal uses the full voltage range. A signal from a circuit with an LDR(light sensor) may vary from 0 to 5V.

A digital signal is much simpler and can only have two voltages. OV (logic0) or 5V(logic1). A push switch gives a digital signal.

�Y�Y

,QSXW 6LJQDO

)URP 'ULYHU

02725

V 9V

�Y�Y

,QSXW 6LJQDO

)URP'ULYHU

02725

V 9V

92/7$*(

7,0(

�9

�9

/,*+7

'$5.

VOLT AGE

T IME

5V

0V

Page 41: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 16

Input TransducersInput transducers convert a change in physical conditions (e.g. temperature) into achange in an electrical property (e.g. voltage) which can then be processedelectronically to produce either a direct measurement of the physical condition(Temperature in oC) or to allow something to happen at a predetermined level (e.g.switching on the central heating at 20 oC).

Common Input TransducersThe table gives some examples of common input transducers that you may have metbefore.

Physical condition to bemonitored

Input Transducer Electrical property thatchanges

TemperatureThermistor

ThermocouplePlatinum Film

ResistanceVoltage

Resistance

LightLDR

Selenium CellPhoto Diode

ResistanceVoltage

Resistance

DisplacementSlide Potentiometer

Variable TransformerVariable Capacitor

ResistanceInductanceCapacitance

Force Piezo electric crystal Voltage

Angle Rotary Potentiometer Resistance

It can be seen that electrical properties that change fall into three groups

1. Transducers that produce voltage.2. Transducers that change the value of resistance.3. Transducers that change either the value of inductance or capacitance.

Changes in the resistance of an input transducer are usually converted to changes involtage before the signal can be processed. This is normally done using a voltagedivider circuit.

Page 42: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 17

Examples of common Input Transducers

The switchWe all make use of switches every day. We use them to turn on lights, personalstereos, hairdryers and numerous other devices. A switch in it’s simplest form is usedfor making and breaking an electrical circuit and it usually contains metal contactswhich when touching allow current to flow.

Switch typesThere are several ways in which the contacts in mechanical switches can be operated.Some are push button, toggle, slide or magnetic (reed), tilt and electromagnetic relay.

Switches are wired up to suit their application. A switch with it’s contacts apart whenit is not operated is called a normally open switch.

These switches are “digital” input devices as they can only be on or off.

7RJJOH6OLGH

.H\ 7LOW

5RFNHU 3XVK %XWWRQ

5HHG

The switches shown above are all single pole with single or double throws. These areknown as SPST and SPDT switches. The symbols are shown overleaf.

Page 43: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 18

AE.Int2.O2.fig2

Notice that the switch consists of two parts, a pole and a contact. This switch iscalled a single pole single throw switch (SPST). It is given this name because itssingle pole can be thrown into contact in one position only.

Three further commonly used switch layouts are given below.

AE.Int2.O2.fig3

AE.Int2.O2.fig4

AE.Int2.O2.fig5

Page 44: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 19

Variable Resistor (Potentiometer)

A potentiometer or variable resistor can be used in a circuit either as a voltage orcurrent control device.

AE.Int2.O2.fig5a

Potentiometers normally have three tags, the outer ones being connected to the ends ofthe resistive material and the centre one the wiper.The spindle of the potentiometer is connected to the wiper, which is able to traversefrom one end of the resistance to the other when the spindle is rotated. As the spindlerotates a sliding contact puts more or less resistive material in series with the circuit.

Page 45: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 20

Light Dependent Resistor (LDR)

The LDR (sometimes called a photoresistor) is a component whose resistance dependson the amount of light falling on it. It’s resistance changes with light level. In brightlight its resistance is low (typically around 1K). In darkness its resistance is high(typically around 1M).

The circuit symbol and typical characteristics are shown below.

AE.Int2.O2.fig6

AE.Int2.O2.fig50 - Graph of Illumination / Resistance

Page 46: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 21

Thermistors

A Thermistor is a device whose resistance varies with temperature. It is a temperaturedependent resistor. There are two main types:1. Positive temperature coefficient (+t) or (ptc) - where resistance increases as

temperature increases.2. Negative temperature coefficient (- t) or (ntc) - where resistance decreases as

temperature increases.

The circuit symbol and typical characteristics are shown below.

AE.Int2.O2.fig7

AE.Int2.O2.fig8

Page 47: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 22

AE.Int2.O2.fig51 - Graph of Temperature / Resistance

Strain Gauges

These are really load sensors. They consist of a length of resistance wire and whenstretched their resistance changes. Strain gauges are attached to structural membersand as they are loaded you can obtain a reading on a voltmeter.

AE.Int2.O2.fig9

Page 48: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 23

Criteria for selecting transducers

Once the physical condition to be monitored and the output requirements of the systemhave been identified, a choice of transducers has to be made. A number of differentcriteria may need to be taken into account, some of which are listed in the table below.

Response Time Most transducers are required to respond to the change inconditions. If changes occur quickly, a transducer with a fastresponse time may be required.

Linearity This is especially important when using transducers inmeasuring instruments

SensitivityIf changes in physical conditions produce only small changesin the electrical properties of an input transducer, then adifferential amplifier (covered in later units and at Higher)may be required to amplify the small changes before furtherprocessing can take place.

Physical Size This may be an important criterion dependent on the systemthe transducer is to be placed in. (e.g. a loudspeaker may beinappropriate as an output transducer for a personal stereo).

Robustness This may be dependent on the environment that thetransducer is exposed to ( or the users will be exposed to)

Accuracy Accuracy of the transducer could be of the utmostimportance in some situations.

Repeatability The ability of a transducer to consistently reproduce thereading for the same conditions.

Cost Given all the above, is the transducer cost effective for theapplication?

Full technical details of transducers and all electronic components are contained inmanufactures data sheets and increasingly in catalogues. (RS Components supply arange of data sheets plus the RS Catalogue on CD-ROM. The CD-ROM contains

Page 49: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 24

product technical details as well as data files in pdf. format that can be easily accessedand printed off if hard copies are required.)

Page 50: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 25

Assignment 2.1

Name the transducers that would be used in the situations below.State whether the transducer is analogue or digital.

a) Streetlight daylight sensor. b) Sensing the angular position of a robot arm. c) Counting components on a fast moving conveyor (non-contact). d) Control the movement of a lift. e) Sensing the high temperatures in an exhaust manifold. f) Sensing the temperature in a home freezer. g) Heating water.

h) Sensing lift doors are fully open. i) Driving a pump in a heating system. j) Setting sound levels in a recording studio.

k) A car alarm sensing the door is shut.

Page 51: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 26

Using Transducers

Assignment 2.2

Use the course Data Book for this assignment. All thermisters refer to type 256-045.

a) Lux indicates the light level. The higher the lux value then the brighter the light.

i) Use the graph in the data book to find the resistance of an LDR at 800 lux.

ii) Describe what happens to the resistance as it gets darker.

b) i) From the graph in data book find the resistance of the thermister at 120° C.

ii) Describe what happens to the resistance as the temperature increases.

c) Give the resistance for the following values. Use the graphs in the data book.

i) Thermistor at 0° C

ii) LDR at 2000 lux.

iii) Thermistor at 60° C.

iv) Thermistor at -20° C.

v) LDR at 30 lux.

vi) LDR at 570 lux.

Page 52: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 27

Assignment 2.3

Use manufacturers data sheets to answer the following questions

1. A kiln used in a brick making process has to heat the bricks to a temperature of600 0C. Which temperature input transducer would be most suitable formonitoring the kiln temperature and why?

2. A photographer wants to time how long his flash light bulb comes on for when he

takes a photograph. To do this, he connects a light sensor to a timer as shownbelow.

AE.Int2.O2.fig10 With reference to appropriate manufacturers data sheets, decide which of the following

light input transducers would be most suitable and why: - LDR, Selenium cell, andphoto diode.

3. Most computers use LED’s as indicators to show various conditions. Why are

LED's used in preference to normal filament bulbs?

Page 53: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 28

INPUT SIGNALS

Voltage divider Circuits

If an input transducer changes it’s resistance as the physical conditions change, thenthe resistance change has to be first converted into a voltage change before the signalcan be processed. This is normally done by using a voltage divider circuit.

If two or more resistors are connected in series (see figure 11 below), the voltage overeach resistor will depend on the supply voltage and the ratio of the resistances.

Voltage divider circuits work on the basic electrical principle that if two resistors areconnected in series across a supply, the voltage load across each of the resistors will beproportional to the value of the resistors.

AE.Int2.O2.fig11

The layouts of voltage divider circuits are conventionally represented as shown abovein fig 11.There are a number of different ways that a voltage divider circuit can be represented.Some of these are shown in fig 12

Page 54: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 29

AE.Int2.O2.fig12

These three diagrams each represent the same circuit, in slightly different form.This should not be a cause for concern since all that has occurred is that the diagramhas been rotated around on it’s side. As we progress through this section and ontomore advanced circuits, it will become apparent to you why these circuits arepositioned as they are.

Consider fig 11

Increasing the value of one of the resistors will increase the voltage drop across it.(You can use Ohm’s Law to confirm this if you wish).

When monitoring physical conditions, one of the resistors in the circuit is an inputtransducer, the resistance of which will change depending on the physical conditions.

In general to calculate the voltage across any resistor in a series circuit, we can use theequation

Page 55: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 30

Voltage across resistor R = Supply Voltage x (size of resistor R/ Total resistance)

For fig 11

V VccR

R R2

2

1 2= ×

+

Worked Example

Calculate the voltage signal, V2 across the resistor R2, in the voltage divider circuitshown.

AE.Int2.O2.fig 13

Applying the voltage proportion formula

V VccR

R R2

2

1 2= ×

+

V 2 1240

40 80= ×

+

V V2 4=

The voltage over the 80K resistor could be calculated in the same way, but this isunnecessary for this circuit since we can use Kirchoff’s 2nd law to confirm the answer.i.e. the voltages over each of the components in a series circuit must add up to thesupply voltage, hence the voltage over the 80K resistor is 12V - 4V = 8V.

It is also possible to continue to use Ohm’s law to solve these voltage dividerquestions. You may choose whichever method you are most comfortable with.

Page 56: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 31

Obtaining a signal voltage from a voltage divider circuit

If we were to replace one of the fixed resistors in a voltage divider circuit with ananalogue sensor, e.g. a Thermistor, we would now have a system which generates asignal voltage which is proportional to the change in the physical environment, in thiscase temperature. If you look at the E & L or Alpha analogue input boards you willfind that this is the method used to generate signal voltages.

AE.Int2.O2.fig 13a

Vsig changes in proportion with the resistance of the Thermistor Rth.

The Thermistor in fig 13a can be replaced by any analogue sensor e.g. the LDR andwill generate a signal voltage proportional to the resistance of the sensor.

Page 57: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 32

Assignment 2.4

Using the formula described above, calculate the voltages that would appear acrosseach of the resistors marked “X” in the circuits below.

1. In each of the following voltage divider circuits determine the unknown quantity.

AE.Int2.O2.fig16

10k

27k

22k

18k

3k9

6V9V 6 V

3k3

9V 16V 9V

12R

9R

39R

12R

15V

4k

8k2 150R

180R 2k2

Page 58: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 33

Assignment 2.5

1. A ntc (negative temperature coefficient) Thermistor is used in a voltage dividercircuit as shown in fig 17. Using information from the graph shown, determine theresistance of the Thermistor and hence calculate the voltage that would appearacross it when it is at a temperature of a) 80 0C b) 20 0C

AE.Int2.O2.fig17 2. What would happen to the voltage across the Thermistor in the circuit shown in fig

17 as the temperature is increased? 3. What would happen to the voltage across the resistor in the circuit shown in fig 17

as the temperature increases? 4. A Thermistor (type 5) is used in a voltage divider circuit as shown in fig 18. The

characteristics of the Thermistor are shown in the graph. If the voltage V2 is to be4.5V at 100 0C, determine a suitable value for R1.

State whether the V2 will increase or decrease as the temperature drops. Explain youranswer.

Page 59: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 34

AE.Int2.O2.fig18

Page 60: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 35

Sensing circuits

Light sensors

Assignment 2.6

Obtain the relevant components and equipment then construct the light sensing circuitshown in fig 19.

AE.Int2.O2.fig 19

In normal light conditions, measure and record the voltage across the LDR and thefixed 10 K resistor.Cover the LDR, repeat the measurements and record them.

You should have found in this circuit configuration that the resistance of the LDRincreases as the light level decreases, so in this case the signal level (Vout) will rise asit gets dark.

Change the position of the LDR and the fixed resistor as shown in fig.20.

AE.Int2.O2.fig 20

Repeat the measurements taken on the first circuit record these.

You should have found that changing the position of the LDR and the fixed resistorallows the signal to change in the opposite direction i.e. the signal level will rise as itgets light.

Page 61: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 36

Temperature sensors

This is a very similar arrangement to light sensing and like the light sensing circuits,temperature sensing circuits can be arranged to produce a signal to move in theopposite direction when the same temperature change is applied.

Assignment 2.7

Obtain the relevant components and equipment then construct the light sensing circuitshown in fig 21. Use a type 3 Thermistor (TH3).

AE.Int2.O2.fig 21

In normal room temperature conditions, measure and record the voltage across theThermistor and the fixed resistor.Apply heat to the Thermistor and repeat the measurements and record them.

Try reversing the positions of the Thermistor and the fixed resistor. Record whathappens.

Page 62: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 37

TRANSDUCER DRIVERS

As the output transducers often require a large current or voltage to enable them towork, most control systems require a driver sub-system.

The following are all signal amplifiers and can be used to drive transducers. -

bi-polar transistor darlington driver field effect transistor FET

Bi-polar Transistor

The diagram shows a bi-polartransistor in a circuit diagram.

The 1K resistor is known as the base resistor. The base resistor is used to limit thecurrent going into the transistor. The current going into the base is known as the basecurrent. Without the base resistor the base current could be too large and damage thetransistor.

The base resistor value depends on the other components values in the circuit. For thework we are doing 1K is generally a suitable value.

As the thermister cools down the basevoltage increases. When the basevoltage reaches 0.7V the transistorswitches on.

OUTPUT DRIVER

INPUTTRANSDUCER

OUTPUTTRANSDUCER

6V

0V

1K

OUTPUT

6V

600K

129K

0V

1K

OUTPUT

BASEVOLTAGE

BASECURRENT

Page 63: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 38

Transistors in Control Systems

Many simple control systems require the output to be either fully ON or fully OFF.

If a transistor is used as an amplifier in these control systems then it must behave as aswitch.

Activity 3.1

Select the components and construct the circuit below, or use circuit simulationsoftware. The transistor to be used is a BC108 or BC548B, look up componentsuppliers catalogues and record its hFE value.

The bulb should switch on at 100 lux - LDR at 1000 ohms.

In this circuit the transistor is behaving as a switch.

The transistor is tending to operate as full ON or full OFF.

BASECURRENT

6V

1K

200R

BC108

0V

1K

Page 64: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 39

Activity 3.2

Alter the circuit in activity 3.1 as shown below and test its performance.

Again the bulb has to switch on at 100 lux.

1) For the above circuit measure and record the base current, Ib.

2) What is the required current for the bulb to be full on. The current flowing throughthe bulb is known as the collector current (Ic). (See Data Table).

3) Measure the actual Ic in your circuit.

4) Why does the bulb not light?

The hFE is the gain of the transistor. From your recordedvalues of Ib and Ic what is the hFE required for the abovecircuit to work.

How does your calculated hFE compare with the hFE you recorded for the BC108 atthe start of activity 3.1.

6V

1K

7KIc

0V

1K

h IcIbF E =

Page 65: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 40

Activity 3.3

Modify your previous circuit as shown below.

Use component suppliers data tables to find the gain of the BC108 and the BFY51

Measure Ic in this circuit.

Ic is much greater and now high enough to make the bulb light.

This type of transistor configuration is known as a Darlington pair or driver.The gain is found by multiplying the hFE’s together.

Calculate the total gain of this circuit.

hFEtotal = hFE1 x hFE2

�9

�.

�.

% F���

% )<��

�9

�.

Page 66: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 41

Developing a Transistor Based Control System

A simple transistor based control system can be developed by following the stepsbelow.

a) Develop the potential divider circuit.

b) Add a base resistor.

In the circuit above R would be a quite a large resistor so the base current will be small. A base resistor will not be required.

In a circuit like the one shown, if the LDR was in bright light, it would have a very low resistance. The base current could be very high and a base resistor would be required.

5

��.�

�9

�9

���9

S IG N A LV O LTA G E

5V

0V

Page 67: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 42

c) Calculate the base current.

If the base current is too big use alarger base resistor.

d) Find the current required for the output transducer. This is the required collectorcurrent (Ic). Look these values up in data tables.

e) Calculate the current gain of the transistor required.

f) Select a suitable transistor from data tables.

It should have a suitable gain (hFE) and it’s maximum collector current (Ic) should be greater than required.

6V

600K

0V

1 K

OUTPUT

0.7V

BASECURRENT

I VR R

b ccb

= −+

0 71

.

h IcIbF E =

Page 68: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 2 43

Assignment 3.4

Draw system diagrams then develop a transistor based electronic control circuits forthe four control systems described below.

The current required to drive the output transducers can be found in the data tables.

Use simulation software to check you circuit design.

a) An experiment monitors the temperature of a chemical solution. If the temp reaches120°C then a buzzer which operates on 6V and requires 25mA is to switch on.Make the supply voltage 6V.

b) A water temperature sensor in an electric shower is to cut off the power to theheating element if it becomes too high for safety. Determine a suitable cutofftemperature. When reached a relay is to be switched to cut power to the heatingelement. Investigate the Ic value required to operate the relay.

c) An automatic street light is to switch itself on when it gets dark at night Determinea suitable light level when it should switch on the relay which will control the lamp.

d) As the outside temperature drops to 3°C an ice warning lamp is to light on a cardashboard.

HEAT TEMPSENSOR DRIVER BUZZER

SOUND

Page 69: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 1

TECHNOLOGICAL STUDIES

INTERMEDIATE 2

SYSTEMS AND CONTROL

STUDENTS’ NOTES

OUTCOME 3

Page 70: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 2

Page 71: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 3

Section 1 - Introduction

The purpose of this section is to introduce the microcontroller and it's architecture.

When you have completed this section you should be able to:

• describe the operation of microcontrollers• understand the terms ALU, RAM, ROM, EEPROM, bus• understand how the Basic Stamp system operates

Before you start this section you should have a basic understanding of:

• No previous knowledge required.

To complete the exercises in this section you require:

• No equipment required.

Page 72: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 4

Section 1 - Introduction

What is a microcontroller?

A microcontroller is often described as a 'computer-on-a-chip'. Microcontrollers havememory, processing units, and input/output circuitry all built into a single chip. As theyare small and inexpensive they can easily be built into other devices to make theseproducts more intelligent and easier to use.

Microcontrollers are usually programmed to perform one specific control task - forinstance, a microwave oven may use a single microcontroller to process informationfrom the keypads, display user information on the seven segment display, and controlthe output devices (turntable motor, light, bell and magnetron).

Microcontrollers are computers designed to control specific processes or products.The microcontroller is programmed with a specific software program to complete thedesired task. By altering this software program the same microcontroller can be usedto complete different tasks. Therefore the same device can be used in a range ofdifferent products by simply programming it with a different software program.

Page 73: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 5

One microcontroller can often replace a number of separate parts, or even a completeelectronic circuit. Some of the advantages of using microcontrollers in a productdesign are:

• increased reliability and reduced stock inventory (as one microcontroller replacesseveral parts)

• simplified product assembly and smaller end products• greater product flexibility and adaptability since features are programmed into the

microcontroller and not built into the electronic hardware• rapid product changes or development by changing the program and not the

electronic hardware

Applications that use microcontrollers include household appliances, alarm systems,medical equipment, vehicle subsystems, and electronic instrumentation. Althoughmicroprocessor systems (such as those based around the Intel Pentium™ processor)tend to be more widely publicised (mainly via personal computer systems),microcontroller manufacturers actually sell hundreds of microcontrollers for everymicroprocessor sold.

Page 74: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 6

Microcontroller Architecture

The main features of the microcontroller are shown in the block diagram.

'$7$

%86

352*5$0

%86

520

352*5$0

0(025<

352*5$0

&2817(55$0

5(*,67(5

),/(6

,�2

32576

7,0(56

$/8

&/2&.

´5($/µ

:25/'

6,03/,),(' 3,& 0,&52&21752//(5

%/2&. ',$*5$0

Microcontrollers contain all these features within a single package, as opposed to themicroprocessor system where each block in the diagram above is normally a separateintegrated circuit. In general the only component that needs to be added to amicrocontroller is a clock resonator, which sets the operating speed of themicrocontroller.

Arithmetic / Logic Unit (ALU) and ClockThe processing unit (full name arithmetic and logic unit (ALU)) is the 'brain' of themicrocontroller. It operates by reading instructions from the read only memory ROM(permanent program memory) and then carrying out the mathematical operations foreach instruction. The speed at which these operations occur is controlled by the clockcircuit.

The clock circuit within the microcontroller 'synchronises' all the internal blocks (ALU,ROM, RAM etc.) so that the system remains stable. The clock circuit is built into themicrocontroller, but an external crystal or resonator is required to set the clockfrequency. A typical clock frequency for use with a microcontroller is 4MHz, butspeeds as high as 20MHz can also be achieved. With a clock frequency of 4MHz themicrocontroller completes one million instructions a second!

Page 75: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 7

Memory (ROM and RAM)Microcontrollers contain both ROM (permanent memory) and RAM (temporarymemory).

The ROM (Read Only Memory) contains the operating instructions (i.e. the 'program')for the microcontroller. The ROM is 'programmed' before the microcontroller isinstalled in the target system, and the memory retains the information even when thepower is removed. Most microcontrollers are one-time-programmable types, whichmeans the ROM can only be programmed once. If you make a mistake, and have tochange the program, the chip has to be thrown away and a new chip programmed withthe revised program. To overcome this problem some microcontrollers now useFLASH EEPROM memory instead. This type of 'erasable-permanent' memory allowsthe ROM to be re-programmed if a mistake is made.

The RAM (Random Access Memory) is 'temporary' memory used for storinginformation whilst the program is running. This memory is 'volatile', which means thatas soon as the power is disconnected the contents of the memory is lost.

Buses.Information is carried between the various blocks of the microcontroller along 'groups'of wires called buses. The 'data bus' carries the 8-bit data between the ALU and RAM/ Input-Output registers, and the 'program bus' carries the 13-bit program instructionsfrom the ROM.

The size of the data bus provides a description for the microcontroller. Therefore an '8bit microcontroller' has a data bus '8-bits' wide. Microcontrollers with 16-bit and 32-bitdata buses are also available.

Input/Output CircuitryMicrocontrollers communicate with the outside world via pins which are groupedtogether in 'ports', with up to eight pins in each port. Smaller microcontrollers mayonly have one port, whilst larger devices may have five or more. Generally each pinwithin the port can be configured as an output or as an input, or can even bemultiplexed to change functions as the program is run!

The CMOS fabrication techniques used to build modern microcontrollers provides arelatively high current capability (approx. 20mA) for each pin. However further'interfacing' circuits are required for most output devices.

TimersMost microcontrollers have one or more 'timers' built into the system. The 'watchdogtimer' is the most common type of timer. This is a special timer that 'resets' themicrocontroller if it stops processing for any reason (e.g. a 'bug' in the program). Thisensures that the microcontroller continues working at all times - which is essential insome applications, for instance medical monitoring equipment.

Page 76: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 8

Understanding the Basic Stamp System

In industry microcontroller programs are normally developed using the 'assembler' or'C' programming languages. Unfortunately these languages are not particularly easy forthe beginner to understand, and it can take a great deal of time and study before aprogrammer is skilled enough to construct a complex program.

For this reason it is easier for the beginner to program with 'user friendly' languagessuch as BASIC (Beginners' All Purpose Symbolic Instruction Code). This language isspecifically designed to be 'easily understood' and so primarily uses standard 'Englishlanguage' words as instructions. However, before the microcontroller can understandthe BASIC instructions, these instructions must be processed by an 'interpreter' intomachine code assembler. The extra processing time involved in this conversion resultsin a BASIC program running slower than an equivalent machine code assemblerprogram. However, as microcontrollers can process over one million assembler codeinstructions a second, the extra processing time required by the BASIC program isnegligible in most cases!

The 'Basic Stamp' system was developed in the early 1990s (by Parallax, Inc., USA) toenable design engineers to quickly prototype systems using microcontrollers byprogramming in a modified BASIC language (called PBASIC - short for ParallaxBASIC) rather than assembler or C. The Basic Stamp system is an ideal compromisefor rapid prototyping - all the power and versatility of a microcontroller combined witha simple programming language.

Page 77: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 9

The 'Basic Stamp' system consists of three main components - the 'Basic Stamp'software, a download cable and the Stamp module itself. The Stamp module containstwo main integrated circuits - a PIC microcontroller pre-programmed with thePBASIC interpreter, and an EEPROM memory chip.

'2:1/2$' &$%/(+267 &20387(5

5811,1*

67$03 62)7:$5(

%$6,&

,17(535(7(5

&/2&.

((3520

,1387�2873873,16

The program instructions are written on a host computer in the simple PBASIClanguage. The download cable is then connected from the computer to the module, andthe program is downloaded into the EEPROM memory chip. The download cable isthen removed, and the program (now stored in the memory chip) is carried outsequentially by the microcontroller 'interpreter' chip.

Therefore the primary difference between programming standard microcontrollers andprogramming the Basic Stamp is that, when you 'download' a program to the BasicStamp, you are actually programming the external EEPROM, rather than themicrocontroller ROM. However when you build electronic systems you are stillconnecting directly to the 'microcontroller' input/output pins, and so the electronicconnections are identical to those made to standard microcontrollers.

The original Parallax Basic Stamp module consisted of a small printed circuit board(PCB) with battery clip and 'prototyping areas'. Although suitable for prototypingwork, this module is not so appropriate for classroom exercises, and so the StampController has been developed for educational use. This uses identical 'chips' to theoriginal module, but is configured on a larger PCB with all the necessary connectorsetc.

Page 78: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 10

The memory chip used on the Stamp Controller to store the program is the EEPROMtype. This type of memory can be reprogrammed when desired, but also retains theprogram when the power supply is removed. This means the Stamp Controller willstart to run the program currently in memory whenever the power supply is connected.

Summary - Programming Procedure.1. Write the program on a host computer using the Stamp software.2. Connect the download cable from the computer to the Stamp Controller.3. Connect the power supply to the Stamp Controller.4. Use the Stamp software to download the program. The download cable can be

removed (if desired) after the download.

The program will start running on the Stamp Controller automatically. However theprogram can also be restarted at any time by pressing the reset switch.

Page 79: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 11

Assignments:

1.1) List the advantages of using a microcontroller within a product design.1.2) Describe the input sensors and output transducers that may be linked to a

microcontroller in the following common household appliances:- microwave oven- washing machine- electronic bicycle speedometer

1.3) Explain the following microcontroller terms: ALU, bus, clock1.4) Explain the differences between the following types of memory:

- RAM, ROM, EEPROM1.5) Describe the similarities and differences between programming, and

constructing interfacing circuits for, a 'true' microcontroller and the 'BasicStamp' system.

Page 80: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 12

Section 2 - Number Systems

The purpose of this section is to introduce the main number systems used withinprogrammable systems for the processing of information.

When you have completed this section you should be able to:

• Use the following terms correctly: decimal, binary.• Describe contexts when it is appropriate to use the two different number systems.• Convert between decimal and binary number systems.

Before you start this section you should have a basic understanding of:

• No previous knowledge required.

To complete the exercises in this section you require:

• No equipment required.

Page 81: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 13

Number Systems

A microcontroller operates by performing a large number of mathematical calculationsin a very short space of time. This is possible because each piece of information can beexpressed as a series of electronic signals. These signals are recognised as being in oneof two states, which are described as high and low (or "on" and "off").

The counting system used in everyday activities is the decimal system. This numbersystem uses the ten familiar digits 0 to 9 to express the magnitude of the number.

However, as the microcontroller only recognises the two electronic states high andlow, it uses the binary number system. This number system uses just two digits 0 and1. An electrical signal which is low is represented by 'logic 0', and a signal which ishigh is represented by a 'logic 1'.

The first sixteen numbers in the decimal and binary systems are shown in the tablebelow:

decimal binary0 00001 00012 00103 00114 01005 01016 01107 01118 10009 1001

10 101011 101112 110013 110114 111015 1111

A single binary digit is referred to a bit (binary digit). Different systems carry outcalculations using different quantities of bits, and so systems are often referred to as 8-bit, 16-bit or 32-bit systems. The most common microcontrollers use the 8-bit system,although 32-bit microcontrollers are also now becoming more readily available.

Page 82: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 14

Notation

When using a number of different counting systems it is important to distinguish whichcounting system you are using. For instance the number '10' means different values inthe two different counting systems!

Therefore the following notations are used within PBASIC programs:

Decimal values are written as usual: 10 ( = 10 in decimal)Binary values are preceded by a % symbol: %10 ( = 2 in decimal)

Bits and Bytes

Eight bits grouped together are described as a byte. The decimal value of a byte iscalculated by adding together the corresponding decimal value of each of the individualbits. The eight bits in a byte are labelled bits 0 to 7, from right to left. The right mostbit is called the Least Significant Bit (LSB) and the left most bit is called the MostSignificant Bit (MSB). The decimal value of each bit is given in the table below:

bit number 7 6 5 4 3 2 1 0decimal value 128 64 32 16 8 4 2 1

The binary number %10010111 when converted into decimal would be:

1 x 128 = 1280 x 64 = 00 x 32 = 01 x 16 = 160 x 8 = 01 x 4 = 41 x 2 = 21 x 1 = 1

Total: 151

Note that when writing binary numbers it is quite common to write all 8 bits, even ifthe first bits are equal to zero (unlike the decimal system, where leading zeros are notnormally written).

Assignments:Convert each of the following binary numbers into decimal:2.1) %111100002.2) %110000112.3) %010101012.4) %10101010

Page 83: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 15

Converting Decimal to Binary

To convert any decimal number into binary repeatedly divide the decimal number bytwo and record the remainder after each division. The decimal number 29 is used as anexample.

29 ÷ 2 = 14 rem 114 ÷ 2 = 7 rem 07 ÷ 2 = 3 rem 13 ÷ 2 = 1 rem 11 ÷ 2 = 0 rem 1

Therefore the decimal number 29 equals the binary number %00011101

Assignments:Convert each of these decimal numbers into binary:2.5) 172.6) 232.7) 112.8) 382.9) 33

Page 84: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 16

Section 3 – PBASIC Commands

The purpose of this section is to introduce the PBASIC commands used in developingcontrol program listings.

When you have completed this section you should be able to:• understand the use of flowcharts• understand the most common PBASIC commands

Before you start this section you should have a basic understanding of:• The architecture of a microcontroller.• The decimal and binary number systems.• Flowcharts

To complete the exercises in this section you require:• Stamp Controller• Input Module or MFA Sensor Module and Sensors

Page 85: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 17

Beginning Programming

Control operations are often represented by flowcharts. A flowchart provides a cleargraphical method of explaining how a program functions. A simple control operation isrepresented by the flowchart shown below.

67$57

6:,7&+ 3,1 �

+,*+

6:,7&+ 3,1 �

+,*+

6:,7&+ 3,16 � �

+,*+

:$,7 � 6(&21'6

6:,7&+ $//

2))

:$,7 � 6(&21'6

6723

:$,7 � 6(&21'

A PBASIC program which would achieve this control operation is:

let dirs = %11110000 ' set 0-3 inputs, 4-7 outputs

high 7 ' set pin 7 highpause 2000 ' wait for 2 seconds (= 2000 ms)high 6 ' set pin 6 highpause 1000 ' wait for 1 secondhigh 5 ' set pin 5 highhigh 4 ' set pin 4 highpause 3000 ' wait for 3 secondslow 7 ' switch pin 7 lowlow 6 ' switch pin 6 lowlow 5 ' switch pin 5 lowlow 4 ' switch pin 4 lowend ' end the program

Page 86: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 18

Activity 3.1

Key in the program listed above, and then download it to the Stamp Controller.

The LED indicator on pin 7 should light first, followed by the indicators on pin 6, andthen indicators 4 and 5. The program will then stop. To re-run the program simplypress the ‘reset switch’ on the Stamp Controller.

Read through the program carefully, and make sure you understand exactly what eachprogram line achieves.

The let dirs = %00001111 statement is explained in more detail later in this section,but it’s purpose in this case is to tell the Stamp Controller to make pins 4 to 7 outputs.

A high command switches an output pin on (logic level 1 = 5V). A low commandswitches an output pin low (logic level 0 = 0V). A pause command creates a delay inmilliseconds (there are 1000 ms in a second).

Note the 'comments' at the end of each line. A comment starts after an apostrophe (')and continues to the end of the line. Although the comments are not needed to makethe program work, they are an essential part of the program as they explain in 'plainlanguage' what the program is doing. You should always add a comment to every lineof your program, particularly if the program is to be studied by someone else at a laterdate.

Page 87: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 19

Assignment 3.2

Explain the function of the following PBASIC commands:- high, low, pause, end

Assignment 3.3

Explain the operation of the PBASIC program listing below, by adding comments toeach line.

let dirs = %11110000 ' set pins 4-7 as outputs

high 7 ' ….pause 2000 ' ….high 6 ' ….pause 1000 ' ….low 7 ' ….low 6 ' ….end ' ….

Page 88: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 20

Labels and Addressing

67$57

6:,7&+ 3,1 �

+,*+

6:,7&+ 3,1 �

+,*+

6:,7&+ 3,16 � �

+,*+

:$,7 � 6(&21'6

6:,7&+ $//

2))

:$,7 � 6(&21'6

:$,7 � 6(&21'

:$,7 � 6(&21'

Sometimes it is necessary to create programs that loop 'forever', as shown by thisflowchart. In this case it is necessary to add labels to the program, and to use the'goto' command to jump to the line marked by the label.

Page 89: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 21

A PBASIC program which would achieve this control operation is listed below.

init: let dirs = %11110000 ' set pins 4-7 as outputs

main: high 7 ' set pin 7 highpause 2000 ' wait for 2 seconds (= 2000 ms)high 6 ' set pin 6 highpause 1000 ' wait for 1 secondhigh 5 ' set pin 5 highhigh 4 ' set pin 4 highpause 3000 ' wait for 3 secondslow 7 ' switch pin 7 lowlow 6 ' switch pin 6 lowlow 5 ' switch pin 5 lowlow 4 ' switch pin 4 lowpause 1000 ' wait 1 secondgoto main ' loop forever

Activity 3.4

Key in, download and run the program listed above.

After the first line (which simply sets pins 4 to 7 as outputs), a label called 'main' hasbeen added to the listing. Note that all address labels must end with a colon (:) whenthey are first defined. It is also a good programming technique to use tabs (or spaces)at the start of lines without labels so that all the commands are neatly aligned. The term'white-space' is used by programmers to define tabs, spaces and blank lines, and thecorrect use of white-space can make the program listing much easier to read andunderstand.

The last line 'goto main' causes program flow to 'jump back' to the line labelled 'main'.This means that this program will loop 'forever'. Note that when ‘main’ is typed here itdoes not need a colon.

Note:Some early BASIC languages used 'line numbers' rather than labels for 'goto'commands. Unfortunately this line number system can be inconvenient to use, becauseif you modify your program by later adding, or removing, lines of code you then haveto modify all the line numbers within the 'goto' commands accordingly. The labelsystem, as used in most modern BASIC languages, overcomes this problemautomatically.

Page 90: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 22

Assignment 3.5

What is meant by the term "white-space"? Why is it important to use white-space andcomments when writing programs?

Page 91: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 23

Port Addressing and the Data Direction Register

Microcontrollers communicate with the outside world by input/output pins which aregrouped together in 'ports'. The Stamp Controller has one input/output port, whichcontains eight input/output pins.

Each pin can be addressed individually, or all eight pins in the port can be addressedsimultaneously. In the PBASIC language the pins are labelled 0 to 7, and the wholeport address is allocated the label 'pins'.

Each pin is referenced to by a single bit in the port address called 'pins'.

input/output pin 7 6 5 4 3 2 1 0bit of address 'pins' 7 6 5 4 3 2 1 0decimal value 128 64 32 16 8 4 2 1

By using the let pins = command the output pins can be switched on or off in differentcombinations in a single PBASIC line (rather than using lots of high and lowcommands).

To switch all pins 'high' the command would belet pins = 255

To switch all pins 'low' the command would belet pins = 0

To switch pins 0-2 'high' and pins 3-7 'low' the command would belet pins = %00000111

Note how the use of the binary number system can be used on this occasion to clearlyillustrate which pins are switched high (=1) or low (=0).

Page 92: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 24

Each Stamp Controller pin can be configured to be an output (to send digital signals)or an input (to receive digital signals). The Data Direction Register (DDR) is used toconfigure the port, and in the PBASIC language the DDR is allocated the label 'dirs'.

If all the bits in the DDR are set high then all the pins will be set as outputs. If all thebits are set low each pin will be set as an input.

For example,

let dirs = 255 ' set all pins as outputslet dirs = 0 ' set all pins as inputslet dirs = %11110000 ' set 0-3 inputs, 4-7 outputs

Every PBASIC program listing should always begin with a 'let dirs =' statement tocorrectly setup the DDR. By default all pins are set to inputs when the StampController is reset.

Page 93: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 25

67$57

6:,7&+ 3,1 �

+,*+

6:,7&+ 3,1 �

+,*+

6:,7&+ 3,16 � �

+,*+

:$,7 � 6(&21'6

6:,7&+ $//

2))

:$,7 � 6(&21'6

6723

:$,7 � 6(&21'

A PBASIC program which would achieve this control operation is:

let dirs = %11110000 ' set pins 0-3 inputs, 4-7 outputs

let pins = %10000000 ' switch pin 7 highpause 2000 ' wait for 2 seconds (= 2000 ms)let pins = %11000000 ' switch pins 7 and 6 highpause 1000 ' wait for 1 secondlet pins = %11110000 ' switch pins 4 to 7 highpause 3000 ' wait for 3 secondslet pins = 0 ' switch all pins lowend ' end the program

Activity 3.6

Key in, download and run the program listed above. This program switches outputs onand off without the use of the high or low command.

When writing programs there is often more than one solution to a problem. Thisprogram could have been written using high and low commands to do exactly the samething!

Page 94: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 26

Assignment 3.7

What is the function of the Data Direction Register (DDR)?

Assignment 3.8

A fountain in a garden centre is to be used to attract visitors to a new range of plasticponds. The garden centre owner wishes to develop a microcontroller based system thatcane be programmed to switch the fountain pump, and an external lighting system, onand off at regular intervals.

The following PBASIC program will switch the pump on and off every 60 seconds.The lights come on 10 seconds after the pump has started, and go off 10 secondsbefore the pump is stopped.

Draw a flowchart for the control sequence and add the missing comments to theprogram listing.

init: let dirs = %11110000 ' set pins 6 and 7 as outputs

main: high 7 ' switch the pump onpause 10000 ' wait 10 secondshigh 6 ' switch the lights onpause 40000 ' ….low 6 ' ….pause 10000 ' ….low 7 ' ….pause 60000 ' ….goto main ' ….

Page 95: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 27

For...Next Loops

<

1

67$57

6:,7&+ 3,1 �

+,*+

6:,7&+ 3,1 �

/2:

:$,7 � 6(&21'

6723

:$,7 � 6(&21'

6(7 &2817(5 �

+$9( :(

/223(' �

7,0(6"

A for...next loop is used when you wish to repeat a section of code a number of times.The number of times the program runs for is set by a variable. A variable is a numberthat is stored in the RAM memory of the Stamp Controller. There are 14 memorylocations that byte variables can be stored in. These locations are labelled b0 to b13,but can also be 'renamed' to more appropriate names by use of the 'symbol' command.

Page 96: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 28

Activity 3.9

Key in, download and run the following program.

symbol counter = b0 ' define the variable "counter"symbol red = 7 ' define pin 7 with the name "red"

init: let dirs = %10000000 ' set up pin 7 as an output

main: for counter = 1 to 5 ' start a for...next loop high red ' switch pin 7 high pause 1000 ' wait for 1 second low red ' switch pin 7 low pause 1000 ' wait for 1 secondnext counter ' end of for...next loop

end ' end program

Note again how white-space (extra spaces) has been used to clearly illustrate all thecommands that are contained between the for and next commands. The 'symbol'command is also used to label pins and variables to make them easier to use.

Page 97: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 29

Assignment 3.10

Explain why the symbol command may be used in a program.

Assignment 3.11

:$,7 ��� 6(&21'6

:$,7 ��� 6(&21'6

6:,7&+ $//

3,16 /2:

6:,7&+ $//

3,16 /2:

67$57

6:,7&+ $//

3,16 +,*+

6:,7&+ $//

3,16 +,*+

6723

<

1+$6 7+,6 %((1

'21( �� 7,0(6"

:$,7 � 6(&21'6

Page 98: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 30

The following PBASIC program will carry out the instructions shown in the flowchartabove.

Add the missing comments to complete the program listing.

symbol counter = b0 ' define the variable "counter"

init: let dirs = %11111111 ' set all pins as outputs

main: let pins = %11111111 ' ….pause 5000 ' ….

for counter = 1 to 10 ' …. let pins = %00000000 ' …. pause 500 ' …. let pins = %11111111 ' …. pause 500 ' ….next counter ' ….

let pins = %00000000 ' ….end ' stop the program

Page 99: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 31

If...Then...

6:,7&+ $//

/2:

<

1

67$57

6:,7&+ 3,1 �

+,*+

6723

,6 3,1 �

+,*+"

The if...then programming structure allows the Stamp Controller to make a decisionbased on information received from an input pin.

The following program switches pin 7 high, and then waits for an input connected topin 3 to go high. When the input switch is pushed the output pin is switched low

Activity 3.12

Key in, download and run the program listed below.

init: let dirs = %10000000 ' setup the DDR

main: let pins = %10000000 ' switch pin 7 highif pin3 = 1 then skip ' jump to 'skip' if input 3 is highgoto main ' loop

skip: let pins = 0 ' switch all pins offend ' end the program

To test the program you will need to connect the sensors module to the StampController, and connect a micro-switch to sensor 3 on the sensor module.

Note:Unlike some other BASIC languages, the then command can only be followed by alabel to jump to. You cannot add extra commands on the same line within the PBASIClanguage.

Page 100: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 3 32

Assignment 3.13

As part of a Christmas decoration in a shop, a lighting sequence is to be controlled by amicrocontroller. The output connections are shown below.

Input Connection Pin Output Connection7 Red Light6 Yellow Light5 Green Light4

Pressure Mat 3210

When a visitor treads on a pressure mat under the carpet, the 3 lights should flash onand off in sequence three times.

The following PBASIC program will carry out the instructions shown in the tableabove.

Add the missing comments to complete the program listing.

symbol counter = b0 ' .…

init: let dirs = %11110000 ' set pins 4-7 as outputs

main: if pin3 = 1 then flash ' ….goto main ' ….

flash:for counter = 1 to 3 ' …. let pins = %10000000 ' …. pause 500 ' …. let pins = %01000000 ' …. pause 500 ' …. let pins = %00100000 ' …. pause 500 ' ….next counter ' ….

let pins = %00000000 ' ….goto main ' ….

Page 101: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 1

TECHNOLOGICAL STUDIES

INTERMEDIATE 2

SYSTEMS AND CONTROL

STUDENTS’ NOTES

OUTCOME 4

Page 102: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 2

Page 103: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 3

Outcome 4 – Developing Control Sequences for Mechatronic Systems

The purpose of this unit is to develop microcontroller control sequences for simplemechatronic control systems.

When you have completed this unit you should be able to:

• develop flowcharts for control sequences• develop PBASIC programs for control sequences• select appropriate input transducers for control applications• select appropriate output transducers for control applications• use PWM to control the speed of a DC motor

Before you start this section you should have a basic understanding of:• The architecture of a microcontroller.• The decimal and binary number systems.• Flowcharts• PBASIC commands

To complete the exercises in this section you require:• Stamp Controller• Output Drivers Module (or MFA Movement Module)• Solar motor with propeller• Buggy (with microswitch sensors)• Input Module or MFA Sensor Module and Sensors

Page 104: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 4

Introduction

The first part of this outcome contains a number of assignments that involve combiningall the skills learnt in outcomes 1 to 3 to solve practical control problems.

The general procedure for solving microcontroller control problems is:

1. Draw a control diagram, identifying the ‘real-world’ inputs and outputs of thecontrol system.

2. Identify the input / output transducers and interfacing circuits required. Assign eachtransducer to a microcontroller pin.

3. Develop the control procedure in ‘sentences’ and then draw up a flowchart.4. Develop a PBASIC program from the flowchart.5. Key in and test the program.6. Modify the program as necessary.

The second part of this outcome introduces the principle of PWM speed control of DCmotors.

The final part of this outcome outlines a number of project briefs for practicalassignments.

Page 105: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 5

Assignment 1

A set of temporary traffic lights are required for a system of road-works.

red 10 secred and amber 2 secgreen 10 secamber 2 sec

Draw a flowchart for the lights sequence shown by one set of the traffic lights. Use thetimes shown in the table for each stage.

Write a PBASIC program, using high and low commands, to achieve this operation.Use the following pin configuration - red (7), amber (6) and green (5).

Write a second PBASIC program, without the use of high or low commands, toachieve this operation.

Page 106: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 6

Assignment 2

S TA M PC O N T RO LLE R

O UT P U TD RIV ER

M O D ULE

Connect a buggy to the output driver module (or MFA movement module) as shown inthe diagram.

67$57

6723

M O VE FO RWA RD

WA IT 3 SEC .

WA IT 3 SEC .

TU R N LEF T

WA IT 1 SEC .

M O VE FO RWA RD

Write a high level program in PBASIC to control the movement of the buggy as shownby the flowchart above.

Page 107: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 7

Assignment 3

S TA M PC O N T RO LLE R

O UT P U TD RIV ER

M O D ULE

Connect a buggy to the output driver module (or MFA movement module) as shown inthe diagram.

3

3

33

The buggy should follow the movement path as shown in the diagram above.

Draw a flowchart for the movement of the buggy, making use of a for...next commandstructure.

Write a high level program in PBASIC to control the movement of the buggy as shownby your flowchart. (It will be necessary to experiment with time delays to establish howquickly your buggy moves and turns).

Page 108: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 8

Assignment 4

A motor, connected to pin 7, is to run when a 'start' switch (connected to pin 2) ismomentarily pressed. The motor continues to run until another 'stop' switch (connectedto pin 3) is pressed - at which point the motor switches off. The system should thenreset to wait for another 'start' signal.

Draw a flowchart and write a PBASIC program for this sequence.

Assignment 5

S TA M PC O N T RO LLE R

O UT P U TD RIV ER

M O D ULE

Connect a buggy to the output driver module (or MFA movement module) as shown inthe diagram. Connect the micro-switch 'bumpers' to pins 0 and 1 on the StampController via the screw terminals as shown below (or via the inputs module).

V+

0

1

2

3

0V

SHOWS HOW TO WIRE 2 SWITCHES TOTHE SCREW TERMINALS ON THE

STAMP CONTROLLER

The buggy should continue in a forward direction until either of the two micro-switchbumpers is activated. At this point the buggy should reverse for 3 seconds, rotate 90degrees clockwise, and then continue in a forwards direction.

Draw a flowchart and write a PBASIC program to control the movement of the buggyas described above.

Page 109: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 9

Assignment 6

67$57

G REE N LED O N

SW IT CHPUS HED?

NO

YE S

G REE N LED O FFAM BE R LED O N

WA IT 3 sec.

AM BE R LED O FFRED LED O N

WA IT 4 sec.

AM BE R LED O N

WA IT 2 sec..

RED /AM BE R LED O FFG REE N LED O N

Page 110: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 10

Develop a PBASIC program that will carry out the instructions shown in the flowchartabove. Use the following pin configuration.

Input Connection Pin Output Connection7 Red Light6 Amber Light5 Green Light4

Start Switch 3210

Page 111: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 11

DC Motor Speed Control - Pulse Width Modulation

The simplest way to control the speed of a DC motor is to vary the voltage applied tothe motor coils - the lower the voltage the slower the motor will spin (within the motoroperating limits). However the current flowing through the motor coils also decreasesas the voltage falls, and so the output torque (turning moment) of the motor alsodecreases.

Therefore this solution is often unsatisfactory for controlling DC motors due to theundesirable loss of motor torque. Pulse Width Modulation (PWM) is a digitalmethod which can be used to vary the motor speed. In this method the full voltage isapplied to the motor, but it is rapidly pulsed on and off. By varying the on and off ratioof the pulses the speed of the motor can be varied. As the full voltage is applied to themotor during the 'on' pulses the torque of the motor remains high.

9

W63$&(

0$5.

The graph shows how the technique is applied. The 'on' time for the motor is called themark, the 'off' time is called the space. When the voltage is applied to the motor itaccelerates to top speed. However before the top speed is reached the motor isswitched off, thus slowing it down. By increasing the frequency of the pulses thisacceleration/deceleration becomes negligible, and the motor rotates constantly at aslower speed.

The PWM technique does have certain limitations. It cannot be used with mechanicalrelays, as the rapid switching would damage the mechanical contacts. The frequency ofthe pulses must also be carefully selected - if the frequency is too slow the motor willstall.

Page 112: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 12

Activity 7

Build the circuit as shown. This is most simply achieved by connecting the dc solarmotor across the 'V+' and '7' Darlington Driver terminals on the Output Driver module.

Connect a propeller to the output shaft of the dc solar motor to make the rotationalspeed easier to see.

Key in, download and run the program listed below. This program drives the motor atapproximately half speed, as the space is twice the length of the mark.

symbol mark = b1symbol space = b2symbol motor = 7

init: let dirs = %11110000 ' pin 4-7 outputslet mark = 10 ' set mark to 10mslet space = 20 ' set space to 20ms

main: high motor ' output highpause mark ' pause for mark timelow motor ' output lowpause space ' pause for low timegoto main ' loop

Try out different speeds (by experiment) by altering the values of 'mark' and 'space'.

Page 113: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 13

Soft Start of DC Motors

9

W

In some devices, such as electric drills, it is desirable for the motor to start rotatingslowly and then build up speed, rather than rapidly 'accelerating' up to full speed. Thisis called 'soft starting' the motor, and the use of PWM is often appropriate in thesesituations. The motor is started at a low speed and then gradually accelerated byvarying the mark to space ratio over a period of time.

Assignment 8

Explain the terms ‘mark’ and ‘space’ in relation to PWM control of a dc motor.

Assignment 9

Describe the advantages and disadvantages of using PWM control. Explain the term‘soft starting’ of a motor.

Page 114: Technological Studies - st-pauls.ea.dundeecity.sch.uk

Technological Studies: Systems and Control Students’ Notes (Int 2) Outcome 4 14

Activity Assignments.

For the following practical assignments students are expected to:1. Draw a control diagram of the system.2. Select suitable input and output transducers, explaining the reason a particular

transducer was selected.3. Build a model of the system, correctly connecting the transducers via appropriate

interfacing circuits.4. Develop a flowchart of the control sequence.5. Use the flowchart to develop and test a Pbasic program for the control sequence.

Project Briefs

1. Design and build a warning light for shipping that will come on automatically assunset and will remain on until dawn. The light must flash on and off and revolvearound 270°.

2. Design and build a lift suitable for a two story warehouse. The lift will rununmanned but must not be able to operate unless a safety grill has been closed first.The lift should be able to be controlled from both floors.

3. A heavy duty, industrial tumble dryer is required by a local cleaning contractor.The drum should be given by gears due to the load it will be expected to cope with.The system should also include a fan to circulate hot air and a method the ensurethat the door has been closed before the machine starts. The drum should alsorotate in both directions during the process.

4. Design and build a mechanism and control system to model a microwave oven.Your design should also include a method of preventing the microwave form beingstarted unless the door has been closed first. It should also include a fan and arotating turntable.

5. Design and build a device which will tell the difference between a real bank noteand a forgery by detecting the presence of the metal security strip in the correctposition in a real note.

6. Design and build an audible levelling device suitable for indicating when a caravanis level.

7. Car theft has become a major problem. After careful consideration, design andbuild a possible burglar alarm for cars left unattended.

8. Design and build a small three-wheeled remotely controlled, electrically poweredbuggy which can be controlled to follow a figure of eight course.

9. Design and build a machine that will revolve to face a light source.10. Design and build a model of an automatic railway level crossing.11. Design and build an automatic curtain control which operates at dusk and dawn.

There should also be provision for manual override.