Saturday, 3 November 2012

10,000 Views!

Another milestone in the journey of this humble blog has been reached. Ten thousand good people from around the world have stopped by to partake in the geeky shindig that is Notes and Volts. I sincerely hope that at least a few of you have put something you've found here to good use and are busy creating your own sonic mayhem.

If you are at all interested in the direction of the blog, then please remember to follow Notes and Volts on Google+, Twitter, and even Pinterest. Grab some free music on your way out. Or just say hello.

Writing this blog has been a great experience for me and I'm looking forward to sharing more of my electronic and musical adventures in the future.

Next stop.... 100,000??

Tuesday, 30 October 2012

NaV-1 Arduino Soundgin-Babblebot Synth - Part 4b

Programming the 24LC256 EEPROM Chip

 

First, read and build the 24LC256 EEPROM circuit in Part 4a of this series. Or if you are new here, start at the beginning. If you want to jump ahead and start building the final hardware go HERE.

Now download the new code HERE, unzip the folder,  and open in Arduino IDE v1.0 or later.
(Make sure you only open the file named "NaV-1_EEPROM_Test.ino".)
The other files will open as tabs in the IDE. The code has been made with IDE version 1.0 and has not been tested in higher versions although it should work. Also, the code is in very early stages so excuse the appearance.

Burn the code on to your Arduino and fire it up. You should see a brief loading page then the main screen of the NaV-1 interface. Since you have not saved anything to the EEPROM yet, it will be full of nonsense values that the synth won't understand. That's ok, there is a Initialization procedure to format the chip. Instead of me writing a long and drawn out description of the procedure, please watch the following video that demonstrates the operation of the NaV-1 in its current state.





We will now take a look at the code that will allow the synth to save its patch data on the 24LC256 EEPROM chip. First, a bit about how the chip works.

The 24LC256 Chip


I suggest that you take a look at this article that does a great job describing the 24LC256 chip and the I2C bus. The important points to take from the article are:

-The chip is an I2C controlled, 32K Byte, EEPROM storage device.
-It uses a control code (in our case Hex 50) to identify the chip.
-The 24LC256 breaks its memory into "Pages". Each page is 64 bytes long.
-You can only write to one page at a time.

The anatomy of the NaV-1 Patch


To make things simple, each Patch on the NaV-1 synth is 192 Bytes long (three eeprom pages). This will allow us to write a patch with three page write calls. The Bytes are arranged as follows.

|---------------------------------|-----------------------|-----------------------------------------|
   144 Soundgin registers      16 Byte name       32 Byte NaV-1 parameters

The first 144 bytes store a snapshot of the Soundgin's 144 registers. This is followed by a 16 byte character array that holds the patch name. The remaining 32 bytes are reserved for parameters that the NaV-1 may want to store in future updates. The software is still in it's early stages so it is nice to have those 32 bytes available.

Arduino EEPROM Functions


The NaV-1 software uses two functions to make the eeprom talk to the Arduino, patchRead() and patchWrite() . Both functions take a one byte argument called 'patchNum'. As you may have guessed, this is simply the number of the patch you are trying to deal with. The patchNum variable is then multiplied by 192 to get the starting address of the 192 Byte block of memory we are going to access. The result is stored in the 'address' variable which is a two byte integer. The address must be sent to the eeprom one byte at a time so the code isolates the high byte - sends it - then isolates and sends the low byte.

The patchWrite() function uses a do-while loop to send the 144 Soundgin data register values in 16 Byte blocks to the eeprom. The data is broken up in this way due to the size of the Arduino data buffer. Next, a final 16 Byte block of data is sent containing the letters of the patch name.

void patchWrite(byte patchNum)
{

  byte i; //Loop Counter
  byte data = 0; //Array Index
  unsigned int address = (patchNum * 192);
  // Write Soundgin data
  do{
    Wire.beginTransmission(EEPROM1);
    Wire.write((int)((address) >> 8));   // High Byte
    Wire.write((int)((address) & 0xFF)); // Low Byte
    for (i=0; i < 16; i++){ //Write 16 Byte block of data
      Wire.write(patch[data]);
      data++;
    }
    Wire.endTransmission();
    address = address + 16; //Move to next 16 Byte block
    delay(10);
  }
  while (data < 144); //Write 16 Bytes until all sent
  // Write Patch name
  Wire.beginTransmission(EEPROM1);
  Wire.write((int)((address) >> 8));   // High Byte
  Wire.write((int)((address) & 0xFF)); // Low Byte
  for (i=0; i < 16; i++){
    Wire.write((byte) patchName[i]);
  }
  Wire.endTransmission();
  delay(10);
}


