Sunday, May 1, 2016

It's been a long time (5-6 years) since I started this project. Things change. With the struggle of work, life, and family, hobbies and interests sometimes have to take a back seat to things with higher priority.
Pretty much unchanged in 5-6 years

Not too long ago, I looked up on my shelf of stuff (you know you have one) and saw a breadboard with some ICs and an Arduino Uno on it. I don't know if it was a sudden outbreak of nostalgia, or if it was the self-loathing of realizing that I never finished such an ambitious project; but I felt a sudden need to complete what I started.

Over the next few weeks, I will be breaking-down the hardware and code of the individual parts of this build. Going from a Mega 2560 board with about a million I/O pins and handing everything in code to as few I/O pins as possible and handling things in hardware is no small task.

Getting Some LEDs to Turn On

Part of the FCB1010 is the LEDs on the board that indicate what pedal was pressed. I previously handled this in code.

I couldn't find any useful or practical tutorials on how to get a 16 bit shift register setup working. That being said, this is not going to even touch on running a basic 8 bit shift register. The following is cobbled together from various sources around the internets and hours of troubleshooting. I apologize ahead of time as my Fritzing skills have much to be desired.

Materials Used:

Step 1: Wire the Power

I hear electronics like electrons.

I used D2 for the constant 5v

Step 2: Wire the Control Lines

I used blue for Data (D10), Yellow for Clock (D7), and Green for Latch (D11).

The two 74HC595 chips share the same latch and clock lines. The data out from the top chip goes to the data in on the bottom. An extra 5v needs to be supplied to the MR pin of the top chip to enable cascading to the bottom chip.

Step 3: Wire the Data Out Circuits

Purple is a nice color. RIP Prince.

Step 4: Add Some LEDs

Since only one will be on at any one time, I figured one resistor would do.

Step 5: There Is No Step 5

Sit back and admire your work. Here's the Fritzing sketch I used if you need any help. 

Step 6: Test Code

Since there won't really be any practical use of hardware to control which light is on or off, the code doesn't really have to be practical either.

All this code does is throw a rotating sequence of high and low bytes of a 16 bit unsigned integer at the shift registers.

#include <stdio.h>
//Pin connected to ST_CP of 74HC595
int latchPin = 11;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 10;

unsigned  data[] = {
0B0000000000000001,
0B0000000000000010,
0B0000000000000100,
0B0000000000001000,
0B0000000000010000,
0B0000000000100000,
0B0000000001000000,
0B0000000010000000,
0B0000000100000000,
0B0000001000000000,
0B0000010000000000,
0B0000100000000000,
0B0001000000000000,
0B0010000000000000,
0B0100000000000000,
0B1000000000000000
};

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  for (int j = 0; j < 16; j++) {
    digitalWrite(latchPin, 0);
    int data = data[j];
    byte first = lowByte(data);
    byte second = highByte(data);
    shiftOut(dataPin, clockPin, MSBFIRST, first);
    shiftOut(dataPin, clockPin, MSBFIRST, second);
    digitalWrite(latchPin, 1);
    delay(1000);
  }
}

If you end-up with something that looks like the following, you're done! Yay!



Reactions:

0 comments:

Post a Comment

Subscribe to RSS Feed Follow me on Twitter!