Document

advertisement
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
Learning Objectives:
At the end of this topic you will be able to;
 know that simple control systems consist of software, computer or
micro-controller, interface, input sensors and output devices;
 know that the sensing circuits and output devices listed in the
specification can be interfaced to a computer or microcontroller;
 use the following operations in flowcharts: inputting data, outputting
data, counting, branching, testing data, simple arithmetic operations;
 design and analyse flowcharts for simple programs to make output
devices: perform a sequence of actions, respond to information from
sensors, make use of feedback;
 describe a range of applications of software-based control systems;
 appreciate the social, economic, ethical and cultural implication of
this technology for improving the quality of life, employment and
leisure.
1
GCSE Electronics.
Unit E2 : Applications of Electronics
2.5.2
Software Based Controllers
There are several types of control system to suit different needs. In this
module we will concentrate on software control systems using a
microcontroller, but we consider briefly the relative merits of the other
control systems as an introduction.
1.
Hard wired control systems
a.
On - Off Control:
The output is switched either on or off depending on the signal
produced by the input sensing sub system which monitors the
environmental condition being controlled. A temperature controlled
room heater is a typical example of such a control system.
Temperature
Sensing
Sub-System
Transistor
Switch
Relay
Room
Heater
If the temperature in a room falls below a predetermined value
the heater will be switched on. The heater remains on until the
temperature rises above the predetermined value and the heater
will switch off, and so on. The temperature in the room is
continually monitored and adjusted automatically.
2
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
b.
Sequential control based on counters and logic circuits
A traffic light sequence is a typical example of such a system.
Clock
Logic
System
Counter
Lamps
The system spends the same amount of time in each of four output
states and the sequence continually repeats itself.
Green
Amber
Red
Red & Amber
In these control systems the function of the system depended on what
components were used and how the components were interconnected.
They are said to be hard wired.
Changing the connections and/or the components used is the only way to
change the sequence produced a hard wired system.
3
GCSE Electronics.
Unit E2 : Applications of Electronics
2.
Programmable Systems based on counter and memory arrays
The design of the simple traffic light sequence generator is improved
by adding a memory IC. This allows us to change a sequence without
changing the circuit hardware significantly. Each memory location is
accessed by connecting a counter to the memory address lines.
In this way each stage of the sequence can last for a different length
of time
A different sequence is obtained by changing the data stored in each
memory location.
Such a system is referred to as a programmable logic system. RAM
(random access memory) will store a sequence only as long as the power
to the system is left on. If the power is switched off the program is
lost unless a back up battery is used.
4
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
Computer controlled systems
A typical microprocessor chip contains thousands of components housed in a
variety of packages from 40 pin d.i.l., to 288 pin ceramic pin grid array
packages.
The usefulness of a microprocessor lies in the fact that it is program
controlled. When built, it has no specific function. A particular function has
to be programmed into it in the form of a sequence of instructions, called the
program. Different programs allow the microprocessor to be used as the
‘brain’ of a wide variety of electronic systems e.g. calculators, automatic
washing machine, traffic light controllers, industrial robots, health monitors,
toys, etc.
The major advantages of program controlled systems over circuit controlled
systems are cost and flexibility. Millions of microprocessor chips can be
manufactured to the same specification hence cutting manufacturing costs.
Each chip can then be programmed to perform a different function.
Although microprocessor based control systems have advantages in terms of
their cost and flexibility, they operate too slowly for some control situations.
For this reason hard wired control systems will continue to be an essential
branch of electronics.
In this topic we use a device called a microcontroller.
5
GCSE Electronics.
Unit E2 : Applications of Electronics
Microcontrollers are totally self-contained whereas microprocessors require
the use of additional chips to function. A microcontroller contains its own
program memory, data storage memory, bidirectional (input/output) ports and
a clock oscillator all in a single IC. The program area can store a program even
if the power is switched off. A program can be written using a flowcharting
program (see later) and then downloaded to the microcontroller. It can then
be disconnected from the programmer and the microcontroller runs the
program independently.
A Computer Interface
Most input sensors and output devices cannot be connected directly to a
computer. An interface or buffer box:
6
i)
simplifies the physical connection to external device.
ii)
protects the computer hardware by providing the correct signal
levels.
iii)
controls the power to drive output devices.
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
A microcontroller interface
These are simpler than computer interfaces because the control circuitry is
contained in the microcontroller device itself. The system can be designed as
a single circuit with inputs and output built to match the microcontroller. This
can make the solution smaller and relatively inexpensive.
Some microcontrollers have inbuilt analogue to digital converters, that allow
analogue sensors to be directly connected to an input.
Outputs can be interfaced to a microcontroller with a transistor or MOSFET,
so even high powered output devices can be accommodated easily.
A program can be downloaded and tested using the actual inputs and outputs
devices. It can then be modified until the system performs exactly as
required.
Control Programs
A very simple control program written in a Control Language is designed to
switch two outputs ON and OFF as shown below.
Switch On 0
Wait 5
Switch Off 0
Wait 2
Switch On 0,1
Wait 3
Switch Off 0,1
Control programs contain many instructions. Typing errors or other SYNTAX
errors (using the wrong ‘grammar’ to write the instructions,) cause the
program to run incorrectly or not to run at all.
7
GCSE Electronics.
Unit E2 : Applications of Electronics
FLOWCHARTS
A flowchart is a set of statement boxes linked by arrows used to arrange the
different steps in the sequence in a logical order. Flow charts can be used to
sort any set of complex instructions, not only in the writing of computer
programs.
A flowchart is particularly useful in determining the structure of a computer
program. The steps required are written inside boxes of different shapes.
The boxes are interconnected by arrowed lines called flow lines.
Some of the more common flowchart boxes are given below.
Start
A start symbol is used at the beginning of each flowchart.
Stop
A flowchart may contain one, none or many stop boxes.
A process box is used if a calculation or a delay
is required.
Let a = 0
Is a > 10
Y
N
Switch
on
output 1
8
A decision box is used to ask a question which can be
answered with either YES or NO. If the answer is YES,
the sequence follows one route. If the answer is no, it
follows a different one.
An output box is used to send data to a
particular output.
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
Here is the flowchart for the simple program given on page 7. It uses some of
flowcharting symbols shown above.
START
Turn Output
0 On
Turn Output
1 On
Delay 5
Delay 3
Turn Output
0 Off
Turn Output
0 Off
Delay 2
Turn Output
1 Off
Turn Output
0 On
STOP
Flowchart 1
9
GCSE Electronics.
Unit E2 : Applications of Electronics
Graphically based programming
Converting a flowchart line by line into a control program can be both
difficult and time consuming. For this reason control programs that use a
graphics interface have been developed. These do not require traditional
programming skills. They make use of the techniques common to many
computer aided design programs. Flowchart symbols are chosen from a menu
and ‘dragged’ onto the computer screen. An editing window allows the
contents to be translated into a program avoiding syntax errors. Then the
flowchart can be tested and edited.
There are currently several flowchart control programs available. These
include programs called: ‘FLOWAL’, ‘LOGICATOR’, ‘CIRCUIT WIZARD
(GENIE)’ and ‘FLOWCODE’. All four allow you to simulate a flowchart program
on a computer and download it via a USB cable to a microcontroller on a
dedicated interface circuit board.
Note: The activities in this chapter are written in a generic format as
individual systems have their own way of setting up the inputs and outputs.
You may have access to Flowal, Logicator, Circuit Wizard or Flowcode in your
school or college. Your teacher will show you the specific differences in the
flowchart for your particular version of software.
Note:
10
If you have access to Circuit Wizard, the supplementary notes to
this chapter have been reproduced specifically to be set up on
Circuit Wizard so that they replace the activities on Page 11 – 23.
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
Activity 1: Demonstrating the Software Program
1a.
Your teacher will set up and demonstrate the simple control program
shown in flowchart 1 to you. Suggest how the program can be made to
repeat continuously?
......................................................................................................................................
......................................................................................................................................
1b.
The following Circuit Wizard flowchart shows the main part of the
program with the STOP box removed. Show the other modification
needed so the sequence repeats itself continuously.
11
GCSE Electronics.
Unit E2 : Applications of Electronics
Activity 2
Flowchart 2 shows a traffic light sequence.
Start
Turn on
Red
Light
Wait 10s
Wait 10s
Turn off
Green.
Turn on
Amber.
Turn on
Red and
Amber
Wait 2s
Wait 2s
Turn Red
& Amber off.
Turn on
Green
Turn off
Amber.
Flowchart 2
Construct the flowchart and test it. Does the program perform the
correct sequence?
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
12
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
Activity 3:
Re-design the flowchart program in Activity 3 so that it represents two
sets of traffic lights at a cross roads, shown by the following sequence:
Step
1
2
3
4
5
North-South Lights
Red On (20sec)
Red & Amber (3 sec)
Green On (20 sec)
Amber On (3 sec)
Red On (20Sec)
East-West Lights
Green On (20sec)
Amber (3 sec)
Red On (20 sec)
Red & Amber On (3 sec)
Green On (20Sec)
Complete the flowchart in the space below.
Start
Turn on
N-S Red
E-W Green
13
GCSE Electronics.
Unit E2 : Applications of Electronics
Using Decision Boxes
All the programs so far have involved only outputs. Now we look at a program
where decisions are made based on the state of the inputs.
Decisions boxes ask questions which have only two possible outcomes,
referred to as Yes and No routes. In programming language decisions boxes
cause branches in a program. The program flow is directed one way or
another depending on the result of the question.
A decision box can be used to cause a program to ‘wait’ and repeatedly test
until an input comes on or goes off. This is shown below:
Is Input
5 On
No
Yes
Here the ‘No’ path loops back on itself repeating the question “Is Input 5
On?” until Input 5 is actually on. Then the program leaves this decision box
and continues through the rest of the program.
14
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
A second use of a decision box is to branch to a different part of the
program depending on the state of an input, as shown below:
Is Input
5 On
No
Yes
Turn Output
0 On
Turn Output
7 Off
The question is the same - “Is Input 5 On?” but the outcome depends on the
answer. If input 5 is on, the program will turn output 0 on. If input 5 is off,
the program will turn output 7 off. The program will enter the decision box
only once. The route it takes depends on the state of Input 5.
15
GCSE Electronics.
Unit E2 : Applications of Electronics
Sometimes, we need to repeat sections of the program a set number of times.
e.g. to pack 6 cans into a box on a production line. To do this, we setup a count
within the program.
The first thing to do is to set a counter to zero. This is achieved by creating
a variable, called ‘Count’ to keep a record of how many times an event has
happened, and by setting this to a value of zero, as shown below:
Count = 0
When we need to increase the count by one we use another process box with
a different instruction:
Count = Count + 1
16
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
Finally we use a decisions box to check when we have reached the required
count of 6, as follows:
Is
Count
= 6?
No
Yes
Here the variable ‘Count’ is tested to see if it has reached 6. If it has then
the program will follow the ‘Yes’ branch. If it has not reached 6 then it will
follow the ‘No’ branch.
17
GCSE Electronics.
Unit E2 : Applications of Electronics
Activity 4:
Study FLOWCHART 3 below. It is a modified version of FLOWCHART 1 with
a decision box and 2 process boxes added.
Start
C=0
Turn on
Green
Light
Wait 3s
Turn off
Yellow
and
Green.
Wait 5s
Turn
Green
Off
Wait 1s
C=C+1
Wait 2s
Turn
Yellow
and
Green On
Turn off
Amber.
Is
C = 10?
Yes
Stop
Flowchart 3
18
No
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
Look at the flowchart. What does it do? Write your description in the space
below.
...............................................................................................................................................
...............................................................................................................................................
...............................................................................................................................................
...............................................................................................................................................
Now try it out. Did you predict the correct result? If not, what did you get
wrong?
...............................................................................................................................................
...............................................................................................................................................
...............................................................................................................................................
...............................................................................................................................................
Notice that:
i.
ii.
iii.
the ‘let C = 0’ statement box is used to set a counter to zero at
the start of the program;
the ‘let C = C + 1’ box increases the count by 1 each time the
sequence repeats itself;
the ‘Is C = 10’ decisions box monitors the count. When the count
less than 10, the sequence continues. When the count equals 10,
the program stops.
19
GCSE Electronics.
Unit E2 : Applications of Electronics
Activity 5:
5a.
Construct and test flowchart 4 below.
Start
Is
Input 6
On?
No
Yes
Turn On
Red
Light.
Turn on
Green
Light
Wait 1s
Wait 1s
Turn On
Yellow
Light
Turn off
all lights
Wait 1s
Wait 1s
Is
Input 7
On?
Yes
Flowchart 4
20
No
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
5b.
Describe the programs operation.
...................................................................................................................................
...................................................................................................................................
...................................................................................................................................
...................................................................................................................................
Activity 6.
The UK cycling team is busy preparing for the Olympic Games. At the
velodrome in Manchester the team coach wants to have a lap counter fitted
to the track to light a lamp when 10 laps of the track have been completed.
A pressure switch is fitted to the track so that when the wheel of the bike
passes over it, the switch is closed.
Can you spot a potential problem with this method?
…………………………………………………………………………………………………………………………………………
21
GCSE Electronics.
Unit E2 : Applications of Electronics
6a.
The flowchart below provides a possible solution to the problem.
Start
Is
Input 6
On?
No
Is bike on start line
Yes
A=0
Is
Input 7
On?
Yes
No
Has wheel passed over finish line
start line
A=A+1
B=A/2
No
Is
B = 10?
Yes
Turn On
Yellow Light
Wait 5s
Turn off
Yellow Light
22
10 laps completed
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
6b.
Setup the flowchart opposite.
D6 is checking that the bike is correctly positioned on the start line.
D7 is the pressure switch checking for completion of a lap.
6c.
Explain what each step of the program does.
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………
23
GCSE Electronics.
Unit E2 : Applications of Electronics
Industrial applications of Computer Control
Computer control is used extensively in all areas of industry. Examples include
computer control of:
 feeding and milk production for dairy cows;
 shearing sheep to gain maximum fleece;
 designing, manufacturing and testing new cars;
 within the cars themselves, controlling the ignition system, ventilation