The patchRead() function works similarly except the data is read from the eeprom.

void patchRead(byte patchNum)
{
  byte data = 0; // Array Index
  byte i; // Loop Counter
  unsigned int address = (patchNum * 192);

  for (i=0; i < 9; i++){ // Read 9 Blocks of 16 Bytes
    Wire.beginTransmission(EEPROM1);
    Wire.write((int)(address >> 8)); // High Byte
    Wire.write((int)(address & 0xFF)); // Low Byte
    Wire.endTransmission();

    Wire.requestFrom(EEPROM1, 16);
    while(Wire.available())
    {
      patch[data] = Wire.read();
      data++;
    }
    address = address + 16;
    delay(10);
  }
  //Read Patch Name
  data = 0;
  Wire.beginTransmission(EEPROM1);
  Wire.write((int)(address >> 8)); // High Byte
  Wire.write((int)(address & 0xFF)); // Low Byte
  Wire.endTransmission();

  Wire.requestFrom(EEPROM1, 16);
  while(Wire.available())
  {
    patchName[data] = Wire.read();
    data++;
  }
}

Have some fun experimenting with the synth. Remember, you can use 'Raw' mode to change any register you like. Just make sure you download and read the Soundgin datasheet so you know what you are changing.

This completes the basic hardware of the NaV-1. Next, we are going to work on removing the Arduino  development board from the equation and making a 'stand alone' version of the circuit.

Sunday, 30 September 2012

NaV-1 Arduino Soundgin-Babblebot Synth - Part 4a

The cure for memory loss 

 

Please read from Part 1 if you are just joining us. If you want to jump ahead and build the final hardware go HERE.


In this installment, we are going to add some EEPROM memory to the NaV-1 synth project. This will allow us to store multiple sound "Patches" like a real synthesizer. The Arduino actually has some EEPROM built in (1024 Bytes or 1K to be exact). There are two issues with using this memory. First, 1024 Bytes is not enough for our purposes. Each patch on our synth is 192 Bytes in size, so we could only store a handful of sounds. And secondly, the Arduino EEPROM is only rated for 100,000 write/erase cycles. That may sound like a lot, but in electronic terms, it's a pretty short lifespan.

What is EEPROM?


EEPROM stands for Electrically Erasable Programmable Read-Only Memory. This kind of memory is referred to as Non-Volatile, which means that it will not lose data when power is removed. Also, EEPROM is different from EPROM memory in that it can be programmed and erased in the circuit. No special tools required.

The 24LC256 Chip


The chip we are going to use is the 24LC256 from Microchip. You can buy these at SparkFun and many other dealers. They're really cheap so grab a bunch. This is a 256 kbit device (256,000 bits = 32K Bytes of memory). This has the potential of storing over a hundred of our synth patches! It is also rated at more than 1 Million write/erase cycles so it will last a long time in our project.


Wiring it up


**IMPORTANT NOTE** We are going to need to swap two wires from the previous installment of the project. Having the LCD display RS line on Pin 7 of the Arduino was causing a strange glitch. Take the Rotary Encoder wire connected to Arduino Pin 6 and move it to Pin 7. Now take the LCD RS wire that you removed from Pin 7 and connect to Arduino Pin 6. So basically, we are just switching the wires on Pins 6 and 7. Here is the updated schematic.

Full Schematic

Close up of 24LC256

 And here is the chip on my bench. Notice that I have added a third small breadboard for this part as the others were getting a little crowded. Just remember to add two wires from Power and Ground on another board.
Messy, but functional.

Close Up of the 24LC256

The wiring for this chip is really simple. Just connect pins 1,2,3,4 and 7 to Ground. Connect Pin 8 to +5v. Then connect Pin 5 to Input A4 on the Arduino and Pin 6 to A5. That's it!

Stay tuned for the next installment where we will add the code for this new component.


