Tuesday, November 27, 2012

Arduino Controlled NES (2A03) Synth - PART II

This works, I swear.

Last time, we left off with a semi-functioning, proof-of-concept noise-maker. In the interest of eliminating variables, we simply shoehorned a design meant for an Arduino Mega onto our Uno. However, now that we know the circuit and software work, we can move on and add another layer, namely: a set of daisy-chained shift registers.

Shift registers are an easy way to increase the digital i/o when working with an Arduino. If you're unfamiliar, read this quick tutorial on the subject. We will basically be shoving Example 2 right into our circuit. So, rather than connecting our Arduino i/o directly to the NES circuit and passing all of the address and data bits in parallel, we will pass both the address and data bits over a single serial line and let the 2 8-bit shift registers do the parallel communication.

The final schematic

There is only one real change to the code we need to make. Instead of setting the bus i/o pins with the PORT keywords:
void sendAddrData(uint8_t address, uint8_t data){ 
    state = false; 
   while(state!=true); 

   PORTB = address; 
   PORTC = data; 
} 
we write the address and data to the shift registers with the SPI.transfer command:
void sendAddrData(uint8_t address, uint8_t data){
   state = false;
   while (state!=true); 

   digitalWrite(latchPin_DATA,LOW)
   SPI.transfer(address);
   SPI.transfer(data);
   digitalWrite(latchPin_DATA, HIGH);
}
Since the shift registers are wired up in series, the address and data bytes are shifted down the line one bit at a time. Setting the latch pin high 'commits' this data to the 16 pins we have wired to the data and address buses.

We now have enough i/o to fully communicate to the NES circuit! Lets load the new SPI sketch and take a listen:



This step turned out to be pretty trivial, but it would have made troubleshooting the original harder than it needed to be. Baby steps.

Additional parts needed (from mouser, total $1.04):
8-bit Shift Register x2 (IC8, IC9)

Download this:
sketch

Next Step:
Now that the Arduino-NES circuit is working, we'll add a MIDI interface and control the chip in real-time.

3 comments:

  1. Very cool, like'n it! Hope to see more.
    Yogi

    ReplyDelete
  2. Are you going to be continuing your posts? I really like your work and I am hoping to build my own sometime soon! :)

    ReplyDelete
  3. Thanks! Yes. I've got more to post, just been a little too busy lately. I'll get on it.

    ReplyDelete