Golden Monkeys The Code

With regards to the coding of the project it was done by our CECS Major Nicholas Morrison. When we got together to work on the coding we had issues with the timing of the decoders which caused some of the LEDS to pop up and light, however since the timing was wrong some of the LEDS just stayed on, but most stayed off. After messing with the code a little more we were able to obtain some blinking, but, again, most of the LEDS stayed off.

After more inspection we found that the connections to the A3BU were connected incorrectly, which made it difficult for our programmer to accurately troubleshoot the code. This basically caused an issue with determining which pin in the LED drivers were high and low. 2015042595183202When trying to further troubleshoot the A3BU we found that we are having issues with designating pins. We have 16 pins available, and we need 20 however that would mean that we would have to disable the 4 pins that are currently in use by the A3BU.

Unfortunately, even though we completed the hardware, and tried our very best with the programming, we were not able to troubleshoot the issues that surfaced when we tried to implement the A3BU with the LED cube. The LED cube is functional when you apply a power source to it, but we were not able to program the A3BU to properly work with the Decoders and the LED drivers to make the LED cube to work properly.

This is the Code that does not function as of yet:

/**
* \file
*
* \brief Empty user application template
*
*/

/**
* \mainpage User Application template doxygen documentation
*
* \par Empty user application template
*
* Bare minimum empty user application template
*
* \par Content
*
* -# Include the ASF header files (through asf.h)
* -# “Insert system clock initialization code here” comment
* -# Minimal main function that starts with a call to board_init()
* -# “Insert application code here” comment
*
*/

/*
* Include header files for all drivers that have been imported from
* Atmel Software Framework (ASF).
*/
#include <asf.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <string.h>
#include <stdio.h>
#define AXIS_X 1
#define AXIS_Y 2
#define AXIS_Z 3

// Delay loop.
// This is not calibrated to milliseconds,
// but we had allready made to many effects using this
// calibration when we figured it might be a good idea
// to calibrate it.
void delay_time(uint16_t x)
{
uint8_t y, z;
for ( ; x > 0 ; x–){
for ( y = 0 ; y < 90 ; y++){
for ( z = 0 ; z < 6 ; z++){
asm volatile (“nop”);
}
}
}
}

static void setup()
{
ioport_pin_t J1[8] = {J1_PIN0, J1_PIN1, J1_PIN2, J1_PIN3, J1_PIN4, J1_PIN5, J1_PIN6, J1_PIN7};
ioport_pin_t J2[4] = {J2_PIN0, J2_PIN1, J2_PIN2, J2_PIN3};
ioport_pin_t J4[8] = {J4_PIN0, J4_PIN1, J4_PIN2, J4_PIN3, J4_PIN4, J4_PIN5, J4_PIN6, J4_PIN7};
int i = 0;
for(i = 0; i <8; i++)
{
ioport_set_pin_dir(J1[i],IOPORT_DIR_OUTPUT);
ioport_set_pin_dir(J4[i],IOPORT_DIR_OUTPUT);
if(i<4)
{
ioport_set_pin_dir(J2[i],IOPORT_DIR_OUTPUT);
}
}
}

int main(void)

{
// Insert system clock initialization code here (sysclk_init()).
pmic_init();
ioport_init();
setup();
int j = 0;
// while(true)
// {
while(true)
{

int i = 2;
ioport_pin_t J4[8] = {J4_PIN0, J4_PIN1, J4_PIN2, J4_PIN3, J4_PIN4, J4_PIN5, J4_PIN6, J4_PIN7};
ioport_set_pin_high(J2_PIN0);
for (i=0; i<8; i++)
{
if(i != 7)
ioport_set_pin_low( J4[i]);
else
ioport_set_pin_high(J4[i]);
}
ioport_set_pin_high(J2_PIN1);
ioport_set_pin_high(J2_PIN2);
ioport_set_pin_high(J2_PIN3);
ioport_pin_t J1[8] = {J1_PIN0, J1_PIN1, J1_PIN2, J1_PIN3, J1_PIN4, J1_PIN5, J1_PIN6, J1_PIN7};
for (i=0; i<8; i++)
{
if(i != 7)
ioport_set_pin_low(J1[i]);
else
ioport_set_pin_high(J1[i]);
}

delay_time(10);
ioport_set_pin_low(J2_PIN0);

delay_time(10000);
}
}

Further inspection, and after many red bulls, we discovered that the issue with our project lied in the hardware and connections that were in the LED cube and the IC circuit board. We tested the pins of the A3BU with a multimeter and we were getting the voltages that we wanted, however when we connected the A3BU to the LED cube we received some malfunctions — none of which was really the programs fault.

This is the final code that was developed:

/**
* \file
*
* \brief Empty user application template
*
*/