Wednesday, 29 August 2012

Summer is Awesome!

All fun and no work makes Dave a lazy......


Hey everyone. I hope you all had an amazing summer (or whatever happens in the southern hemisphere at this time of year). I know I did. But too much fun can make a person lazy and do horrible things like not update their blogs for long stretches. Well summer's almost over and it's time to get back to work! Well, I haven't exactly been sitting around in flip-flops and bad Aviator shades this whole time.

One big project has been converting my basement (which previously resembled something that would make a hoarder sad) into a half decent woodworking shop.


Workshop Before - Depressing...
Workshop After - Ahhhh!
You see, I have been making electronic gizmos for many years. But when it came time to build enclosures for these projects, my efforts have been.....umm.....lacking.

Exhibit A - Brownie pan MacGyver
Exhibit B - I don't need no stinkin' case!
Exhibit C - Oh the humanity!!

Hopefully from this point forward, my projects will be surrounded by nothing but the beauty of wood and old-world craftsmanship (or at least look slightly less crappy). So expect some articles on this.

NaV-1 case under construction

I have also been working hard on the NaV-1 Arduino synth project. I'm in the middle of programming a menu system and adding an EEPROM to the circuit so you can edit and save multiple patches. I'll be posting this tutorial soon.

So summer is officially over and it's time to get back to business with newfound determination and......What's that....Well I guess one more round of Frisbee Golf won't hurt anyone....

Thursday, 28 June 2012

Fun with Arduino - Annoying LCD glitch

Arrrggggg!!!


Have you ever spent a bunch of hours trying to debug a weird programming glitch only to find out it was a hardware fault? I have!!!!

I have been having a persistent problem with the LCD Display on my NaV-1 Arduino Synth project where the LCD display would not initialize when you first powered up the system. Actually, I don't think the Arduino program would start at all. If I hit the reset button on the Arduino, it would work but that is not going to cut it in a stand alone, enclosed system.

Apparently the problem was a result of having the RS pin (pin 4) of the LCD module connected to Pin 7 on the Arduino. For some reason unknown to me, this can cause problems. A quick Google search showed that I am not the only one having this issue. Since many people are referring to Ladyada's fine LCD tutorial which uses Pin 7 for the RS line, this problem could be very common.

The fix is very simple - Move the LCD RS pin to Pin 6 on the Arduino! Use Pin 7 for something else entirely. All is now right with the world.

If this post can save one person from this frustrating issue, my work is done.

If you have any insight into this problem, please leave a comment below.

Monday, 18 June 2012

Warning about purchasing Babblebot Chips

For those of you who have been following the NaV-1 Babblebot - Arduino Synth project, you may be soon looking to purchase a Babblebot chip. I just wanted to pass along a warning about this

If you google "Babblebot", the first result will direct you to the site Babblebot.net. This is the site for JT Technology, the company that is producing the Babblebot chip using the old Soundgin firmware. This page has a store section with a drop-down menu and a familiar "add to cart" button interface. I placed an order from this page and went through the usual checkout procedures and paid with Paypal. The order was processed and a Paypal payment was sent to JT Technology.

No products were shipped and any attempt to contact the seller went unanswered.

After some unsuccessful attempts at contacting JT Technology, I filed a Paypal Dispute. The dispute was resolved by Paypal in my favor and luckily the funds were recovered but it seems like for all intents and purposes, the seller is gone. I just wanted to share this experience to hopefully prevent any problems for my readers but if JT Technology would like to contact me and clarify this issue, I will gladly update this post.

For some good news, i was able to purchase some Babblebots from www.speechchips.com. Thanks to them.

It seems like the Babblebot chips may be in short supply but since the device is in reality software running on a standard PIC microprocessor, it should be easy for other sellers to produce.

If you find any other sources for the chip, please post a comment below.


Sunday, 27 May 2012

NaV-1 Arduino Soundgin-Babblebot Synth - Part 3

The User Interface

 

Please go back and read Part 1 and Part 2 if you haven't already. If you want to jump ahead and start building the final hardware go HERE.


Designing the user interface tends to be my favourite part of any project. It is also the most painstaking as it will determine if your project is friendly and intuitive or a total pain to use.

