Programming for Control Systems

advertisement
Programming for Control
Systems
Chapter 17
Letts Study Guide
“Information Systems-IT”
Controlling a turtle with LOGO
• A floor turtle is a simple robot which can move
around the floor and respond to LOGO
instructions.
• A screen turtle is a shape on the screen which
can carry out the same instructions as the floor
turtle.
• A turtle can usually obey:
PEN DOWN,
PEN UP, FORWARD n,
BACKWARD n,
LEFT b, RIGHT b.
• A set of instructions can be repeated using
REPEAT n [...].
Programming control systems
• The user can define a new instruction [or
procedure] by putting together a group of existing
instructions.
• One way to express a control algorithms in simple
English.
• The language used needs to be:
precise, using clear language;
set out so that it is easy to read.
Examples of a control algorithm
A Burglar Alarm
• 2 sensor systems, using touch sensors in the doors and
windows and the other using infra-red beams inside.
• Both sensors are on all the time the burglar alarm is on.
• If either of these sensors is off the processor switches on
the alarm an alarm and also switches on the outside lights.
The program to do this could be represented as:
REPEAT
CHECK touch sensor
CHECK infra-red sensor
IF touch sensor OFF OR infra-red SENSOR OFF THEN
SWITCH ON alarm
SWITCH ON lights
UNTIL alarm system switch OFF
• The language is English but is precise
• To emphasise regularly used words they have been written
in capital letters
• Every time the same operation is done the same words are
used (e.g. SWITCH ON)
• Where statements should be grouped together they have
been indented from the margin
• SWITCH ON alarm and SWITCH ON lights have been indented
together to make it clear that they are governed by the IF condition
• all statements between REPEAT and UNTIL have been indented to
make it clear they are all to be repeated
– Actual control equipment will have a control
language with instructions for:
–
switching outputs on and off
–
receiving input from sensors
Solving control problems
A project on control work involves:
• finding a problem to solve;
• producing a project proposal and having it
accepted;
• investigating the problem further;
• producing a design for a solution including a
diagram of the hardware, a description of what the
system will do and a program flowchart or
structure diagram;
• constructing the hardware but not spending too
long on it;
Solving control problems cont.
• writing the program in a way that it is easy to
understand;
• testing the interface, the rest of the hardware and
then the whole system including the program;
• evaluating the project.
Download