Software Based Controllers - WJEC

fiercebunΗλεκτρονική - Συσκευές

2 Νοε 2013 (πριν από 4 χρόνια και 11 μέρες)

114 εμφανίσεις


Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


1

Learning Objectives:



At the end of this topic you will be able to;




k
now that simple control systems consist of software, computer or
micro
-
controller, interface, input sensors and output devices;



k
now that the sensing circuits and output devices listed
in the
specification can be interfaced to a computer or microcontroller;



u
se the following operations in flowcharts: inputting data, outputting
data, counting, branching, testing data, simple arithmetic operations;



d
esign 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
.



GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


2

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
mic
rocontroller,
but we
consider
briefly
the relative merits of
the
other
control systems as an introduction.


1.

Hard wired control systems



a
.

O
n

-

O
ff

C
ontrol
:




The output is switched either on or off depending on the signal
produced by the input sensi
ng sub system which monitors the
environmental condition being controlled. A temperature controlled
room heater is a typical example of such a control system.









If the temperature in a room falls below a predetermined value
the heater will be switch
ed 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.



Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


3


b
.

S
equential

co
ntrol

based
on counters an
d logic circuits



A traffic light sequence is a typical example of such a system.


The

system spends the

same amount

of time in each of four output
states and the sequence continually repeats itself.



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 t
he only way
to
change
the

sequence produced
a hard wired system
.



GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


4

2.

P
rogrammable
Systems

based on counter and memory arrays


T
he design of the simple traffic
light
sequence

generator

is improved
by adding a
memory IC
. This allows us to

chang
e

a sequence without
changing the circuit hardware significantly.

Each memory location

is

access
ed 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 referr
ed to as a programmable logic system.

RAM
(random access memory)
will store a sequence
only
as long as t
he power
to the system is left on. If the power is switched off the
program

is
lost

unless a back up battery is used.




Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


5

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
programme
d into it in the form of a sequence of instructions
,
called the
program
.

Different
program
s allow

the microprocessor
to
be used as the
‘brain’ of a wide variety of electronic sys
tems e.g.

calculators,

automatic
washing machine, traffic light controllers, industrial robots, health monitors,
toys, etc.


The major advantage
s

of program controlled systems over circuit controlled
systems
are

cost and flexibility.
Millions
o
f microproc
essor chips can be
manufactured to the same specification hence cutting manufacturing costs.
Each chip can then be
program
me
d to perform a different function.


Although microprocessor based control systems have advantages in terms of
their cost and flexibi
lity, 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
.



GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


6

Microcontrollers are totally
self
-
conta
ined

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 C
omputer Interface


Most
i
nput sensors and output devices cannot be connected
directly
to a
computer. An interface or buffer box:



i)

simplifies

the physical connection to external device.



ii)

protect
s

the computer
hardware
by providing the correct

signal
levels.



iii)

control
s

the power to drive

output devices.



Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


7

A microcontroller interfac
e



These are simpler than computer interfaces

because
the control circuitry is
contained in the micr
ocontroller device

itself
. The
system
can be designed as
a s
ingle circuit
with inputs

and output built
to match
the microcontroller.
This
can
make the solution small
er

and relatively inexpensive.


Some
microcontrollers have inbuilt analogue to digital converters, that allow
analogue sensors to be directly connecte
d 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
input
s

and output
s

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 a
s 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.



GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


8

Is a > 10


Y


N

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 t
he 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.



A start symbol i
s used at the beginning

of each flowchart.








A flowchart may contain one,
n
one or m
any
stop box
es
.




A process box is used if a calculation

or
a

delay


is required.




A decision

box is used to ask a question

wh
ich can be
a
nswered with either
Y
ES

or NO.

If the answer is YES
,
the sequence follows one route. If

the
an
swer is no
, it
follows a different one.



An output box is used to send data to a


particular output.




Let a = 0

Switch
on
output 1

Start

Stop


Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


9

H
ere is the

flowchart for the simple program given on page
7
.
It uses some
of
flowcharting symbols
shown
above.




Flowchart 1



GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


10

Graphically based programming


C
onverting
a flowchart
line by line into a control program can be both
difficult and time consuming. For this reason control programs that use a
graphic
s

interface
have b
een 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’
on
to

the computer screen.

An editing window allow
s
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
indi
vidual systems have their own way of setting up the inputs and outputs.
Y
ou
may
have access to
F
lowal
,

