User Tools

Site Tools


user:jmendoza:portfolio:datacomm1

Project: Binary 4 bit counter

A project for Data communications by i and i alone during fall 2013.

This project was begun on 9/22/2013 and is anticipated to take about a week.

Objectives

The purpose of this project is to track and better understand the relationship between a processor and the modules that exist outside of it's native system by way of invoking a program.

The out come should be four blinking LEDs that count to sixteen in binary and then stop.

Knowing how bad I fail at this noise I'm sure I will try many methods that do not work at all before getting close.

Prerequisites

In order to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:

Background

Now that the blinky kerjigger is doing this the next logical step must be to have it do something useful.

This thing is ultimately going to be used as a means of communication I will attempt to have it communicate…things….

Binary counter it is!

different colors even

such lights

much count

very code

wow

Scope

The focus of this will be to forgo the the monitor all together and have the pi communicate with the user by, what has become, unconventional means.

Attributes

I hope to gain the following knowledge from this project:

  • binarium: Will find a clever way to perform binary conversions and translate that to the GPIO standards.
  • GPIO: Since I will be wrastling with these things I hope to gain a deeper understanding of how the system interacts with this aspect of itself.
  • Attractiveness: this will be so awesome it will make my wife's clothes fall off.

Procedure

So I fell flat on my face, tried one to many times to get all fancy with the code and the loops and all that noise.

went in and made things as simplistic as conceivably possible even if it ended up not looking rally like any of the code we are accustomed to

Pretty proud of the streamlinedness :)

Code

 #include "RPI.h"
 
int count;
int a,b,c,d,e,f,g,y;
 
int main()
{
        if(map_peripheral(&gpio) == -1)
        {
                fprintf(stdout, "Failed to map the physical GPIO registers into the virtual memory space. \n");
                return(-1);
        }
 
        //Define pins as output
        INP_GPIO(7);
        OUT_GPIO(7);
 
        INP_GPIO(9);
        OUT_GPIO(9);
 
        INP_GPIO(17);
        OUT_GPIO(17);
 
        INP_GPIO(10);
        OUT_GPIO(10);
 
 
 
        for(count=0;count<16;count++)
        {
                y = count/2;            //using modulus on the incrementing count
                a = count%2;
                b = y/2;                        //odd numbers produce a remainder triggering the LED's
                c = y%2;
                d = b/2;
                e = b%2;
                f = d/2;
                g = d%2;
 
                GPIO_SET = a << 17;          //setting LED's to trigger when the value of the variable = 1
                GPIO_SET = c << 10;
                GPIO_SET = e << 9;
                GPIO_SET = g << 7;
                sleep(1);
                GPIO_CLR = a << 17;
                GPIO_CLR = c << 10;
                GPIO_CLR = e << 9;
                GPIO_CLR = g << 7;
                sleep(.5);
 
        }

Reflection

This was pretty sweet. I went through many different iterations of different techniques that I have come across since starting in computer science and tried, what I think is, a short and elegant iterative approach. Instead of getting all fancy with the loops I took Matt's advice and went to the core of the problem and ended up with a very simple binary conversion. Using a ton of variables it works and it is pretty adorable and very straight forward. Not entirely sure I have been more proud at how one of these projects has turned out.

References

In performing this project, the following resources were referenced:

  • URL1
  • URL2
  • URL3 (provides useful information on topic)
  • URL4

Generally, state where you got informative and useful information to help you accomplish this project when you originally worked on it (from Google, other wiki documents on the Lab46 wiki, etc.)

user/jmendoza/portfolio/datacomm1.txt · Last modified: 2013/12/13 02:26 by jmendoza