Content

View
View Content

Account

Username
Password
Forgotten my password

Pictures

R Pod
R Pod
Basic Electronics and Computer Programming Tutorial

Introduction

This document provides a basic tutorial for secondary school children on Electronics and simple computer programming to allow children to develop and program the simple Greenpower Car computer system. The Greenpower Car computer uses a simple PicAxe micro-processor and the information below is based around using this chip.

Basic Electronics

To understand the basics of Electronics you need to understand the principles of electricity. Basically most materials contain small particles called electrons. These electrons can move or flow through particular materials that can conduct electricity. Some materials conduct electrons well, such as metals, and some materials restrict the flow of electrons, these materials are said to offer some resistance to the passage of electrons. Materials that offer a high resistance to electrons are called insulators.

In electronics we manage and measure the flow of these electrons around circuits of conductors, resistors and semi-conductors. Unfortunately we cannot easily see electrons flowing around a circuit and thus need to use instruments to measure the flow of electrons. To provide a basic understanding of electricity and the flow of electrons an anology with the flow of water in pipes can be used. This is not a perfect anaolgy, but can be usefull to aid basic understanding. There are a number of important attributes and parts used:

  • Voltage:This is a measure of the "pressure" of electrons. This is measured in Volts and we use a Volt Meter to measure it.

  • Current: This is a measure of the amount of electrons that are flowing due to the pressure of electrons (Voltage) through a material (could be a wire). This is measured in Amps and we use an Amp Meter to measure it.

  • Resistance: This the the amount of resistance to electron flow a material or component has. It is measured in Ohms and we use an Ohm Meter to measure it.

  • Battery: A battery or other power source can be thought of as a pump of electrons that will pump a current of electrons around a circuit.

There is a usefull law called "Ohm's Law" that defines a relationship between Voltage, Current and Resistance. This is defined in terms of a mathmatical equation:

  • Voltage = Current x Resistance

Some more information on basic electronics is available at:An overview of basic electrics.

Computer Numbers

Computers use electronics to "compute" data and information. Predominantly they perform calculations on numbers. Now how do they do this ? As humans we normally use numbers in base 10. Ie each digit can have a value of 0,1,2,3,4,5,6,7,8 or 9. Computers use what is called binary arithmetic. In binary processing each individual digit can have only two states: "0" or "1". Computers use a voltage to define a value of "0" or "1". In the Greenpower computer a voltage of 0 Volts (actually anything less than 0.5 Volts) defines the value of "0", a voltage of 5 Volts (actually anything greater than 2.5 Volts) defines a value of "1". So how does a computer define a value of say 5 ? Well it would require three separate digit's defined as follows:

4's Column

2's Column

1's Column

1

0

1

Each of the digits of a binary computer is stored in what is called a "bit". Numbers or values are stored in sets of bits. These "bit sets" are of a fixed save and thus can only store a number up to a maximum value. There are some commonly used sized sets of bits, they are:

Name

Number of bits

Value Range

Byte

8

0 - 255

Word

16

0 - 65535

Double Word

32

0 - 4294967299

The decimal number "100" is shown below stored in a bytes binary digit columns:

128

64

32

16

8

4

2

1

0

1

1

0

0

1

0

0

Thus the decimal value "100" would be written in binary as "1100100". This is quite a long winded way of writing out the decimal value "100". So computer programmers often use, what is called, a hexadecimal numbering scheme. In hexadecimal each digit can have a value between 0 and 15. The digits can thus have a value of: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e or f. It is easy to convert between binary and hexadecimal as both schemes columns are a multiple of 2. To decimal value of "100" in shown below in hexadecimal:

16

1

6

4

Bit values can be stored within a computer in memory locations or input or output through "pins" on a computer chip.

How about negative numbers ? A computer uses a coding scheme called "two's compliment" to store a negative number. In this case the uppermost bit of a byte, word or double word is used as a sign bit. If this bit is set to "1" then its value is taken as minus its normal column value. Below shows the decimal value "-100" in a signed byte.

-128

64

32

16

8

4

2

1

1

0

0

1

1

1

0

0

In a computer a memory location can be used as an "unsigned" value or a "signed" value.

Simple micro-processors such as the PicAxe range can only perform integer arithmetic. More complex processors have the ability to work with floating point numbers that can hold a fractional part as well as an integer.

Computers

Computers perform calculations and other operations on numbers. A basic computer has the following components: ElectronicsTutorialDraw1

  • Memory: This is an area where a computer will store infomation temporarily (while switched on). Memory is addressed using a value termed an address. This is a value from "0" up to the maximum memory size eof the computer in use.

  • Processor: The performs "calculations" on the data from input and memory and puts results into the output and memory.

  • I/O: This is the input and output to the computer. In the Greenpower computer it is implemented as a set of pins on a the computer chip.

Computers perform a set of comands using the input data and memory and write results into the memory and/or output. The set of commands is called a program. The set of program commands can consist of oneof the following types:

  • Input: Inputs data from an outside source.

  • Output: Outputs data to an outside source.

  • Memory access: Reads or writes data to internal memory.

  • Calculation: Performs a mathmatical calculation on data.

  • Decision and jump: Checks the value of data and jumps to a different section of the program. Can also loop around a section of program.