and heating, cruise control, anti-lock braking systems and so on.
Your teacher will discuss other computer control applications with you.
Social Implications of Computer Control
Computer control affects all areas of our lives. There are both benefits and
concerns for the introduction of such control systems.
Benefits:
In the home, DVD players, ‘Sky’ boxes, automatic washing machines,
microwave ovens and many other appliances contain microprocessors. These
improve versatility and reliability at lower cost, allowing us to make better
use of our leisure time.
In industry robots have helped the efficiency of production since they:
i.
ii.
iii.
iv.
v.
vi.
work 24 hours a day without a break;
need no holiday;
produce consistent quality work;
can be quickly ‘retrained’ by reprogramming a computer;
can be used in unhealthy and hazardous conditions;
do not get bored with repetitive tasks.
Computer control brings benefits in many other areas of society such as
health care, communication, transport, security, and entertainment.
24
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
Concerns
Some people are concerned that computer control systems:
i. cause unemployment.
ii. can be used for a military purpose.
iii. invade people’s privacy.
Overall, the majority of people consider that the benefits outweigh the
concerns. It is left to you as an individual to draw your own conclusion.
25
GCSE Electronics.
Unit E2 : Applications of Electronics
Examination Style Questions
1.
A computer-controlled system is used to pack baked-bean tins into a box in a canning factory.