/**
* \mainpage User Application template doxygen documentation
*
* \par Empty user application template
*
* Bare minimum empty user application template
*
* \par Content
*
* -# Include the ASF header files (through asf.h)
* -# “Insert system clock initialization code here” comment
* -# Minimal main function that starts with a call to board_init()
* -# “Insert application code here” comment
*
*/

/*
* Include header files for all drivers that have been imported from
* Atmel Software Framework (ASF).
*/
#include <asf.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <string.h>
#include <stdio.h>
#define AXIS_X 1
#define AXIS_Y 2
#define AXIS_Z 3

// Delay loop.
// This is not calibrated to milliseconds,
// but we had already made to many effects using this
// calibration when we figured it might be a good idea
// to calibrate it.
static void delay_time(uint16_t x)
{
uint8_t y, z;
for ( ; x > 0 ; x–){
for ( y = 0 ; y < 90 ; y++){
for ( z = 0 ; z < 6 ; z++){
asm volatile (“nop”);
}
}
}
}

static void setup(void)
{
//J1: Cathode Control; J2: Pin 0 : Output Control, 1-3: Addressing; J4: Data bus
ioport_pin_t J1[8] = {J1_PIN0, J1_PIN1, J1_PIN2, J1_PIN3, J1_PIN4, J1_PIN5, J1_PIN6, J1_PIN7};
ioport_pin_t J2[4] = {J2_PIN0, J2_PIN1, J2_PIN2, J2_PIN3};
ioport_pin_t J4[8] = {J4_PIN0, J4_PIN1, J4_PIN2, J4_PIN3, J4_PIN4, J4_PIN5, J4_PIN6, J4_PIN7};
int i = 0;
for(i = 0; i <8; i++)
{
ioport_set_pin_dir(J1[i],IOPORT_DIR_OUTPUT);
ioport_set_pin_dir(J4[i],IOPORT_DIR_OUTPUT);
if(i<4)
{
ioport_set_pin_dir(J2[i],IOPORT_DIR_OUTPUT);
}
}
}

int main(void)
{
// Insert system clock initialization code here (sysclk_init()).
pmic_init();
ioport_init();
setup();
int i = 0;
int j = 0;
int k = 0;
int l = 0;
// while(true)
// {
while(true)
{

ioport_pin_t J4[8] = {J4_PIN0, J4_PIN1, J4_PIN2, J4_PIN3, J4_PIN4, J4_PIN5, J4_PIN6, J4_PIN7};
ioport_set_pin_high(J2_PIN0);
for (i=0; i<8; i++)
{
if(i != j)
ioport_set_pin_low( J4[i]);
else
ioport_set_pin_high(J4[i]);
}
switch (k)
{
case 0:
ioport_set_pin_low(J2_PIN1);
ioport_set_pin_low(J2_PIN2);
ioport_set_pin_low(J2_PIN3);
break;
case 1:
ioport_set_pin_high(J2_PIN1);
ioport_set_pin_low(J2_PIN2);
ioport_set_pin_low(J2_PIN3);
break;
case 2:
ioport_set_pin_low(J2_PIN1);
ioport_set_pin_high(J2_PIN2);
ioport_set_pin_low(J2_PIN3);
break;
case 3:
ioport_set_pin_high(J2_PIN1);
ioport_set_pin_high(J2_PIN2);
ioport_set_pin_low(J2_PIN3);
break;
case 4:
ioport_set_pin_low(J2_PIN1);
ioport_set_pin_low(J2_PIN2);
ioport_set_pin_high(J2_PIN3);
break;
case 5:
ioport_set_pin_high(J2_PIN1);
ioport_set_pin_low(J2_PIN2);
ioport_set_pin_high(J2_PIN3);
break;
case 6:
ioport_set_pin_low(J2_PIN1);
ioport_set_pin_high(J2_PIN2);
ioport_set_pin_high(J2_PIN3);
break;
case 7:
ioport_set_pin_high(J2_PIN1);
ioport_set_pin_high(J2_PIN2);
ioport_set_pin_high(J2_PIN3);
break;
default:
k = 0;
break;
}
ioport_pin_t J1[8] = {J1_PIN0, J1_PIN1, J1_PIN2, J1_PIN3, J1_PIN4, J1_PIN5, J1_PIN6, J1_PIN7};
for (i=0; i<8; i++)
{
if(i != l)
ioport_set_pin_low(J1[i]);
else
ioport_set_pin_high(J1[i]);
}
ioport_set_pin_low(J2_PIN0);
j++;
if(j >= 8)
{
j = 0;
k++;
if(k >= 8)
{
k = 0;
l++;
if(l >= 8)
{
l = 0;
}
}
}
delay_time(1000);
}
}