The diagram shows a central heating system for a large building.
When the temperature falls, the operator will open the valve to increase the flow of gas to the burner, raising the temperature.
When the temperature rises, the operator will close the valve to decrease the flow of gas to the burner, lowering the temperature.
This way the temperature remains fairly constant, but the operator gets tired and will need some rest.
When the temperature falls, the temperature sensor and transmitter will send an input to the controller processor.
If the temperature is below the default value, it will give an output to the servo to open the control valve to increase the flow of gas to the burner, raising the temperature.
When the temperature rises, the temperature sensor and transmitter will send an input to the controller processor.
If the temperature is above the default value, it will give an output to the servo to close the control valve to decrease the flow of gas to the burner, lowering the temperature.
This is known as a feedback control system because the output feeds back into the input.
A change in the output - the heater brings about a change in the input - the control valve.
Because the computer controlled system reponds more quickly the temperature remains steady. This 'steady state' system is known as homeostasis.
The computer does not get tired, needs no rest and so can operate continuously - forever!
A push switch or an on off switch can only have two possible states (or values), ON (or 1) and OFF (or 0).
An analogue input can have a continuous range of values such as, temperature, speed, pressure, loudness, pH, light level, etc..
The values are measured through the use of a transducer such as a temperature sensor.
The transducer will input a range of values to the system as its resistance changes
These plants grow best at a temperature of 20°C .
At night it gets cold so a heater has been installed in the greenhouse.
If the temperature falls below 20°C the heater is turned on.
The temperature rises.
If the temperature rises above 20°C the heater is turned off.
The temperature falls.
This will keep the average temperature at the default value of 20°C so the plants will thrive.
This is an excellent STEM project as it has a lot of scope for designing, making and artistic creativity. Having researched a number of different lighthouses the pupils can then build a model into which they will later add the control circuit.
The final step is to write the block code script which will bring their model to life.
Scratch can be used to plan and model or simulate control systems.
It is a very graphical way of testing algorithms.
Click this link for a working model of the lighthouse algorithm
To run the model, click the green flag then press 'd' for day and 'n' for night.
Click See inside, to view the code.
There are many similarities between the LDR controlled street light project and this project.
The lighthouse makes use of a light sensor to distinguish between day time and night time.
When it is night time, the main beam of the lighthouse must not only come on, but must flash in the sequence - on for 2 seconds, off for 1 second - all night.
A lighthouse is one of the easiest models to make. The model illustrated was made from the following components:
Square of recycled plywood or cardboard.
Length of recycled cardboard tube.
Plaster of Paris or paper mache.
An old plastic 'shot' glass.
A 100 Ohm resistor.
A light dependent resistor (LDR).
A white light emitting diode (LED).
Multi strand wire..
The components are wired to the micro:bit as shown in the diagram below:
The LED is wired between Pin 0, red wire = positive and GND, black wire = negative.
One leg of the LDR is also connected to GND, white wire (dark blue on the model) = negative.
The circuit includes a 100 Ohm resistor wired between the other leg of the LDR and 3V pin on the micro:bit, green wire. This is a digital divider circuit. Digital divider circuits are explained later in this course. At this stage all the learners need to know is that it gives a better range of input values from the LDR to the micro:bit.
The light input value from the LDR is connected to Pin 1, yellow wire.
An LDR is a resistor. It reduces the current flowing in the circuit.
Its resistance decrease as the light level falling on the component increases.
So the brighterr the light, the lower the resistance and the higher the electric current.
When using an LDR as a light sensor it is important to know that the resistance increases as the light level decreases. So the darker it is, the greater the input value.
For these reasons, the LDR can be used as a analogue sensor because it inputs a range of values to the micro:bit.
Calibration is a very important concept to teach when students are learning about control systems which depend on analogue input values. Calibration is explained in more depth later in this course.
At this stage tell the learners that they must decide how dark it must get for the lighthouse's lamp to come on.
The next step is to measure the input value at this light level. We can call this the default value.
If the threshold value is e.g. 750, then the lighthoude control code must compare each input reading with 750.
If the input reading is leass than 750, then it is light enough and the lamp must be switched off.
Else, if the input value is any higher than 750 then it is too dark and the lamp must be switched on.
Calibration is necessary in every control system because there are always a number of variables such as type of LDR, size of resustor, amount of charge in the batteries, position of the LDR on the model, etc, which must be allowed for.
This is simplified in the flowchart below. In reality the decision must include the default value so it should say:
Is the input less than 750?
If YES turn light off.
If NO turn light on.
Every lighthouse has a different signal of flashes so that ships can identify them.
This lighthouse has to have the signal:
When it is dark, flash ON for 1 second and then OFF for 3 seconds continuously.
When it is daylight, turn the light off.
Block code created for the micro:bit using the MakeCode editing environment.
The screen shot shows the code being simulated to test it.
These learners chose a default value of 800 to switch on the lamp.
They are using the simulator to compare the analogue read pin P1 value with the default.
In their test, they have set the analogue read pin P1 value to 868.
This is greater than 800, so the simulator has changed the digital write pin P0 to 1 (which is on).
N.B. The concepts taught in this project are fairly universal and are applied to an enormous number of very different control systems.
They are illustrated in a number of the applications covered later in this course.
A simple soil moisture sensor can be made from two, 10cm iron nails and a short length of plastic tube.
The two nails must be pushed into the soil as far as they can go before taking a reading.
See the photos below.
You will need the following:
micro:bit
moisture sensor (x2 10cm iron nals and a length of plastic tube.
fixed resistor (approximately 7 k Ohms)
4 insulated crocodile to crocodile clip leads
The sensor is connected to the micro:bit in a voltage divider circuit (study the pictures below).
Press button A to take a reading.
Dry soil = 838
Moist soil = 523
Wet soil = 182
The dryer the soil becomes, the greater the resistance it has.
Therefore when the soil is watered the water helps the soil to conduct electricity so the resistance of the soil falls.
As the resistance falls the readings on the micro:bit didplay will decrease.
The higher the number, the dryer the soil.
These readings will vary depending on, the length of the nails, how far they are pushed into the soil, the fixed resisi
Commercial moisture sesnor
Look at the street light picture on the right.
The cylinder on top is a light sensor which controls the street light.
You are going to design and make a control system that will sense the light level.
When the light level fall below a default value it will turn the light on.
When the light level rises above the default value it will turn the light off.
An LDR (light dependent resistor) can be used as a light level sensor.
Electronic components create some resistance to the flow of electric current passing through them.
The resistance of an LDR changes as the intensity of the light shining onto it changes.
The brighter the light, the lower the resistance so the higher the input voltage that will be measured by the micro:bit.
Repeat forever:
Measure the light level
If the light level goes above the default value:
lamp turns off
If the light level falls below the diffault value:
lamp turns on
This is the perfect STE(A)M project as it combines, science, maths, coding and deisgn and making skills.
The design brief is - create a wrist band navigation system that can make use of the Earth's magnetic field.
Magnetometer
A magnetometer is a device that measures the strength, direction, or change in a magnetic field.
They can be used in many applications, including navigation, security, and scientific research.
A megnetometer is built into every micro:bit.
Simple code
Using the MakeCode tutorial, the pupils must find out how to take and display a compass bearing from th magnetometer.
Once programmed, the micro:bit has to be calibrated to the Earth's magnetic field by rotating in vertically until every LED on the display lights up.
Complex code
The pupils must use their knowledge of maths, and bearings to display a cardinal direction, N for North, S for South, E for East and W for West.
The conditional statement must test a range of bearings to identify the cardinal direction, e.g. If bearing > 45 and bearing < 135 then display E etc.
The four conditional statements needed for the micro:bit to display N, S, E & W.
The MakeCode script for a micro:bit to display N,S,E & W.
Design and making
This is the part of the project where the pupils have to think about how the micro:bit and battery pack will be worn on the wrist during navigation using the digital compas.
Once the wearable tech, navigation band is finished the pupils could use them in a treasure hunt ot orienteering activity arround the school's grounds.