(a)
The computer receives a signal when a tin moves past a sensor on a conveyor belt.
The computer uses a counter to keep track of how many tins have passed.
At the end of the conveyor belt, the tins are placed in the box.
When the box contains 10 tins, it is closed, and replaced with an empty box.
Part of the flowchart for this control system is shown below.
Add these instructions to the correct boxes in the flowchart:
Add 1 to ‘count’
Has a can passed?
Is ‘count’ equal to ten?
[3]
(b)
Add the links to the two decision boxes to show how the flowchart branches when the
answer to the decision box question is ‘No’.
[2]
26
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
2.
A lift can carry 9 persons safely. A computer program is used to count the number of persons and
sounds an alarm if 10 people have entered the lift.
(a)
Name a suitable sensor to be used at the entrance.
.............................................................................................................................................................
[1]
(b)
The program makes use of a counter. How does the signal from the sensor affect the
counter?
.............................................................................................................................................................
[1]
(c)
Complete the following flow chart for the program required by:



writing the instructions in the empty boxes;
adding correct branches to the decision boxes;
writing yes / no on the first decision box.
[6]
27
GCSE Electronics.
Unit E2 : Applications of Electronics
3.
Some school buses have a reversing system controlled by a microcontroller.


The system pulses a bleeper when reverse gear is selected.
The system also switches on a warning lamp inside the bus if it senses something near the
back of the bus.
The flowchart shows part of the operation of this reversing system.
Some parts of the flowchart have been left out.
28
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
(a)
Name a suitable device to sense when reverse gear is selected.
.................................................................................................................................................
[1]
(b)
Complete the flow chart for the program required by:

