Programming Pioneers KN1

18
Learning Objective: To explain how computers and computer programs are used in a variety of products. Programming Pioneers

Transcript of Programming Pioneers KN1

Learning Objective: To explain how computers and computer programs are used in a variety of products.

Programming Pioneers

Simple electrical systems are used in

products all around us. This steam iron uses only

electrical components; there are no computer-

controlled parts inside it.

A thermostat is a device that can control

temperature and switch on or off at a specific

temperature.

The hot plate is heated until the temperature set by the

thermostat is reached; the thermostat turns off the indicator lights, showing that the iron is hot

enough to use.

Thermostat controlled by dial

These products are controlled only with simple electronic components. How do they work?

KETTLE SECURITY LIGHTELECTRIC

TOOTHBRUSH

When the switch is flicked on, a heating element boils

the water. When a thermostat detects the water is at boiling temperature, it

turns off.

The sensor detects movement near the light and

turns it on. A quartz timer (like those in wristwatches)

detects when a certain amount of time has passed,

and turns it off again.

When the button is pressed, the

motor starts vibrating the bristles, and the indicator light turns on. When two

minutes have passed, the light flashes to show that it's time

to stop brushing!

Why do you think this product is

controlled by a computer system? Which of its functions cannot be

performed by a simple electrical system?

Other products, such as this washing machine, are more

complex and are controlled by computer systems.

The washing programmes have complicated instructions which cannot be

memorised or controlled by a simple electronic system. The programmes must be stored in computer memory and controlled

with a computer system.

How do modern computer memory chips work? How do you think they store information?

A circuit board from a modern SSD hard drive. SSDs store

data on memory chips.

How Memory Chips WorkMemory chips store data by setting thousands, millions or even billions of tiny switches (called

transistors) in on or off positions. The changes in the level of electrical current flowing through the open

or closed switches can be read and interpreted. Can you work out what three-letter word is being spelled out by the three switching circuits below?

Switch state (open = 0, closed = 1)

Corresponding letter

i. ii.1 0 A

0 1 B

1 1 C

0 0 D

Did you work it out? Modern microprocessors and memory

chips contain millions or even billions of tiny transistors. They're hard to see, even using

a microscope.

How Memory Chips Work

AC B

By Pauli Rautakorpi (Own work) [CC BY 3.0 (http://creativecommons.org/licenses/by/

3.0)], via Wikimedia Commons

T h i s t ra f fi c l i g h t i s monitored and controlled by a computer system. Normally, traffic lights A and B are green, unless a car approaches traffic light C, which has a sensor for detecting approaching cars.

A

B

C

Can you write a set of instructions which explain how this traffic light system

might work?

Were your instructions

similar to these?

1.Traffic lights A and B are set to green. Traffic light C is set to red.

2.If the sensor on traffic light C detects a car approaching, a ten-second countdown timer starts.

A

B

C

Were your instructions

similar to these?

3.After ten seconds, traffic lights A and B change to red.

4.Once traffic lights A and B have finished changing, traffic light C changes to green.

5.A twenty-second countdown timer starts.

6.After twenty seconds, the lights will all change back to their starting setting.

A

B

C

Devices such as these are too big, expensive and

unnecessary for systems like traffic lights! Instead, microcontrollers are used.

Embedded computers in systems like those traffic lights don't have touch screens, mice

or keyboards like the computers and devices we're used to using.

Microcontrollers are small, inexpensive computer systems on chips. They are usually designed and built for one specific purpose, such as controlling a

traffic light system. You may have small devices, with microcontrollers on them, at home or at school, which you can program yourselves! Arduinos

and Raspberry Pis have microcontrollers on them. You can connect screens, mice and keyboards to them to program them.

Arduino UnoRaspberry

Pi

Microcontroller

Some products which are monitored and controlled by microcontrollers may be designed, prototyped and tested on a breadboard (bottom-left).

The programmer writes a set of instructions in human language, then turns those instructions into an algorithm written in computer code which the

microcontroller understands (centre). The final design is made on printed circuit boards (PCBs). The program is stored

on a microcontroller on the PCB (bottom-right).

The traffic light instructions, or algorithms, you wrote are similar to the one written by the

programmer who programmed the microcontroller embedded in the traffic light system. Another way of

showing instructions or algorithms is with a flow chart.

START Traffic lights A and B are

green; traffic light C is red.

If the sensor detects a car approaching, a 10 sec.

countdown timer starts.Lights A and B change to red.

At the end of the 20 sec. timer, the lights change back.

A 20 sec. countdown timer starts.

When lights A and B finish changing, light C changes to

green.

Do you think you could write instructions or draw flow

charts showing how you think other products with embedded

systems are programmed?

GlossaryQuartz - an electronic component called a quartz oscillator is

used to measure the passing of time in a circuit. When a tiny electric current is passed through a microscopic quartz crystal, it vibrates. Simple electronic circuits such as those in security lights

count the number of vibrations, then turn off the light.

Did you know that quartz crystals vibrate exactly 32,768 times a second?!