Tuesday 22 September 2015

Shifting the Smile - Freeing up some ports on AgoBo

This week I finally got around to setting up the code for the shift register I soldered onto AgoBo's 
prototyping board several months ago.


I used one of the preset positions for chips so it was relatively easy to add the board and some resistors to keep everything safe.

The seven segment display was then reconnected to the outputs and the head scratching began. I had a good look at the data sheet to get everything connected up then tried to sort out some test code to get the smile back on AgoBo's face.

I put some quick code making a short library so that i could call on mouth.smile in my code for AgoBo. I could probably make the code more efficient but this was a quick first attempt. I will try and get the code uploaded to my Git Hub repository when I have a chance to connect up AgoBo to the network

I have also added a talking mouth pattern to the different expressions that I may use if add some sound later on.

My next plan is to use some of the now free GPIO pins to light up some fibre optics I was given by my wife to make some hair. The current plan is to have the hair change colour to suit AgoBo's current emotions but some cycling also seems an appealing idea.

Acting the Part - A lesson in processor architecture

Part of the syllabus for my A-level computing group (OCR A Level) is to learn about and understand the make up of a CPU. This goes beyond the basic "this is the brains of a computer" and starts to look at how the CPU does it's job and which parts of the CPU do each part of the job.

To do this I could have done a 'chalk and talk' lesson telling the students all about the functions but I felt they would learn better if i could get them more involved. I also wanted to get them interacting and working together.

I did a lesson before with my Home Education group based on a CS unplugged activity - class simulation of a computer. I had adapted the ideas on the page to make a human calculator program using children to move the information around the parts of the computer. this was a little basic but it seemed like a good basis to expand on for my lesson.

As this was an A-Level group I wanted to get the students to do the thinking. So i came up with a plan based on a simple introduction to the parts and functions then set the students the task of designing activities to explain the working of the CPU to their classmates.

For the introduction we did a revision of the fetch-execute cycle and then went smaller to look at the parts of the CPU and what part they play in the process. The students were also given access to a YouTube playlist of videos about processor architecture to help them research the topic.

The students were split into small groups then set the task to design an activity to explain the process to their peers.

The Groups came up with a variety of ways of delivering the idea. All of the groups had an activity which showed they understood the process. The best group came up with an activity that involved the other students to take the role of each of the components and memory.

Their activity is detailed below (with a little editing):

Equipment:
Pens
Plain paper
Whiteboard pens
Mini Whiteboards
Labels for each of the components (can be written on the boards)

Set up:
1) Write a simple program to be used by the simulated computer the students used the following program:

     1 Load 70
     2 Add 71
     3 Store 72
     (at location 70 they had 712, at location 71 they had 73)

2) Select students to take the following roles -

     Registers:
     Program control - PC
     Memory Address Register - MAR
     Memory Data Register - MDR
     Current Instruction Register - CIR

     Arithmetic Logic Unit - ALU
     Control Unit - CU
     Accumulator - AC

     Cache Memory

     Address Bus
     Data Bus
     Control Bus

3) Hand each student the correct label, a whiteboard whiteboard pen, paper, and pen then position them around the classroom. Ensure the registers are together and the other components are spaced out around the room.

4) Hand Memory the Program and data loaded into memory


Activity

The students then act the parts of the CPU to carry out the program. To pass data / instructions / control around they write the information on to paper screw it into a ball and throw it to the next part in the process.

So for this example program the following happens:

1) PC is set at 1. This is transferred to the MAR (by throwing paper).
2) CU requests contents of address 1 from memory. (throwing paper via the address bus)
3) The data in the memory (LOAD 71) at address 1 is transferred to the MDR (via the data bus)
4) Contents of MDR loaded into the CIR
5) Contents of CIR sent to CU to be decoded (Data bus)
6) CU decodes the instruction and sends the required address to the MDR and increments the PC. (control bus)
7) Control signal sent (control bus) to fetch the data at the new address (70) (address bus)
8) Data from memory address 70  (712 ) loaded into the MDR (via the data bus)
9) Data from MDR (712) sent to the AC as required by the Load command


10......

this continues carrying out each instruction from the program so for this program PC 2 loads the Add 72 command which fetches the data from location 72 (73) and adds it to the AC. To add the two numbers the ALU is used. The total is added to the AC then the next instruction followed which in this case stores the result at memory location 72.



This could also be extended to show the extra time required to fetch data / instruction from RAM if they are not in cache memory. To do this the RAM should be positioned further away than cache memory. The cache is checked first then the RAM queried if it is not there.