L
ogicator,

Circuit Wizard
or F
lowcode

in your
school or college. Y
our teacher will show you the
specific
differences in the
flowchart

for your particular

version of software
.


Note:

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 the
y replace the

activities
on Page 11


23.






Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


11

Activity 1:

Demonstrating
the Software Program


1a.

Your teacher will set up and demonstrate the simple control program
shown in flowchart 1 to you.
S
uggest how the program can be made to
repeat continuously?



..............................................
...................
......
...............................................................



..............................................
...................
.....................................................................


1b.

The following
Circuit Wizard

flowchart shows the
m
ain part of the
program with the STOP box removed. Show
the
other
modification

needed

so the sequence repeats itself
continuously
.





GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


12

A
ctivity

2


Flowchart
2

shows

a traffic light sequence.


Flowchart
2



Construct the flowchar
t and test it.
Does the program perform the
correct sequence?



...........................................
...................
........................................................................



..................................................
.....
..............
.................................................................



...................................................
...................
................................................................

Start

Turn on

Red

Light

Wait 10s

Turn on

Red and
Amber

Turn Red

& Amber off.
Turn on

Green

Turn off

Green.
Turn on

Amber.

Turn off

Amber.

Wait 2s

Wait 10s

Wait 2s


Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


13

Activity
3
:


Re
-
design the flowchart
program in Activity 3

so that it
represents
two
sets o
f

traffic lights at a cross roads
,
shown by
the following sequence
:



Step

North
-
South Lights

East
-
West
Lights

1

Red On (
20
sec)

Green

On (20sec)

2

Red & Amber (
3

sec)

Amber (
3

sec)

3

Green On (
2
0 sec
)

Red
On (2
0 sec)

4

Amber On (3 sec)

Red &
Amber On (3 sec)

5

Red On (
20
Sec)

Green

On (
20
Sec)


Complete
the flowchart in the space below.


Start

Turn on

N
-
S
Red

E
-
W Green


GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


14

Using Decision Boxes


All the programs so far have
involved
only

outputs.
N
ow

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
progra
m
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:

Here the ‘No’ path loops back on itself

repeat
ing the question “Is Input 5
On?” until
Input 5 is actually on
. Then

the program leave
s

this decision box
and
continues through
the rest of the program.





Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


15

A
second

use of a decision box is to

branch

to a different part of the
program depending on t
he state of an input, as shown below
:


T
he question is the same
-

“Is Input 5 On?” but the outcome

depends on the
answer.

If
i
nput 5 is
on
,

the program will
t
urn
o
utput 0
o
n
.

I
f
i
nput 5 is
off
,

the program will
t
urn
o
utput 7
o
ff
. The p
rogram will enter t
he de
cision box
only
once
.

The route it takes depends on
the state

of Input 5.







GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


16

Sometimes,
we
n
eed to repeat sections
of
the program
a set number of times.
e
.g. to pack 6 cans into a box
on

a production line. T
o d
o this
,

we setup a count
within the pro
gram.


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
:







When we need to incr
ease the count by on
e w
e use
another

process box

with
a different instruction
:








Count = 0

Count =

Count + 1


Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


17

Finally we use
a

decisions box
to check
when
we have reach
ed
the
required
count
of 6, as follows:









Here the variable ‘C
ount
’ 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.




I
s

Count

= 6
?

Yes

No


GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


18

Activity
4
:



Study

FLOWCHART
3

below.

It is a modified version of
FLOWCHART
1

with
a
decision box and 2 process boxes added
.



Flowchart
3

Start

Turn on

Green

Light

Wait 5s

Turn
Green

Off

Turn

Yellow

and

Green

On

Turn off

Yellow
and
Green.

Turn off

Amber.

Wait 2s

Wait 3
s

Wait
1
s

C = 0

C = C + 1

Is

C =

10?

Stop

No

Yes


Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


19


Look at the flowchart. What does it do?

W
rite your description in the space
below.


.....................................................................
..................
........................................
.
.....
.
..
..
.
....


.....................................................................
..................
........................................
.
......
..
..
.
....


.....................................................................
..................
............
............................
.
......
..
..
.
....


.....................................................................
..................
........................................
.
......
..
..
.
....


Now try it out. Did you predict the correct result
?

I
f not
,

