
Basic Electronics and Computer Programming Tutorial
IntroductionThis 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 microprocessor and the information below is based around using this chip. Basic ElectronicsTo 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 semiconductors. 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:
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: Some more information on basic electronics is available at:An overview of basic electrics. Computer NumbersComputers 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:
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:
The decimal number "100" is shown below stored in a bytes binary digit columns:
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:
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.
In a computer a memory location can be used as an "unsigned" value or a "signed" value. Simple microprocessors 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. ComputersComputers perform calculations and other operations on numbers. A basic computer has the following components:
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:
