#mazetrix video 1

I spent about 4 hours programming last night trying to simulate the physics of a rolling ball on the AVR. I think it turned out pretty well:

Here’s the timer interrupt that services the analog to digital converter and the multiplexing of the LEDs:

ISR(TIMER2_OVF_vect){
static unsigned char activeLine=0;
static unsigned char adcChannel=0;
PORTC=0xFF;
PORTA=0xFF;
selectLine(activeLine);
PORTC=~green_display[activeLine];
PORTA=~red_display[activeLine];
activeLine++;
if(activeLine>7){
activeLine=0;
}
switch(adcChannel){
case 0: x_accel=(ADCH-x_flat)/10;
if((x_loc<500)&&(x_accel<0)){ x_accel=0; } if((x_loc>7500)&&(x_accel>0)){
x_accel=0;
}
x_vel=limit(x_vel+x_accel,-MAXVELOCITY,MAXVELOCITY);
ADMUX=0xE1;
adcChannel=1;
break;
case 1: y_accel=(y_flat-ADCH)/10;
if((y_loc<500)&&(y_accel<0)){ y_accel=0; } if((y_loc>7500)&&(y_accel>0)){
y_accel=0;
}
//if((abs(y_accel)>1)||(abs(y_vel)>20)){
y_vel=limit(y_vel+y_accel,-MAXVELOCITY,MAXVELOCITY);
//}else{
// y_vel=0;
//}
ADMUX=0xE2;
adcChannel=2;
break;
case 2: z_accel=(ADCH-125);
ADMUX=0xE0;
adcChannel=0;
break;
default: adcChannel=0;
}

}

And the main loop:

while(1){

if((abs(x_vel)>STICTION)||(abs(y_vel)>STICTION)){
x_vel=(int)((ELASTICNUMERATOR*(long int)x_vel)/ELASTICDENOMINATOR);
x_loc+=x_vel;
y_vel=(int)((ELASTICNUMERATOR*(long int)y_vel)/ELASTICDENOMINATOR);
y_loc+=y_vel;
}
if(x_loc<0){ x_loc=-x_loc; x_vel=-x_vel; } if(x_loc>7999){
x_loc=7999;
x_vel=-x_vel;
}
if(y_loc<0){ y_loc=-y_loc; y_vel=-y_vel; } if(y_loc>7999){
y_loc=7999;
y_vel=-y_vel;
}
x_pos=(unsigned char)(x_loc/1000);
y_pos=(unsigned char)(y_loc/1000);
plotBall(x_pos,y_pos);
_delay_ms(50);

}

Mazetrix Update

I received the pcbs for Mazetrix and started the build. After 4 1/2 hours of troubleshooting I realized that I connected the SCK line to the wrong pin and finally managed to get AVR Studio to recognize the processor. Then I wrote enough code to verify the LEDs would all light up.  However I then started having problems with the firmware. Finally, during my 15 minute lunch today, I found the problem was the fuse settings in the ATMEGA128 (either 103 comaptibility mode or JTAG enabled).

I just added the 3-axis accelerometer, but haven’t soldered on the supporting components. Also I still need to add the Li-Po charge IC. I am currently using the STK500 both to power and program the board.

So without further ado, here are some pics…

Mazetrix project

Mazetrix project

Mazetrix Bottom

Mazetrix Bottom

Mazetrix Top

Mazetrix Top

Welcome to the Mazetrix

So, I just got an email from BatchPCB that my board has been shipped, so it looks like I’m switching gears again.

My board is for a project based on the Tiletoy, and incidentally not unlike the Space Invaders Button, the Awesome and 64Pixels.

Many moons ago I managed to score several 8×64 Red-Green matrix displays salvaged, evidently, from a casino display. Even though I had managed to reverse engineer them and figure out how to display nifty messages, they were just too large and too COTS for me. I removed the 8×8 LED matrices (matrixes?) and designed a small board to run them. The display is run directly from an ATMega128, using a half-H bridge on each column so I can use the entire matrix as a sensor. Additionally, I have added a MMA7260 triple axis accelerometer. Last but not least is an IR LED pointed in each of the cardinal directions, also connected to be used as an input and an output, for communicating to neighbor modules(PDF link).

The ultimate goal is to create tiles with a red maze and a green “ball” than you can manipulate by tilting, just like the good old labyrinth game. When you get to the edge of a tile, you can connect another, which will attach magnetically, and the maze will continue on the new tile.

I’ll add more updates when I start building.

Here’s a few images to satisfy the curious:

schematic

schematic

Mazetrix Layout

Mazetrix Layout