what

did you get
wrong
?


.....................................................................
..................
........................................
.
......
..
..
.
....


.....................................................................
..................
....
....................................
.
......
..
..
.
....


.....................................................................
..................
........................................
.
......
..
..
.
....


.........................................................
............
..................
........................................
.
......
..
..
.
....


Notice
that
:


i.

the ‘let C = 0’ statement box
is

used to set a counter to

zero at
the start of
the

program;

ii.

the ‘let C = C + 1’ box increase
s

the

count by 1 each time the

sequence
repeat
s

itself
;

iii.

the ‘Is C = 10’ decisions box monitor
s

the count.
When

the count
less than 10
,

the sequence continue
s
.
When
the count equal
s

10
,

the program stop
s
.




GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


20

A
ctivity

5
:


5a.

Construct and test flowchart

4 below
.


Flowchart 4



Is

Input 7

On?

No

Yes

Start

Turn on

Green

Light

Wait 1s

Turn
On
Yellow

Light


Turn
On

Red
Light
.

Turn off

all lights

Wait 1s

Wait 1s

Is

Input 6

On
?

No

Yes

Wait 1s


Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


21

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 li
ght 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 th
e bike
passes over it, the switch is closed.



Can you spot a potential problem with this method?


…………………………………………………………………………………………………………………………………………



GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


22

6a.

The flowchart below provides a
possible
solution to the problem.


Is

B = 10
?

No

Yes

Start

Turn o
ff

Yellow Light

A = 0

Turn
On

Yellow

Light


Is bike on start line

A = A + 1

Is

Input 6

On?

No

Yes

Wait
5
s

Is

Input 7

On?

No

Yes

B = A /

2


Ha
s
wheel passed
o
ver finish line

start line


10 laps completed


Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


23

6b
.

Setup the flowchart opposit
e.



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.



…………………………………………………………………………………………………………………………………



……………………………………
……………………………………………………………………………………………



…………………………………………………………………………………………………………………………………



…………………………………………………………………………………………………………………………………



…………………………………………………………………………………………………………………………………



…………………………………………………………………………………………………………………………………



…………………………
………………………………………………………………………………………………………



…………………………………………………………………………………………………………………………………



…………………………………………………………………………………………………………………………………



…………………………………………………………………………………………………………………………………



…………………………………………………………………………………………………………………………………



………………
…………………………………………………………………………………………………………………



…………………………………………………………………………………………………………………………………



…………………………………………………………………………………………………………………………………

GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


24

Industrial a
pplications 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
;



design
ing
, manufactur
ing

and test
ing new cars;



within the cars themselves,

control
ling

the ignition system, ventilation
and heating, c
ruise 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 o
ther

appliances contain microprocessors. The
se

improve

versatility and reliability at
lower cost,

allow
ing

u
s to make better
use of our leisure time.


In industry robots have helped the efficiency of production since they
:


i.

work 24 hours a day without a break
;

ii.

need no holiday
;

iii.

produce consistent quality work
;

iv.

can be quickly ‘retrained’ by reprogramming a compute
r
;

v.

can be used in unhealthy and hazardous conditions
;

vi.

do not get bored with repetitive task
s
.


Computer control brings benefits in many other areas of society such as
health care, communication, transport, security, and entertainment.



Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


25

Concerns



Some peop
le 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.


GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


26

Examination Style Questions


1.

A computer
-
controlled system is used to pack baked
-
bean tins into a box in a canning factory.




The computer receives a signal when a tin moves past a sensor on a conveyor belt.



The computer uses a count
er 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.



(a)

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 qu
estion is ‘No’.

[2]


Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


27

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 boxe
s;



adding correct branches to the decision boxes;



writing yes / no on the first decision box.




[6]


GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


28

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.





Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


29



(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]



GCSE Electronics
.

Unit E
2

:
Applications of
Electronics


30

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]



Topic
2.
5



Programmable Control Systems
.

2.
5
.
2

Software Based Controllers
.


31

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 s
ensing 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
operati
ons;




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;




appreci
ate the social, economic, ethical
and cultural implication of this technology
for improving the quality of life,
employment and leisure
.






Targets:

1.

…………………
…………
…………………………………………………………………………………





………………………………………………………………………………………………………………


2.

…………………………
……………………………………………………………………………………


……………………………………………………

………………………………………………………