Writing the correct instruction from this list in the empty boxes
Is something near?
Switch on reverse bleeper
Switch on warning lamp


Adding correct branches to the decision boxes,
Writing yes/no on the second decision box.
[6]
29
GCSE Electronics.
Unit E2 : Applications of Electronics
4.
A maximum of 100 cars can enter a car park. A computer program is used to count the number of
cars and close a barrier if 100 cars have entered.
(a)
Name a suitable sensor to be used at the entrance.
..................................................................................................................................................
[1]
(b)
Complete the following flow chart for the program required by:



writing the instructions in the empty boxes
adding correct loops to the decision boxes
writing Yes/No on the decision boxes
[7]
30
Topic 2.5 – Programmable Control Systems.
2.5.2 Software Based Controllers.
Self Evaluation Review
Learning Objectives
My personal review of these objectives:



know that simple control systems consist
of software, computer or micro-controller,
interface, input sensors and output
devices;
know that the sensing circuits and output
devices listed in the specification can be
interfaced to a computer or
microcontroller;
use the following operations in flowcharts:
inputting data, outputting data, counting,
branching, testing data, simple arithmetic
operations;
design and analyse flowcharts for simple
programs to make output devices: perform
a sequence of actions, respond to
information from sensors, make use of
feedback;
describe a range of applications of
software-based control systems;
appreciate the social, economic, ethical
and cultural implication of this technology
for improving the quality of life,
employment and leisure.
Targets:
1.
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
2.
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
31
Download