Sunday, 31 March 2013

NaV-1 Arduino Synth - Build it

Putting it all together


If you want to jump in and start building the NaV-1 Synthesizer, this is the place to start! If you would like to see the design process from the beginning go HERE.

If you have been following the NaV-1 project over the last several months, you have seen the design slowly come together and hopefully gained some insight into the design process. There have been changes and re-designs along the way. Now the hardware part of our project is complete and set in stone. So lets build a final version.

Buying the Soundgin / Babblebot chip


This is the only relatively hard to get component on this project. Therefore it should be the first thing you acquire. If you can't get your hands on one of these, this project is going nowhere fast. Please read this article about buying the chip. I have had great luck ordering through speechchips.com.

Stripboard Construction


I wanted this project to be build-able by anyone with a soldering iron and some motivation. So with that in mind, I decided not to use a custom printed circuit board (PCB) and go with an off the shelf solution.

Stripboards (or Veroboards) are a great way to build up permanent versions of your electronic designs. If you've never used one, the video below is a great primer.

The Video


Instead of writing a small novel on all the details of constructing this project, I thought it would be better to show you. The following video will show you in great detail the techniques required to build this project. It is also a good primer on Stripboard construction and electronics assembly in general.


Schematic and Stripboard Diagram





The Code


Download the software for the NaV-1 HERE

Operation


After you have completed the project build, this video will show you how to put the NaV-1 to use.

Parts List


Integrated Circuits


1 - SSG01 Soundgin (or Babblebot) - Sound Processor Chip
1 - ATMEGA328P - Microcontroller
1 - 6N138 - Optocoupler
1 - 24LC256 - EEPROM
1 - LM386 - Audio Power Amplifier
1 - LM7805 - Voltage Regulator

1 - LCD Display 20x4 w/Backlight (HD44780 Compatible)

Semiconductors


1 - 1N4001 - Rectifier Diode
1 - 1N914 - Diode

1 - 16Mhz - Crystal
1 - 10Mhz - Crystal

Electrolytic Capacitors


1 - 220uF
1 - 100uF
3 - 10uF

Capacitors - Ceramic


3 - 100nF
2 - 10nF
4 - 22pF

Resistors - 1/4 Watt


2 - 27K Ohm
1 - 270 Ohm
1 - 220 Ohm
1 - 10K Ohm
1 - 1K Ohm
1 - 100 Ohm
1 - 10 Ohm

2 - 10K Ohm Trim Potentiometer

Hardware


1 - Rotary Encoder w/ Push Button - Panel Mount
1 - Push Button - Momentary, Normally Open - Panel Mount
1 - 5 Pin Din Socket (MIDI)
1 - 2.1mm Power Jack
1 - 1/4" Phone Jack (Mono)

2 - Header - 6 Position - .100" Straight (Mode Electronics #37-6206-3)
1 - Header - 5 Position - .100" Straight
1 - Header - 2 Position - .100" Straight
1 - Header - 2x6  Straight

