Saturday, August 05, 2006

Ta Daaaa! There it is, the finished PCB layout. Well actually this is only one of the finished products. There are a couple more as well! All we have to do now is have those boards manufactured and we can get into testing them to make sure they work. The best way to do this will be to program the processors with basic routines which will operate each sensor one by one. Then if and when the code fails we will be able to use a process of elimination to work out what needs to be fixed or replaced. These things will never work first time.

The next step is the software and my lab partner and I are already beginning to look into it. As with all missions, this one requires a plan and one of the most effective way to plan a program is to use a structure diagram. There are two methods for drawing the program into a diagram - a flow chart or the use of case statements. I won't go into case statements because at the moment that's not the design format we are using. I will include a very basic flow chart which breaks down the interaction between the parts of Libramentum. Although I would like to (because it is very exciting) I won't go into great detail about the coding structure because I don't particularly want it stolen and to be honest - I don't trust this internet thungimajig! So here is a very basic idea of what the program will be doing. This is a cut and paste from a word document flow diagram. First we want the sensors to do their job of working out what is going on, then the two minor processors on the motherboard will (between them) filter that information and send values to the main processor - here labelled the Mega128. From there the [Atmel AT]Mega128 will turn the voltages and codes into a discrete set of values. These values will be sent to the daughterboard which has an Atmel ARM processor on it. This processor does all the hard yards - it does all the complicated maths that will turn those values into an understanding of exactly what is happening to the robot. Additionally it calculates what force will be required at each of the three motors (and in which direction!) and sends these values back to the motherboard - the one we started on - who sends the correct voltages through special control circuits called H-bridges to the motors. As soon as it's set the H-Bridges it immediately collects the next lot of sense information - even as the motors are busy righting the robot!

Now as I said - that flow diagram was thrown together using Microsoft Word, but there are special symbols used by programmers. There are many different ways of writing a program and you might hear about all sorts of 'languages,' Pascal, C-Plus, Java, Pearl and others. The special thing about a structure diagram is that it can be written by someone with only a basic understanding of a single language, and any program developer anywhere should be able to pick it up and write a program in any language that will do what the structure describes. It is a plan of how the overall system is handled. The details are for the individual to work out for themselves. I felt guilty about not putting any of the diagrams for Libramentum up, so I'll put up another instead. I made this in about 30 seconds, and will see what I can do about coding it later...


It's a little difficult to see, and I apologise, but lets look at what it says.
** START (easy)
** IF you are a boy. This is an 'IF/ELSE' statement. If the statement is true take the action from the right of the diamond - Go to the Rugby. If the statement is false, take the action from the bottom of the diamond - Go to the netball. Once these have been completed, we return to the next action after the 'IF' box.
** FOR the duration of the game. This action has a loop on it and the little equals sign indicates where the test is carried out. The program 'tests' the for statement, while the game is being played, the program will carry out any actions attached to that loop - in this case, obey the ref. when the game is no longer in progress the FOR statement will be false and the program will break out of the loop. We could add another simple action after the FOR loop which instructs the program to "go to the aftermatch function." When the program reaches END it knows it has nothing more expected of it and will not look for further instructions. So you can see from that diagram that there was no actual code included in it. The words in the box were on the whole simple english, designed to be picked up by anyone and turned into a program. This is important because there will be three people working on the code for Libramentum. My Lab partner and I have designed a lot of little programs before and we have a good system going. I predict that for the software design of this robot we will work at it seperately and then work out which design to turn into code. Often we'll create an amalgamation of the two designs. It is important we are able to pick up the other persons structure and be able to almost immediately see what the other is intending. Also, our supervisor needs to be able to keep an eye on our progress and add his input, which is quicker and easier for all if we don't spend half an our explaining what we mean in our plan.
So if you're still interested keep reading and I'll try and turn my spontaneous structure diagram into some C-code.

#include
#include

#define boy 1
#define girl 0
#define rugby 1
#define netball 0

void main(void)
{
int person=boy, game, rugby, netball, obeyRef, gameTime;

if(person == boy)
{
game = rugby;
}else
game = netball;

gameTime = 1200;

for(gameTime > 0)
{
obeyRef = 1;
gameTime--;
}

}


It's a lot harder to read isn't it? In fact, if you don't know programming, or if you haven't worked with anything that works like C then the whole thing is a lot of gibberish. That's why the structure diagram is so important - because it's universal. I don't know if some of you reading this have much experience with programming, but I bet anyone you know who does will be able to take my structure diagram and turn it into code. But that code might look very different to mine. And I know some people reading this will have as much AND more experience at programming than me and will probably be shaking their heads at this awful mashed example, but I would like to take this oportunity to point out that I whipped up in only a few minutes because my flatmates are putting on a DVD and I want to see it. Ciao!

4 comments:

simon said...

my gawd! too scientific for an auctioneer!

I think my IQ is very low....

Ju's little sister said...

Oh no - it has nothing to do with IQ! Remember everthing we learn is in baby steps, and this is where I'm at. I've misse dout on other important or enjoyable skills, like talking to strangers and holding a conversation... Okay so I'm kidding a little, but my area of expertise is a little narrow. I don't think i could run an auction.

Ju's Mum said...

It's alright Simon - that is my daughter & Ju's little sister & I too think my IQ is very low - but I must have a little bit ???? And, you don't have to believe all you are told either - when has Sarah EVER found any difficulty in holding a conversation ???? NEVER (... and she'd be very good at running an auction!)
Truely though, this project is very impressive and wish Sarah all the success she deserves.xx

Ju's little sister said...

Don't listen to mother.

I wouldn't be able to run an auction - don't you have to learn another language? Mum think's there's never an occasion I can't hold a conversation but there have been plenty.