Document 280956

Level 3 Digital Technologies 91638 (3.47)
Title
Demonstrate understanding of complex concepts used in the
design and construction of electronic environments
Credits
4
EXEMPLAR FOR EXCELLENCE
THIS PDF ALSO CONTAINS A
PRINTABLE ANNOTATED VERSION
Report for 3.47: 'HPRQVWUDWHXnderstanding RIcomplex concepts XVHGLQWKHGHVLJQDQG
FRQVWUXFWLRQRIHOHFWURQLFHQYLURQPHQWV
Specification:
My design for a model elevator (lift) which will help explain the hardware and software
concepts I have chosen is the two-floor (G & 1), two-call button type. There is a call
button on each floor and an LCD display panel inside the lift. The motor that raises and
lowers the lift is reversible. It is connected to the lift cables through a gearbox and
pulleys (not shown). Sensors (P1- P4) positioned near the bottom and top of each level
on the lift shaft wall signal the motor controller to manage the speed of the lift as it
moves. The motor control circuit uses an H-bridge type that contains an inbuilt current
sensor (this can be used as a safety feature to detect when the lift is overloaded and to
prevent it moving off). A PICAXE microcontroller is programmed to operate the lift.
Diagram of a model elevator
P1-P4 are sensors in the lift shaft
to enable the lift to know where
it is and in what direction it is
travelling. This is needed to
control motor speed and
acceleration and deceleration.
The LCD panel is inside the lift.
Digital Technologies 91638 (3.47)
Page 1 of 13
Exemplar for Excellence
Circuit schematic
Here is a block diagram of the model lift control system.
+
Current
sensor line
Inputs for limit
switch sensors
H-bridge
control lines
L293D
Multiple
switch
sensors
Multiple
switch
sensors
Serial data to
LCD
Inputs for button
press sensors
My report demonstrates understanding for five software and five hardware concepts
using the elevator (building lift) context.
Complex hardware concepts:
Microcontroller, H-bridge with speed control, FET operation, multiple sensors, LCD
display
Complex software concepts:
Bitwise logic, flags and interrupts, serial data transmission, structuring complex
programmes, ADC and DAC (analogue to digital and digital to analogue conversion).
Complex hardware concepts
1. Microcontroller
The microcontroller represents the concept of a small computer on a single integrated
circuit with inputs and outputs and with processing and memory capacity.
A microcontroller is a ‘computer-on-a-chip', as it has its own memory, can process
instructions and data, and has dedicated input/output functionality.
A microcontroller has both RAM and ROM, as well as input and output ports. Like all
microprocessors instructions are executed in an ordered manner, the speed of which is
dictated by the micro’s internal oscillator (clock).
Digital Technologies 91638 (3.47)
Page 2 of 13
Exemplar for Excellence
A microcontroller is necessary in the model elevator context to be able to respond to
sensory data, such as button presses, control the motor satisfactorily and react to
emergencies. . Most microcontroller types have enough in/out pins and can support the
features such as ADC, DAC, pwm and interrupts that are needed for the elevator, so the
actual choice is a wide one.
There are many different families of microcontrollers- PICAXE, Arduino, Basic Stamp,
ARM, Atmel etc. Each family and each particular chip within the family has different
capabilities- e.g. motor control, analogue sensing, memory capability etc. The particular
device chosen for a task will also be affected by price, availability, programming
language and so forth.
A microcontroller is necessary in the model elevator context to be able to respond to
sensory data, such as button presses, control the motor satisfactorily and react to
emergencies. There is a wide range of devices that could be chosen- for the purpose of
this context a chip was selected from the PICAXE range as these are easy to
programme (PICAXE Basic), they are cheap and there is a great deal of support from
the education provider and on online forums. I am also familiar with these chips, having
worked with them since Year 10.
The memory capacity of a microcontroller is divided between RAM and ROM. RAM
capacity is usually quite small (typically 256 bytes used for things like values of
variables) and ROM capacity may be both non-erasable ROM (the basic functionality of
the chip and may also include bootstrap and interpreter programmes) as well as
rewritable ROM, but non-volatile (remains even if power is switched off) so that the
micro can be programmed for many purposes if necessary. This can be EEPROM or
flash-EEPROM.
There are three sorts of memory in the PICAXE- Programme memory (usually stored in
Flash (a type of easily written/ erased EEPROM), data memory (standard EEPROM)
and RAM (where the variables are stored as the programme is run).
I have drawn up a diagram that helps me understand how memory is allocated in a
typical PICAXE chip. The memory sizes given are typical, but vary widely with chip type.
I also give the function of some of these areas.
Digital Technologies 91638 (3.47)
Page 3 of 13
Exemplar for Excellence
Flash EEPROM
2048 bytes
This is where up to 1800 lines of programme can be
stored. Does not disappear when power turns off.
EEPROM
256 bytes
This is data memory (constants or variables). Remains
even when power is turned off.
RAM
256 bytes
This is used for temporary data storage when the
programme is run- this data is lost when power is off.
Scratchpad memory
(only in X series chips)
Table memory
256 bytes
To select a chip that meets my requirements for the elevator I looked first at the table
below (from a popular book: ‘PICAXE for the Evil Genius’).
.
PICAXE chip family characteristics
Educational line
PICAXE Processor
Advanced line
08M2
14M2
18M2
20M2
28X1
40X1
20X2
28X2
40X2
8
14
18
20
28
40
20
28
40
10-bit ADC Input Pins
Touch input Pins
6
12
16
18
22
33
18
22
33
PWM output Pins
3
7
10
11
4
7
11
9
12
3
7
10
11
-
-
-
-
-
1
4
2
4
2
2
1
2
2
-
-
-
-
-
-
2
3
3
200
600
600
600
1000
1000
1000
4000*
4000*
28
28
28
28
28
28
56
56
56
48
256
*
-t
o
t
256
a
l
32
256
256
96
96
128
256
256
-
-
128
128
128
1024
1024
256
256
256
256
256
256
256
32
32
20
20
64
40
40
Pins
I/O Pins
Hardware Interrupt Pins
Approx no. code lines
Gen purpose vars (bytes)
Peek/poke storage vars (bytes)
Get/put Scratchpad vars (bytes)
Data (EEPROM) Memory (bytes)
Maximum speed (MHz)
256**
32
f
or 4 program slots
**data memory stored with program memory
Digital Technologies 91638 (3.47)
Page 4 of 13
Exemplar for Excellence
Firstly, an educational line chip will suffice for my model elevator. The basic clock speed
of these chips is 8MHz which gives a fast enough programme execution, but it can be
overclocked to 32 MHz if desired.
Programme memory is recorded in the table as about 600 lines, but the latest M2 chips
can store and handle up to 1800 lines of code. The functions I require for the model are
fairly simple, so I don’t expect to get anywhere near this. Also as my programming gets
smarter, I expect the programme to be more economic in length.
There are sufficient I/O pins for my needs in the chips above the basic 08M2 and ADC
functionality to spare. I am just going to be monitoring 4 sensors in the shaft, two
external lift buttons and the current drawn by the motor.
The PICAXE 14M2 was chosen as a microcontroller suitable for the model elevator as it
is cheap, has plenty of memory capacity and sufficient I/O pins for this, can output pwm
(pulse width modulation) to the H-bridge that drives the motor (more than one pin can
do this if I decide to have an extra motor for the lift doors) and can feed data to the LCD
display(s) (via the sertxd command). This chip also supports the processing of the flags
and interrupts needed for the elevator scenario.
The specialised commands available on this chip (hserout/hserin- high speed serial
data transmission; hpwm; hI2C- communications between chips; true DAC etc.) are not
needed for the basic elevator model, but would be useful if the design were to be
extended in the future. This, plus the fact the chip is very cheap, support its choice here.
2. H-bridge
Concept: an H-bridge is a complex subsystem that can pass current through a motor in
either direction, controlling speed, and direction of rotation of the motor.
An H-bridge is a complex hardware subsystem, either with separate transistors or
integrated on a chip, that allows power to be supplied to a motor as well as allowing the
direction of rotation of the motor to be reversed.
The L293 and L298 are commonly used examples of an H-bridge on a chip. Each chip
can control two motors. The L298 has current sensing capability, which we can use to
detect motor overload.
The H-bridge is used in the model elevator context to allow motor speed control
(through PWM, pulse-width modulation) and reversal of motor direction, so that the lift
will be able to move smoothly up or down.
Digital Technologies 91638 (3.47)
Page 5 of 13
Exemplar for Excellence
+
-
-
The diagram represents the principle of the H-bridge.
Current can flow through the motor in either direction,
because of the way it is connected. The switches can be
mechanical, but for electronic control switching should be
by transistors. We need to use an H-bridge for the
elevator to enable the motor to both raise and lower the car in a controlled manner.
The L293D (D stands for ‘diode-protected’) is a cheap and readily available H-bridge on
a chip. Here is its pinout. It can drive two motors- one on each side of the chip. This
could allow us to install an auxiliary motor in the model, to open and close the lift door,
for example. The motor connections are 1Y and 2Y; and 3Y and 4Y. The ‘A’ pins are
where the pwm (pulse-width modulated) signal from the microcontroller is applied, to
control the speed and direction of the motor(s). The ‘EN’ (enable) pins give us the ability
to shut either half of the H-bridge down, which is useful in an emergency, such as when
the lift is overloaded, or the motor is overheating for some reason.
L293D pinout
If we want to check for overload conditions, as when too many people get into the lift at
once, or the motor is put under stress for any reason (maybe through a partial stall),
then we need some form of current load sensing capability. As the L293D doesn’t have
inbuilt current-sensing, we would need to rig something up, like a resistive divider. Two
low-value resistors connected between the L293D and the power supply rail with a
serial link to the PICAXE (as shown in the schematic at the start of this report) would be
able to detect a rise in current to the H-bridge as an elevated voltage. This could be set
up as an interrupt to stop normal operation until the condition was rectified e.g. people
get out of the lift.
Digital Technologies 91638 (3.47)
Page 6 of 13
Exemplar for Excellence
However there is a better option. The
L298D chip has two current sensing
pins at 1 and 15 and voltage rises
detected at the top of the resistors
here can be fed to the PICAXE as
shown and appropriate action
programmed into the software.
Another consideration is the load current drawn by the lift motor from the H-bridge. A
sudden surge can easily burn out the chip. The L293D is rated at a maximum of only
0.6A. We need to be sure that this is not exceeded in our elevator. Here again the
L298D option is attractive- it is a brute of a motor driver, designed for up driving 4
amperes at 46 volts.
External protection diodes are advised, to protect against voltage back-spikes (the
motor is an inductive load) that could damage the chips in the project. These diodes are
connected across the motor as shown. Even with the ‘D’ version of the L298 it is good
practice to fit external diodes.
Overheating of the chip can also be a problem. The L298D comes in two packages: the
Multiwatt and the PowerSO20. The multiwatt version features offset pins with a lug for a
heatsink to be fitted (this is important hardware for H-bridges!) and so allows for
A heatsink can also be fitted to the PowerSO20, but this is a less effective configuration.
However this chip can be ‘piggy-backed’ on another and corresponding pins soldered to
each other (an unlikely solution- but it works!) The use of an H-bridge also allows for
motor-braking which can assist the pwm control here. A ‘fast motor stop’ option is
desirable in the lift context, but as motor braking creates a rise in current, we have to be
careful the absolute maximum rating.
(from Wikipedia)
If one wants to go the whole hog (as when a bigger motor is used in a scaled-up
Digital Technologies 91638 (3.47)
Page 7 of 13
Exemplar for Excellence
project) an H-bridge can be built from discrete MOSFETs, which can allow current
draws of hundreds of amps if you needed it! The expense and physical size of this
option are a drawback, however.
For the reasons discussed, I have decided to replace the L293D with the L298D in my
model elevator design.
3. FET (Field-effect transistor)
Concept: a FET is a transistor that uses an electric field to control the shape and hence
the conductivity of a semiconductor channel.
The concept behind the operation of a FET is quite different to that of a BJT. The BJT is
current operated and the FET voltage operated. FETs utilise only one type of charge
carrier (BJTs use two), have very high input impedance, low noise, low power losses
and better temperature stability.
There are two main types of FETs: the Junction gate FET (JFET) and the metal-oxide
semiconductor FET (MOSFET). JFETs and MOSFETs use both n- and p-type silicon in
their construction; the MOSFET has an additional layer of insulating oxide between the
metal gate electrode and the n- or p- type silicon that the gate is made of.
A p-type MOSFET
When a negative voltage is applied to the gate the n-type region next to the gate oxide
layer is partially converted to p-type and a current can then flow from the drain to the
source.
A typical motor adequate for the model elevator context would not need to be very large
or demanding of power. Here an H-bridge chip would suffice. However, if a much larger
motor was required (if the model were to be scaled up), the H-bridge could be
constructed of high-power MOSFETs, because of their capacity to deliver larger
currents.
These features, along with the MOSFET’s capacity to deliver large currents (hence
power) to a motor, would suit it for use in an H-bridge in the elevator context if the Hbridge wasn’t adequate.
4. Multiple sensors
Concept: inputs from different sensors (of type and number) can be detected (by a
microcontroller, for instance) and appropriate action taken.
Sensors are components (thermistor, LDR, Hall-effect device, Dallas temperature 1-wire
device, optical encoder e.t.c) set in their own subsystem. This will invROYHVXSSRUWLQJ
Digital Technologies 91638 (3.47)
Page 8 of 13
Exemplar for Excellence
components such as resistors, capacitors and diodes and a circuit layout that suits the
sensor component. The sensor subsystem has to be able to deliver a measurable
output at a suitable level over the range of conditions the sensor is likely to encounter in
the context it is in (the electronic environment).
The proximity sensors used in the lift shaft serve as input sensors to allow the
microcontroller to detect the position of the lift in the shaft. There are multiple sensors to
allow the lift to know where it is and in what direction it is travelling, so the behaviour of
the motor can be properly controlled.
Here is a state table that shows how the sensors P1-P4 can provide information of this
sort. ‘1’ means the lift is covering the sensor; ‘0’ means the sensor is uncovered.
Because of the size of the lift and the spacing of the sensors, these are the only states
possible.
P1
P2
P3
P4
Lift state
1
0
0
0
Level G – may be stopped, accelerating or decelerating
0
1
0
0
Mostly in G zone- accelerating (up) or decelerating (down)
0
1
1
0
Between floors- constant speed zone
0
0
1
0
Mostly in Level 1 zone- decelerating (up) or accelerating (down)
0
0
0
1
Level 1- may be stopped, accelerating or decelerating
The software can be set up to recognise these states and respond accordingly.
5. LCD (liquid crystal display)
Concept: a flat panel that uses the light modulating properties of liquid crystals to
display letters, digits or graphics.
A liquid-crystal display (LCD) is matrix of ‘cells’ or pixels, containing a light-sensitive
organic substance, arranged in a thin layer. Each cell is connected to an electrical
contact. When a voltage signal is sent to the contact point (usually a transistor switch),
the pixel goes dark and light because the organic crystals twist and untwist. This allows
messages, numbers or graphics to be displayed. LCDs are usually controlled through a
parallel connection, but software can be written interpret serial data as well, the
advantage then being only a one wire connection is needed.
Digital Technologies 91638 (3.47)
Page 9 of 13
Exemplar for Excellence
The LCD is used in the model elevator to indicate what the lift is doing in terms of
position and travelling direction. This messaging could be upgraded to display other
information as well e.g. ‘lift overloaded.’ LCDs could also be added at each floor level to
tell those waiting what the lift is doing.
Complex software concepts
1. Bitwise logic
Concept: combining single bits using logical AND, OR and XOR operations.
Bit-wise logic is about performing the logic operations NOT, AND, OR, XOR on binary
numbers, treating each bit individually rather than as part of the whole number.
Since individual bits (0 or 1) can represent useful information, like the state of a register
in memory, or whether there is a signal present at an input or not, or whether a button
has been pressed etc., bitwise logic is a very useful tool in microcontroller programming.
For example, an ‘AND’ operation may be used to determine whether a particular bit is
‘set’ (1) or ‘clear’; (0). Say there is a bit pattern 0011 (this could represent inputs 0 and 1
being ‘high’, for example) and we want to know whether the second bit is set. Then all
we have to do is logically ‘AND’ the unknown bit pattern with 0010. Thus 0011 AND
0010 = 0010.
Since we get a ‘1’ in the second position, this tells us the unknown bit pattern has a ‘1’
in that position too and is therefore ‘set’. One use of this information might be for when
we want to clear the register.
The state of the lift car (position in the lift shaft and direction of travel) needs to be
continually checked. If the information from the digital sensor inputs in the shaft is
expressed as a binary number variable then bitwise logic can be used to check any
input state.
2. Interrupts
Concept: interrupt- a special signal triggered by an emergency situation that halts the
execution of a program or device until the situation is able to be dealt with and normal
operation can be resumed.
The program has to check for the presence of interrupt conditions constantly. If an
interrupt is activated, normal routine is suspended and an interrupt subroutine (which
tells the microcontroller ‘what to do in this emergency’) is activated. When the interrupt
has been serviced, the microcontroller will resume normal operation.
There are two types of interrupts, software and hardware. A software interrupt is driven
by a software instruction and a hardware interrupt is the result of external causes.
The difference between ‘hardware’ and ‘software’ interrupts is that a hardware interrupt
(which may be due to a priority signal being received, or a failure of an external device,
for example) is linked to the micro by a direct control line that can suspend what it is
doing. A ‘reset’ switch being pressed is the simplest type of example. For the lift context,
this may be when somebody has pressed the emergency stop. Hardware interrupts are
a more direct method of intervention than software interrupts, which generally involve
the program ‘polling’ (systematically checking) the inputs. Software interrupts use up
processor time. The PICAXE checks for software interrupt conditions between each line r for Excellence
of code.
An example of an interrupt in the elevator context might be a situation where too many
people get into the lift so that it is overloaded. The lift will stop until the situation is
addressed. The interrupt routine overrides all other lift procedures.
3. Serial data transmission
Concept: sending data sequentially along a single wire or wirelessly as a data stream.
serial data transmission is the sending of data one bit at a time. It is cheaper and more
efficient than parallel data transmission for long distances, although slower, but clock
speed can be increased to compensate. It also requires fewer pins (valuable ‘real
estate’ on a microcontroller).
There are different protocols (systems of transmission) for serial data transmission. The
simplest (and still useful) is Morse code, but there are many others- using one, two or
three wires depending on the protocol and the application- RS232 (low-speed), RS485,
I²C (inter-integrated circuit), SPI (serial peripheral interface), USB (universal serial bus),
1-wire, Ethernet etc. A ‘bus’ means both the hardware and software needed to transmit
the data stream.
In the model elevator information about the position of the lift is gathered from the shaft
sensors. This information is processed by the microcontroller which then sends
messages (data) about the lift position and direction of travel via a serial link to the LCD
screen inside the lift.
4. Structuring complex programmes
Concept: Optimising the layout, elegance and efficiency of a software programme so
that it can be readily understood, debugged and improved.
‘Structuring good-practice’ can include using symbols, labels, indentation, annotation,
and specialised commands etc. to improve the format, clarity and execution time for a
programme.
The features of the program below are:
•
•
•
•
•
•
Multiple subroutines to process interrupts and overload conditions.
Complex Interrupt programming. Multiple input interrupt on 0, 1 and 2 on Port C.
Logical OR extension is used along with correct mask and logic polarity.
Processing of the interrupt. This makes the code more efficient and shortens
several routines in the main loop.
Load sensing from the H bridge internal –ve shunt sensing point (or can use an
external 1 ohm resistor that can be used to monitor the load on the motor (i.e. lift
loading ) and here just generates a warning message + LED + Buzzer during
acceleration if too much load is detected
Programming directives have been added to the header as an additional level of
sophistication in setting up the features of the programming editor and tweaking
the programming environment
Digital Technologies 91638 (3.47)
Page 11 of 13
Exemplar for Excellence
This causes:
-Motor to stop immediately
-Red Overload LED turns on
-Buzzer alarm turns on
-Overload message
Digital Technologies 91638 (3.47)
Page 12 of 13
Exemplar for Excellence
5. ADC and DAC (analogue to digital and digital to analogue conversion)
Concept:
ADC- Continuous values (as in binary numbers) can be converted to discrete values.
DAC- Discrete values (as in binary numbers) can be converted to continuous values.
ADC is hard-wired into most microcontrollers so that they can deal with measurements
from the real world like temperature and light levels. Because the microcontroller only
works with digital representations of data, it’s important this conversion takes place.
Analogue to digital conversion is the ‘chopping up’ of a smooth signal into discrete
steps, each step being represented by a digital value. The ‘resolution’ of the digital
values produced is given by the number of bits in the value e.g. 8-bit resolution allows
the digital signal to take up 256 different values. ADC is commonly used to convert
values from real-world variables (temperature, light level etc.) into binary numbers that
the computer can process.
Digitising an analogue signal (5-bit resolution)
In the elevator context, ADC occurs when the motor
overload circuit returns a voltage value to the PICAXE input it is connected to.
In the elevator context ADC can be used to convert the voltage generated by the current
sensor network into digital data that the programme can test for overload conditions.
This is a safety feature that ensures that there are not too many people in the lift- if
there are, the programme will interrupt normal operation.
When a microcontroller programme (digital) is controlling an analogue device, such as a
motor, the binary numbers that the microcontroller sends out needs to be ‘smoothed
out’ so that the motor doesn’t move jerkily. This involves DAC.
Digital to analogue conversion is the conversion of a binary number whose value is
represented in discrete steps into a continuous value number e.g. a computer
programme might generate data as bytes and a DAC convertor change this data into a
continuously varying value.
Motor speed and direction is controlled by the PWM (pulse-width modulated) signal that
the PICAXE sends out. In the elevator context the PWM command performs a sort of
DAC. PWM (pulse-width modulation) generates a square wave signal with ‘off’ and ‘on’
sections (therefore digital). When the PWM is applied to the lift motor, it changes speed
smoothly (analogue), not in jumps. The PWM is not true analogue, but can be made to
be a close approximation to it.
Digital Technologies 91638 (3.47)
Page 13 of 13
Exemplar for Excellence
Level 3 Digital Technologies 91638 (3.47)
Title
Demonstrate understanding of complex concepts used in the
design and construction of electronic environments
Credits
4
EXEMPLAR FOR EXCELLENCE
PRINTABLE ANNOTATED VERSION
Summary of Comments on 3.47 Excellence Exemplar
Page: 1
Author:
Date: 11/12/12 11:16:45 AM
This is a very clear example of a good Excellence grade report. Some of the concepts are not individually explored at the excellence level. Each part of
the candidate’s report makes some contribution to demonstrating either breadth or depth of understanding. With a number of key concepts;
Microcontroller, H-bridge, and Program Structuring the candidate offers linked detailed accurate explanations that relate the concepts to the whole within
the specific environment of the elevator.
Author:
Date: 3/10/12 8:19:42 AM
Relating understanding to a context helps validate the student’s understanding.
Report for 3.47: 'HPRQVWUDWHXnderstanding RIcomplex concepts XVHGLQWKHGHVLJQDQG
FRQVWUXFWLRQRIHOHFWURQLFHQYLURQPHQWV
Specification:
My design for a model elevator (lift) which will help explain the hardware and software
concepts I have chosen is the two-floor (G & 1), two-call button type. There is a call
button on each floor and an LCD display panel inside the lift. The motor that raises and
lowers the lift is reversible. It is connected to the lift cables through a gearbox and
pulleys (not shown). Sensors (P1- P4) positioned near the bottom and top of each level
on the lift shaft wall signal the motor controller to manage the speed of the lift as it
moves. The motor control circuit uses an H-bridge type that contains an inbuilt current
sensor (this can be used as a safety feature to detect when the lift is overloaded and to
prevent it moving off). A PICAXE microcontroller is programmed to operate the lift.
Diagram of a model elevator
P1-P4 are sensors in the lift shaft
to enable the lift to know where
it is and in what direction it is
travelling. This is needed to
control motor speed and
acceleration and deceleration.
The LCD panel is inside the lift.
Digital Technologies 91638 (3.47)
Page 1 of 13
Exemplar for Excellence
Author:
Date: 3/10/12 8:19:49 AM
A diagram of the elevator clarifies the description given of the context in the specification.
Page: 2
Circuit schematic
Author:
Date: 3/10/12 8:19:58 AM
This schematic summarises the hardware & connections required for the control of the model elevator.
Here is a block diagram of the model lift control system.
Author:
Date: 3/10/12 8:20:04 AM
A selection has been made from the hardware and software concepts listed in Standard 3.47 that suit the context of the
Elevator.
+
Author:
Date: 11/12/12 11:17:06 AM
In what follows the candidate has defined and described the concept and offered several linked explanations which draw together in a discussion about
the evaluation and selection of the particular controller. The candidate’s discussion is both broad and deep and therefore comprehensive.
Current
sensor line
Inputs for limit
switch sensors
H-bridge
control lines
L293D
Multiple
switch
sensors
Multiple
switch
sensors
Serial data to
LCD
Inputs for button
press sensors
My report demonstrates understanding for five software and five hardware concepts
using the elevator (building lift) context.
Complex hardware concepts:
Microcontroller, H-bridge with speed control, FET operation, multiple sensors, LCD
display
Complex software concepts:
Bitwise logic, flags and interrupts, serial data transmission, structuring complex
programmes, ADC and DAC (analogue to digital and digital to analogue conversion).
Complex hardware concepts
1. Microcontroller
The microcontroller represents the concept of a small computer on a single integrated
circuit with inputs and outputs and with processing and memory capacity.
A microcontroller is a ‘computer-on-a-chip', as it has its own memory, can process
instructions and data, and has dedicated input/output functionality.
A microcontroller has both RAM and ROM, as well as input and output ports. Like all
microprocessors instructions are executed in an ordered manner, the speed of which is
dictated by the micro’s internal oscillator (clock).
Digital Technologies 91638 (3.47)
Page 2 of 13
Exemplar for Excellence
This page contains no comments
A microcontroller is necessary in the model elevator context to be able to respond to
sensory data, such as button presses, control the motor satisfactorily and react to
emergencies. . Most microcontroller types have enough in/out pins and can support the
features such as ADC, DAC, pwm and interrupts that are needed for the elevator, so the
actual choice is a wide one.
There are many different families of microcontrollers- PICAXE, Arduino, Basic Stamp,
ARM, Atmel etc. Each family and each particular chip within the family has different
capabilities- e.g. motor control, analogue sensing, memory capability etc. The particular
device chosen for a task will also be affected by price, availability, programming
language and so forth.
A microcontroller is necessary in the model elevator context to be able to respond to
sensory data, such as button presses, control the motor satisfactorily and react to
emergencies. There is a wide range of devices that could be chosen- for the purpose of
this context a chip was selected from the PICAXE range as these are easy to
programme (PICAXE Basic), they are cheap and there is a great deal of support from
the education provider and on online forums. I am also familiar with these chips, having
worked with them since Year 10.
The memory capacity of a microcontroller is divided between RAM and ROM. RAM
capacity is usually quite small (typically 256 bytes used for things like values of
variables) and ROM capacity may be both non-erasable ROM (the basic functionality of
the chip and may also include bootstrap and interpreter programmes) as well as
rewritable ROM, but non-volatile (remains even if power is switched off) so that the
micro can be programmed for many purposes if necessary. This can be EEPROM or
flash-EEPROM.
There are three sorts of memory in the PICAXE- Programme memory (usually stored in
Flash (a type of easily written/ erased EEPROM), data memory (standard EEPROM)
and RAM (where the variables are stored as the programme is run).
I have drawn up a diagram that helps me understand how memory is allocated in a
typical PICAXE chip. The memory sizes given are typical, but vary widely with chip type.
I also give the function of some of these areas.
Digital Technologies 91638 (3.47)
Page 3 of 13
Exemplar for Excellence
This page contains no comments
Flash EEPROM
2048 bytes
This is where up to 1800 lines of programme can be
stored. Does not disappear when power turns off.
EEPROM
256 bytes
This is data memory (constants or variables). Remains
even when power is turned off.
RAM
256 bytes
This is used for temporary data storage when the
programme is run- this data is lost when power is off.
Scratchpad memory
(only in X series chips)
Table memory
256 bytes
To select a chip that meets my requirements for the elevator I looked first at the table
below (from a popular book: ‘PICAXE for the Evil Genius’).
.
PICAXE chip family characteristics
Educational line
PICAXE Processor
Advanced line
08M2
14M2
18M2
20M2
28X1
40X1
20X2
28X2
40X2
8
14
18
20
28
40
20
28
40
10-bit ADC Input Pins
Touch input Pins
6
12
16
18
22
33
18
22
33
PWM output Pins
3
7
10
11
4
7
11
9
12
3
7
10
11
-
-
-
-
-
1
4
2
4
2
2
1
2
2
-
-
-
-
-
-
2
3
3
Pins
I/O Pins
Hardware Interrupt Pins
Approx no. code lines
Gen purpose vars (bytes)
Peek/poke storage vars (bytes)
Get/put Scratchpad vars (bytes)
200
600
600
600
1000
1000
1000
4000*
4000*
28
28
28
28
28
28
56
56
56
48
256
*
-t
o
t
256
a
l
32
256
256
96
96
128
256
256
-
-
128
128
128
1024
1024
256
256
256
256
256
256
256
32
32
20
20
64
40
40
Data (EEPROM) Memory (bytes)
Maximum speed (MHz)
256**
32
f
or 4 program slots
**data memory stored with program memory
Digital Technologies 91638 (3.47)
Page 4 of 13
Exemplar for Excellence
Firstly, an educational line chip will suffice for my model elevator. The basic clock speed
of these chips is 8MHz which gives a fast enough programme execution, but it can be
overclocked to 32 MHz if desired.
Programme memory is recorded in the table as about 600 lines, but the latest M2 chips
can store and handle up to 1800 lines of code. The functions I require for the model are
fairly simple, so I don’t expect to get anywhere near this. Also as my programming gets
smarter, I expect the programme to be more economic in length.
There are sufficient I/O pins for my needs in the chips above the basic 08M2 and ADC
functionality to spare. I am just going to be monitoring 4 sensors in the shaft, two
external lift buttons and the current drawn by the motor.
The PICAXE 14M2 was chosen as a microcontroller suitable for the model elevator as it
is cheap, has plenty of memory capacity and sufficient I/O pins for this, can output pwm
(pulse width modulation) to the H-bridge that drives the motor (more than one pin can
do this if I decide to have an extra motor for the lift doors) and can feed data to the LCD
display(s) (via the sertxd command). This chip also supports the processing of the flags
and interrupts needed for the elevator scenario.
The specialised commands available on this chip (hserout/hserin- high speed serial
data transmission; hpwm; hI2C- communications between chips; true DAC etc.) are not
needed for the basic elevator model, but would be useful if the design were to be
extended in the future. This, plus the fact the chip is very cheap, support its choice here.
2. H-bridge
Concept: an H-bridge is a complex subsystem that can pass current through a motor in
either direction, controlling speed, and direction of rotation of the motor.
An H-bridge is a complex hardware subsystem, either with separate transistors or
integrated on a chip, that allows power to be supplied to a motor as well as allowing the
direction of rotation of the motor to be reversed.
The L293 and L298 are commonly used examples of an H-bridge on a chip. Each chip
can control two motors. The L298 has current sensing capability, which we can use to
detect motor overload.
The H-bridge is used in the model elevator context to allow motor speed control
(through PWM, pulse-width modulation) and reversal of motor direction, so that the lift
will be able to move smoothly up or down.
Digital Technologies 91638 (3.47)
Page 5 of 13
Exemplar for Excellence
Page: 5
Author:
Date: 11/12/12 1:24:37 PM
In what follows the candidate has defined and described the concept and offered several linked explanations which draw together in a
discussion about the evaluation and selection a particular H bridge. The report also makes linkages that relate the subsystems within the
context of the block diagram and the lift operation.
This page contains no comments
+
-
-
The diagram represents the principle of the H-bridge.
Current can flow through the motor in either direction,
because of the way it is connected. The switches can be
mechanical, but for electronic control switching should be
by transistors. We need to use an H-bridge for the
elevator to enable the motor to both raise and lower the car in a controlled manner.
The L293D (D stands for ‘diode-protected’) is a cheap and readily available H-bridge on
a chip. Here is its pinout. It can drive two motors- one on each side of the chip. This
could allow us to install an auxiliary motor in the model, to open and close the lift door,
for example. The motor connections are 1Y and 2Y; and 3Y and 4Y. The ‘A’ pins are
where the pwm (pulse-width modulated) signal from the microcontroller is applied, to
control the speed and direction of the motor(s). The ‘EN’ (enable) pins give us the ability
to shut either half of the H-bridge down, which is useful in an emergency, such as when
the lift is overloaded, or the motor is overheating for some reason.
L293D pinout
If we want to check for overload conditions, as when too many people get into the lift at
once, or the motor is put under stress for any reason (maybe through a partial stall),
then we need some form of current load sensing capability. As the L293D doesn’t have
inbuilt current-sensing, we would need to rig something up, like a resistive divider. Two
low-value resistors connected between the L293D and the power supply rail with a
serial link to the PICAXE (as shown in the schematic at the start of this report) would be
able to detect a rise in current to the H-bridge as an elevated voltage. This could be set
up as an interrupt to stop normal operation until the condition was rectified e.g. people
get out of the lift.
Digital Technologies 91638 (3.47)
Page 6 of 13
Exemplar for Excellence
This page contains no comments
However there is a better option. The
L298D chip has two current sensing
pins at 1 and 15 and voltage rises
detected at the top of the resistors
here can be fed to the PICAXE as
shown and appropriate action
programmed into the software.
Another consideration is the load current drawn by the lift motor from the H-bridge. A
sudden surge can easily burn out the chip. The L293D is rated at a maximum of only
0.6A. We need to be sure that this is not exceeded in our elevator. Here again the
L298D option is attractive- it is a brute of a motor driver, designed for up driving 4
amperes at 46 volts.
External protection diodes are advised, to protect against voltage back-spikes (the
motor is an inductive load) that could damage the chips in the project. These diodes are
connected across the motor as shown. Even with the ‘D’ version of the L298 it is good
practice to fit external diodes.
Overheating of the chip can also be a problem. The L298D comes in two packages: the
Multiwatt and the PowerSO20. The multiwatt version features offset pins with a lug for a
heatsink to be fitted (this is important hardware for H-bridges!) and so allows for
A heatsink can also be fitted to the PowerSO20, but this is a less effective configuration.
However this chip can be ‘piggy-backed’ on another and corresponding pins soldered to
each other (an unlikely solution- but it works!) The use of an H-bridge also allows for
motor-braking which can assist the pwm control here. A ‘fast motor stop’ option is
desirable in the lift context, but as motor braking creates a rise in current, we have to be
careful the absolute maximum rating.
(from Wikipedia)
If one wants to go the whole hog (as when a bigger motor is used in a scaled-up
Digital Technologies 91638 (3.47)
Page 7 of 13
Exemplar for Excellence
project) an H-bridge can be built from discrete MOSFETs, which can allow current
draws of hundreds of amps if you needed it! The expense and physical size of this
option are a drawback, however.
For the reasons discussed, I have decided to replace the L293D with the L298D in my
model elevator design.
3. FET (Field-effect transistor)
Author:
The concept behind the operation of a FET is quite different to that of a BJT. The BJT is
current operated and the FET voltage operated. FETs utilise only one type of charge
carrier (BJTs use two), have very high input impedance, low noise, low power losses
and better temperature stability.
There are two main types of FETs: the Junction gate FET (JFET) and the metal-oxide
semiconductor FET (MOSFET). JFETs and MOSFETs use both n- and p-type silicon in
their construction; the MOSFET has an additional layer of insulating oxide between the
metal gate electrode and the n- or p- type silicon that the gate is made of.
A p-type MOSFET
When a negative voltage is applied to the gate the n-type region next to the gate oxide
layer is partially converted to p-type and a current can then flow from the drain to the
source.
A typical motor adequate for the model elevator context would not need to be very large
or demanding of power. Here an H-bridge chip would suffice. However, if a much larger
motor was required (if the model were to be scaled up), the H-bridge could be
constructed of high-power MOSFETs, because of their capacity to deliver larger
currents.
These features, along with the MOSFET’s capacity to deliver large currents (hence
power) to a motor, would suit it for use in an H-bridge in the elevator context if the Hbridge wasn’t adequate.
4. Multiple sensors
Concept: inputs from different sensors (of type and number) can be detected (by a
microcontroller, for instance) and appropriate action taken.
Sensors are components (thermistor, LDR, Hall-effect device, Dallas temperature 1-wire
device, optical encoder e.t.c) set in their own subsystem. This will invROYHVXSSRUWLQJ
Page 8 of 13
Exemplar for Excellence
Date: 3/10/12 8:20:22 AM
Defines the concept, describes the complex hardware concept, and applies it to the context.
This component of the report is at the achieved level. The standard does not require every concept considered to be at the
excellence level. In this case consideration of the FET makes a contribution to the breath of the report. Decisions about the
appropriate grade are made using the criteria applied to the report as a whole. The question the marker asks is, ‘Does the
report on the whole, demonstrate comprehensive understanding of complex concepts used in the design and construction
of electronic environments?
Author:
Concept: a FET is a transistor that uses an electric field to control the shape and hence
the conductivity of a semiconductor channel.
Digital Technologies 91638 (3.47)
Page: 8
Date: 3/10/12 8:20:31 AM
Defines the hardware concept, describes the hardware concept, and applies it to the context. The functional arrangement of the sensor
set up is explained in context.
This component of the report is at the merit level. The standard does not require every concept considered to be at the
excellence level. In this case consideration of the sensors makes a contribution to the breath of the report. Decisions about the
appropriate grade are made using the criteria applied to the report as a whole. The question the marker asks is, ‘Does the
report on the whole, demonstrate comprehensive understanding of complex concepts used in the design and construction
of electronic environments?
components such as resistors, capacitors and diodes and a circuit layout that suits the
sensor component. The sensor subsystem has to be able to deliver a measurable
output at a suitable level over the range of conditions the sensor is likely to encounter in
the context it is in (the electronic environment).
The proximity sensors used in the lift shaft serve as input sensors to allow the
microcontroller to detect the position of the lift in the shaft. There are multiple sensors to
allow the lift to know where it is and in what direction it is travelling, so the behaviour of
the motor can be properly controlled.
Here is a state table that shows how the sensors P1-P4 can provide information of this
sort. ‘1’ means the lift is covering the sensor; ‘0’ means the sensor is uncovered.
Because of the size of the lift and the spacing of the sensors, these are the only states
possible.
P1
P2
P3
P4
Lift state
1
0
0
0
Level G – may be stopped, accelerating or decelerating
0
1
0
0
Mostly in G zone- accelerating (up) or decelerating (down)
0
1
1
0
Between floors- constant speed zone
0
0
1
0
Mostly in Level 1 zone- decelerating (up) or accelerating (down)
0
0
0
1
Level 1- may be stopped, accelerating or decelerating
The software can be set up to recognise these states and respond accordingly.
5. LCD (liquid crystal display)
Concept: a flat panel that uses the light modulating properties of liquid crystals to
display letters, digits or graphics.
A liquid-crystal display (LCD) is matrix of ‘cells’ or pixels, containing a light-sensitive
organic substance, arranged in a thin layer. Each cell is connected to an electrical
contact. When a voltage signal is sent to the contact point (usually a transistor switch),
the pixel goes dark and light because the organic crystals twist and untwist. This allows
messages, numbers or graphics to be displayed. LCDs are usually controlled through a
parallel connection, but software can be written interpret serial data as well, the
advantage then being only a one wire connection is needed.
Digital Technologies 91638 (3.47)
Page 9 of 13
Exemplar for Excellence
Page: 9
Author:
Date: 3/10/12 8:20:51 AM
Defines the concept, describes the complex hardware concept, and applies it to the context. This component of the report is at the achieved level. The
standard does not require every concept considered to be at the excellence level. In this case consideration of the LCD makes a contribution to the breath
of the report. Decisions about the appropriate grade are made using the criteria applied to the report as a whole. The question the marker asks is, ‘Does
the report on the whole, demonstrate comprehensive understanding of complex concepts used in the design and construction of electronic
environments?
Page: 10
The LCD is used in the model elevator to indicate what the lift is doing in terms of
position and travelling direction. This messaging could be upgraded to display other
information as well e.g. ‘lift overloaded.’ LCDs could also be added at each floor level to
tell those waiting what the lift is doing.
Complex software concepts
1. Bitwise logic
Author:
Date: 3/10/12 8:20:58 AM
Defines the hardware concept, describes the hardware concept, and applies it to the context. The aspect of this section of the
report that deals with the function is more descriptive than explanatory.
This concept is described with a partial explanation. Within any electronic environment there might be a number of conceptual
processes that are important for understanding function within the environment, which do not need to be explored in depth.
Addressing these components does assist the marker to make decisions as to the breadth of the candidate’s understanding.
Author:
Date: 3/10/12 8:21:10 AM
Defines the software concept, describes the software concept, and applies it to the context. The text is more descriptive than explanatory.
Concept: combining single bits using logical AND, OR and XOR operations.
Bit-wise logic is about performing the logic operations NOT, AND, OR, XOR on binary
numbers, treating each bit individually rather than as part of the whole number.
Since individual bits (0 or 1) can represent useful information, like the state of a register
in memory, or whether there is a signal present at an input or not, or whether a button
has been pressed etc., bitwise logic is a very useful tool in microcontroller programming.
For example, an ‘AND’ operation may be used to determine whether a particular bit is
‘set’ (1) or ‘clear’; (0). Say there is a bit pattern 0011 (this could represent inputs 0 and 1
being ‘high’, for example) and we want to know whether the second bit is set. Then all
we have to do is logically ‘AND’ the unknown bit pattern with 0010. Thus 0011 AND
0010 = 0010.
Since we get a ‘1’ in the second position, this tells us the unknown bit pattern has a ‘1’
in that position too and is therefore ‘set’. One use of this information might be for when
we want to clear the register.
The state of the lift car (position in the lift shaft and direction of travel) needs to be
continually checked. If the information from the digital sensor inputs in the shaft is
expressed as a binary number variable then bitwise logic can be used to check any
input state.
2. Interrupts
Concept: interrupt- a special signal triggered by an emergency situation that halts the
execution of a program or device until the situation is able to be dealt with and normal
operation can be resumed.
The program has to check for the presence of interrupt conditions constantly. If an
interrupt is activated, normal routine is suspended and an interrupt subroutine (which
tells the microcontroller ‘what to do in this emergency’) is activated. When the interrupt
has been serviced, the microcontroller will resume normal operation.
There are two types of interrupts, software and hardware. A software interrupt is driven
by a software instruction and a hardware interrupt is the result of external causes.
The difference between ‘hardware’ and ‘software’ interrupts is that a hardware interrupt
(which may be due to a priority signal being received, or a failure of an external device,
for example) is linked to the micro by a direct control line that can suspend what it is
doing. A ‘reset’ switch being pressed is the simplest type of example. For the lift context,
this may be when somebody has pressed the emergency stop. Hardware interrupts are
a more direct method of intervention than software interrupts, which generally involve
the program ‘polling’ (systematically checking) the inputs. Software interrupts use up
processor time. The PICAXE checks for software interrupt conditions between each line r for Excellence
This concept is described with a partial explanation. Within any electronic environment there might be a number of conceptual processes that are
important for understanding function within the environment, which do not need to be explored in depth.
Addressing these components does assist the marker to make decisions as to the breadth of the candidate’s understanding.
Page: 11
of code.
Author:
An example of an interrupt in the elevator context might be a situation where too many
people get into the lift so that it is overloaded. The lift will stop until the situation is
addressed. The interrupt routine overrides all other lift procedures.
Date: 3/10/12 8:21:17 AM
Defines the software concept, describes the software concept, and applies it to the context.
This concept is described with a partial explanation. Within any electronic environment there might be a number of conceptual
processes that are important for understanding function within the environment, which do not need to be explored in depth.
Addressing these components does assist the marker to make decisions as to the breadth of the candidate’s understanding.
3. Serial data transmission
Concept: sending data sequentially along a single wire or wirelessly as a data stream.
serial data transmission is the sending of data one bit at a time. It is cheaper and more
efficient than parallel data transmission for long distances, although slower, but clock
speed can be increased to compensate. It also requires fewer pins (valuable ‘real
estate’ on a microcontroller).
There are different protocols (systems of transmission) for serial data transmission. The
simplest (and still useful) is Morse code, but there are many others- using one, two or
three wires depending on the protocol and the application- RS232 (low-speed), RS485,
I²C (inter-integrated circuit), SPI (serial peripheral interface), USB (universal serial bus),
1-wire, Ethernet etc. A ‘bus’ means both the hardware and software needed to transmit
the data stream.
In the model elevator information about the position of the lift is gathered from the shaft
sensors. This information is processed by the microcontroller which then sends
messages (data) about the lift position and direction of travel via a serial link to the LCD
screen inside the lift.
4. Structuring complex programmes
Concept: Optimising the layout, elegance and efficiency of a software programme so
that it can be readily understood, debugged and improved.
‘Structuring good-practice’ can include using symbols, labels, indentation, annotation,
and specialised commands etc. to improve the format, clarity and execution time for a
programme.
The features of the program below are:
•
•
•
•
•
•
Multiple subroutines to process interrupts and overload conditions.
Complex Interrupt programming. Multiple input interrupt on 0, 1 and 2 on Port C.
Logical OR extension is used along with correct mask and logic polarity.
Processing of the interrupt. This makes the code more efficient and shortens
several routines in the main loop.
Load sensing from the H bridge internal –ve shunt sensing point (or can use an
external 1 ohm resistor that can be used to monitor the load on the motor (i.e. lift
loading ) and here just generates a warning message + LED + Buzzer during
acceleration if too much load is detected
Programming directives have been added to the header as an additional level of
sophistication in setting up the features of the programming editor and tweaking
the programming environment
Digital Technologies 91638 (3.47)
Page 11 of 13
Exemplar for Excellence
Author:
Date: 3/10/12 8:21:29 AM
This complex, accurate, and coherent summary of the complex contextually appropriate program structure demonstrates a considerable depth of
understanding of the concepts involved.
Page: 12
This causes:
-Motor to stop immediately
-Red Overload LED turns on
-Buzzer alarm turns on
-Overload message
Digital Technologies 91638 (3.47)
Page 12 of 13
Author:
Date: 3/10/12 8:21:37 AM
A sample of program is provided. Sophisticated processing procedures and extensions have been included- interrupts, subroutines, logic, directives This
application of the concepts above within a micro controller program is very persuasive of both breadth and depth of understanding of both hardware and
software concepts.
Exemplar for Excellence
Page: 13
Author:
5. ADC and DAC (analogue to digital and digital to analogue conversion)
Date: 3/10/12 8:21:43 AM
Defines the software concept, describes the software concept, and applies it to the context. Develops a very clear explanation of
function that deals with inputs and outputs and the effect of the output.
Concept:
ADC- Continuous values (as in binary numbers) can be converted to discrete values.
DAC- Discrete values (as in binary numbers) can be converted to continuous values.
ADC is hard-wired into most microcontrollers so that they can deal with measurements
from the real world like temperature and light levels. Because the microcontroller only
works with digital representations of data, it’s important this conversion takes place.
Analogue to digital conversion is the ‘chopping up’ of a smooth signal into discrete
steps, each step being represented by a digital value. The ‘resolution’ of the digital
values produced is given by the number of bits in the value e.g. 8-bit resolution allows
the digital signal to take up 256 different values. ADC is commonly used to convert
values from real-world variables (temperature, light level etc.) into binary numbers that
the computer can process.
Digitising an analogue signal (5-bit resolution)
In the elevator context, ADC occurs when the motor
overload circuit returns a voltage value to the PICAXE input it is connected to.
In the elevator context ADC can be used to convert the voltage generated by the current
sensor network into digital data that the programme can test for overload conditions.
This is a safety feature that ensures that there are not too many people in the lift- if
there are, the programme will interrupt normal operation.
When a microcontroller programme (digital) is controlling an analogue device, such as a
motor, the binary numbers that the microcontroller sends out needs to be ‘smoothed
out’ so that the motor doesn’t move jerkily. This involves DAC.
Digital to analogue conversion is the conversion of a binary number whose value is
represented in discrete steps into a continuous value number e.g. a computer
programme might generate data as bytes and a DAC convertor change this data into a
continuously varying value.
Motor speed and direction is controlled by the PWM (pulse-width modulated) signal that
the PICAXE sends out. In the elevator context the PWM command performs a sort of
DAC. PWM (pulse-width modulation) generates a square wave signal with ‘off’ and ‘on’
sections (therefore digital). When the PWM is applied to the lift motor, it changes speed
smoothly (analogue), not in jumps. The PWM is not true analogue, but can be made to
be a close approximation to it.
Digital Technologies 91638 (3.47)
Page 13 of 13
Exemplar for Excellence