2 - Connector - 6 Position w/Crimp Pins (Mode Electronics #37-606-3)
1 - Connector - 5 Position w/Crimp Pins
1 - Connector - 2 Position w/Crimp Pins

2 - DIP IC Socket - 8 Pin
1 - DIP IC Socket - 18 Pin
1 - DIP IC Socket - 28 Pin

1 - Stripboard - 38 x 62 Holes - 0.1"(2.54mm) Centers
1 - Ribbon Cable -  (6 wires or more)
1 - Roll - AWG 22 Stranded Wire
3 - Roll - AWG 22 Solid Wire (Red, Green, Blue)
1 - 9v DC Power Adapter (500mA or Greater)



Wednesday, 30 January 2013

Fun with Arduino - The Arduino as ISP

Time to BURN!


In the previous tutorial, we learned how to build a 'stand-alone' Arduino circuit on a breadboard using an ATMEGA328P microcontroller and some supporting components. That's all fine and good, but we need the ability to upload programs to the bare microprocessor for it to actually be useful.

This can be done in a few ways:

- Program the ATMEGA in the Arduino and pull the chip - (Not very convenient)
- Buy an AVR programmer - ($$$$$)
- Use the Arduino Board as a programmer

In this tutorial we are going to go with the last option and use the Arduino board that is conveniently sitting right in front of you as an ISP.

Once again, a Video is worth a thousand words:

 

What is an ISP?


ISP stands for 'In System Programmer'. This is a device that lets you upload code into a Microcontroller without removing it from the circuit. There are several types of ISP's ranging from inexpensive home-built circuits to expensive stand alone field programmers that don't even need a computer.

What is the SPI?


SPI stands for 'Serial Peripheral Interface' Bus. This is a communication standard introduced by Motorolla as a way to transfer data between digital devices. We will use this to connect the Arduino board to our breadboard microcontroller.

You can read all the gory details about the SPI here, but this is the minimum you should know. SPI works by categorizing devices as Masters or Slaves. A Master device can be connected to multiple Slave devices. The master also decides which slave to talk to and is in charge of starting communication.

An SPI connection requires four wires:

SCLK - 'Serial Clock' - This is the clock signal that synchronizes the two devices.
MOSI - 'Master Output, Slave Input' - The data line from the Master
MISO - 'Master Input, Slave Output' - The return data line from the Slave to the Master
SS - 'Slave Select" - This line is used to determine which Slave device is listening

To Bootload or not to Bootload?


Whenever you upload a sketch to an Arduino, you are using the Bootloader.  The Arduino Bootloader is a small program that permanently lives on the Arduinos' microcontroller. It allows the Arduino to communicate with your computer and download programs.

Since we are using the SPI interface to program the chip, we don't need the Bootloader. In fact, as soon as we upload our first program over the SPI, the Bootloader will be overwritten.

Even though we don't need the Bootloader anymore, It does have one useful trick. Each AVR microcontroller (inluding our ATMEGA328P) has a small chunk of permanent memory called 'Fuses' that control how the chip will behave. These Fuses need to be set in a specific configuration to make the chip Arduino compatible. When you buy a brand new ATMEGA chip from your favorite electronics store, they may not be set correctly.

When you 'Burn the Bootloader' to a chip, part of the process includes setting the Fuses. It is a dead simple way to configure a new chip. (See video for details)

You should now be comfortable using the ATMEGA328P chip in a stand alone circuit and can finally let your Arduino board move on to the next project.

Enjoy.

Monday, 31 December 2012

Fun with Arduino - Arduino on a Breadboard

How to remove the 'Arduino' from your Arduino project


In this tutorial, we are going to build a 'stand-alone' circuit that will allow you to run your Arduino code without an actual Arduino board.

The term Arduino actually refers to a system of components that include the board, the microcontroller, the boot-loader ,and the programming environment. It is a system designed to 'protect' the user from a lot of the complication that is part of microcontroller programming.

At the heart of the Arduino board is a microcontroller called the ATMEGA328P. The Arduino board acts like a space suit for the ATMEGA, providing life support and doing its best to protect the chip from damage.

At the end of the day, the Arduino is a development board. While you can make the Ardino a permanent part of you project, once you have finished with the development phase of your design, it is often cleaner and less expensive to replace it with a stand alone ATMEGA microcontroller circuit. This is what we are going to build.

The Arduino board has built in power regulation circuitry that provides a steady 5 Volts to the ATMEGA328P. But, since the Arduino is going bye-bye, we have to build our own power supply circuit. We also need to provide a clock source for the microcontroller.  The 16Mhz crystal and 22pF capacitors take care of that.

Parts required:

1 - 9v DC Power Adapter - 500ma or greater (Wall Wart)
1 - DC Power Socket (2.1mm or sized to fit the plug of your power adapter)
1 - LM7805 - 5 Volt regulator
1 - 1N4001 - rectifier diode
1 - 100uF (Micro-Farad) electrolytic capacitor - rated at 25v or more
1 - 10uF (Micro-Farad) electrolytic capacitor - rated at 25v or more
2 - 22pF ceramic capacitors
1 - ATMEGA328P microcontroller
1 - 16 Mhz crystal
Hook-up wire (22 Gauge - Solid)

(Optional)
1 - SPST Switch
1 - 220 ohm resistor
1 - LED

How it works


First take a look at the schematic.



Let's look at what this circuit is doing. The 9 volt power from your adapter is being fed to a 1N4001 diode. This diode will only allow current to pass in one direction so if the adapter is connected backwards, the circuit will be protected. The 7805 regulator then drops the voltage down to 5 volts and holds it there. The 10uF and 100uF smooth out any ripples in the 5 volt supply.

This steady 5 volt power is supplied to the ATMEGA328P chip. The 16Mhz crystal and 22pf capacitors supply a steady clock signal to the microcontroller. Finally, in 10K resistor holds the microcontrollers 'reset' pin high, so the chip will run it's program. It's a very simple circuit.

Choose your Power


A couple of notes about choosing a DC Power adapter. This circuit will accept a variety of power adapters, but 9 volts is a good choice. You could go a little higher but the extra voltage will just be wasted as heat from the 7805 regulator. You may need to add a Heat-Sink if you go too high. If you go lower than 9v you may find the regulator may have difficulty putting out it's full 5 volts.

Also check the current rating of the adapter. I am using a 500mA unit. This is a fair choice as it is the same rating as the USB port that was probably powering your Arduino not long ago. If your project is larger, you may want to go with a 1 amp unit.

Finnaly, check the polarity of your adapter. Most adapters have a symbol printed on the label that shows the polarity of the tip and sleeve of it's power plug. You can see the symbol in the photo below. This one is showing that the sleeve of the plug is positive. You can use either type, just make sure you wire up your jack accordingly.



Build it


This video provides a step-by-step guide to circuit construction.



You should now have a funtional ATMEGA chip on your breadboard happily running your Arduino program.

In the next tutorial, we are going to look at programming the microcontroller directly on the board. See you then.

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....