After some thought, I decided to use a less-is-more approach and went with a minimal design. There will be one Rotary Encoder that will choose menu items and adjust parameters. Pressing the encoder knob will act as a Confirm command while pushing the button beside it will act as an Exit command.



IMPORTANT NOTE:
The Midi Library has recently been updated to work with the Arduino IDE Version 1.0 so I am going to port this project to this newer IDE. The new IDE uses the suffix .INO for it's files so you won't be able to open them in previous Arduino IDE versions.

Download the latest version of the Midi Library HERE (Version 3.2 as of this post) . Unzip the package and find the folder named "MIDI". Copy this folder and paste into the "libraries" folder inside your Arduino IDE 1.0 installed folder. If all is working, you should find a "MIDI" option listed in the "Sketch>Import Library..." menu of the Arduino IDE.



Here is the circuit schematic



Wiring it up


Notice that I have added a second Breadboard for the interface circuitry. I like having lots of small Breadboard modules that can simply be added as the project grows. If you do this, remember to wire +5V and Ground to the new board. I simply connected two jumper wires from the power strips of the first board to the power strips of the second.



The LCD Display


First we'll get the LCD Display connected. I am using this white on blue, back-lit, 20 X 4 Character display from Adafruit but any standard 20X4 - HD44780 compatible display with back-light should work. Adafruit has a great tutorial for connecting the LCD to an Arduino that you should read. I have soldered a 16 Pin - 0.1" header to the LCD Module so I could plug it into a Breadboard. Here are the LCD Module connections I am using:

LCD Pins

Pin 1 - GND
Pin 2 - +5V
Pin 3 - Center pin of 10K Potentiometer
Pin 4 - Arduino Pin 7
Pin 5 - GND
Pin 6 - Arduino Pin 8
Pin 7,8,9,10 - Not Connected
Pin 11 - Arduino Pin 9
Pin 12 - Arduino Pin 10
Pin 13 - Arduino Pin 11
Pin 14 - Arduino Pin 12
Pin 15 - 100 Ohm Resistor (Other side of the resistor goes to +5V)
Pin 16 - GND

The Rotary Encoder and Buttons


Next we'll connect the Rotary Encoder and Buttons. I am using this Rotary Encoder from Sparkfun as I had it on hand, but will change it to a Panel Mount unit for the final assembly. This Encoder contains a built in switch that is activated by pressing down on the knob.
If you look at the unit you will notice that one edge will have three pins. These are the Encoder pins. Connect the middle pin to Ground, one outside pin to Arduino Pin 5, and the other outside pin to Arduino Pin 6.
The other edge of the Encoder has two pins. These pins connect to the built in switch. Connect one pin to Arduino Pin A0 and the other pin to Ground. (Since we have used all the Arduino Digital Input Pins we will need to steal a couple of Analog Pins for our switches. This is perfectly fine as the software will simply treat them as extra Digital Pins. We are also using the Arduino's built in resistors for these switch inputs so we don't need to add any to the circuit.)
We will connect one more button to our interface. I used a small Breadboard friendly unit similar to this, but will once again replace it with a Panel Mount button for the final assembly. Connect one pin of the button to Arduino pin A1 and the other to Ground.

The Software


Download the code HERE and load into the Arduino. This will allow you to run a simple test to make sure the LCD Display and controls are working properly.

I am using multiple Tabs in the Arduino IDE to break up the code a bit so make sure you open the "NaV1_Interface_Test.ino" file in the IDE. This should automatically open the other files as Tabs.

If all is well, you will see NOTEANDVOLTS.COM on the Display. An Astrix will move across the screen when you turn the rotary encoder and the words "ENTER" and "EXIT" will be displayed when you push the corresponding buttons. You will also be able to play notes from an attached MIDI Keyboard.
NOTE: You will need to adjust the contrast of the display by turning the 10K Potentiometer connected to the LCD until the characters are clearly visible.

The LCD uses the standard Arduino LiquidCrystal library included with the Arduino IDE.

Rotary Encoders are notorious for switch bounce so the software must be ready for this. There are several methods that are floating around but the State Machine method described by Buxtronix seemed to be the most foolproof. The buttons use a simple 300 Millisecond delay to prevent false triggers.

Congratulations if you have made it this far! The basic hardware circuit is near complete. In the next installment, we find a cure for bad memory.