Sunday, April 18, 2010

Ferrari F40 robot

Hey, I haven't been writing for a while - that's because I've been caught up with a project we (my group) have been assigned on Computer Systems Architecture class. The assignment was to build a robot that was supposed to drive through an 8-shaped track marked with white paper boarders marked black. To do that we had to steer him through LPT port using a computer and 8259 for interrupt handling. The interrupts occurred when the sensors, positioned in the front left and right of the robot, had changed state. After that the software was supposed to read their state from STATUS(input) pins of the LPT and set proper signals on DATA(output) pins so the engines steer our robot in the right way.

The whole thing took us combined of one week work. The most problems we had with electronics, especially with engine circuitry. We have melted a lot transistors. I was responsible mostly for software (written in C and partially assembler).

That's the (almost) final state of the robot. As you can see it's build on  Ferrari F40, red plastic.



 In case you ever wanted to send something to 8259, 8253 or your LPT port here's a code snippet :

void aoutPort(short port,short data)
{
    asm cli
    asm mov dx, port
    asm mov ax, data
    asm out dx, ax
    asm sti
}

short ainPort(short port)
{
    short tmp;
    asm cli
    asm mov dx, port
    asm in ax, dx
    asm mov tmp, ax
    asm sti
    return tmp;
} 

It does work on a computer with DOS or FDOS operating system. Ofcourse if your using FDOS/DOS you could also use dos.h and outport and inport functions already implemented. Some groups last year had a similar task and used Linux.

And here is an exemplary code we used to update the system remembering the previous state of the sensors and detecting a change.

void refreshDiode()
{
    lastAck=ACK_ON;
    aoutPort(DATA, lastEng+lastAck+lastLight);
    lastAck=ACK_OFF;
    aoutPort(DATA, lastEng+lastAck+lastLight);
} 

ACK_ON is defined as 32 because we use DATA5 pin on the LPT, DATA is defined as 0x378 which is the address of data line in LPT port. We don't want to change the state of the other DATA pins so we add the state of the engine and light pins (D0-D4).

The next assignment is to use a micro-controller instead of a computer - the robot will be autonomous then. The down side is we'll have to use only assembler to program it.

No comments:

Post a Comment