latest video

TOPICS:
Bleep Blog
A Box that goes Bleep
A new platform
Documenting the Design
The Bleep Box Brief
Day One
agreed convention
References
SimmStick
MINI TUTORIALS:
Voltage Divider
Simple Digital to Analog converter



Day Two
Day Three
Day Four

Bleep Blog


Welcome to the Bleep Blog- an educational guide to creating microelectronic music.


This is a step-by-step guide to a microelectronics-based project I'm developing- the "Bleep Box".



The Bleep Box is a low-level electronic music sequencer. When I say "electronic music", I mean it in its most old-fashioned sense- not music created with a computer, but music generated directly from electronics, specifically microelectronics.

"What is he on about?" Have a quick look here - it's a video of an early prototype of the Bleep Box in action. Simply put, my aim is to put some audio-generating microelectronics into a wooden box.


The box is an old Voltmeter (possibly WWII vintage) that I've hollowed out. I've made a series wooden facades that fit the box perfectly, to allow me to develop interface panels. The good thing about this is that should the interface prove not to be quite what I'm after, I can re-cut another.

This is an ongoing project- as of October 2007, there's a complete mini-project for you to study, and as I progress, I'll add entries, which you can pick up as an RSS feed. If you're keen to jump straight in, feel free to start with Day One .

If you're a subscriber to my "cool things at Cool Fusion" art/geek blog, then you'll know that I've made lots of projects involving microelectronics. But this is the first time I've thoroughly documented the process, and I hope that you find it helpful.

You'll learn:

  • basic electronics
  • basic microelectronics
  • advanced microelectronics
  • how to document your designs
  • how to design in a modular way
  • how to debug your projects effectively

If you're an Arduino user, there's plenty here for you, and if you're a user of microelectronics in general, the same applies.

The project discussed here is aimed at advanced users; if you are relatively new to microcontroller projects, then I recommend you head over to the tutorials page at the Arduino site.

This project also relies heavily on the use of the SimmStick platform; however the use of Simmstick is not required in order for you to get the most out of the guides here.

Look to the menu at the right to jump to a specific post, or if you like it linear, click here to continue.


A Box that goes Bleep

A Box that goes Bleep


- a history of bleepy boxes I've made over the years.

About 5 years ago (before I got into microcontrollers) I attempted to make a simple bleepy device that would create nice bleepy noises. At one point I had a device with 13 integrated circuits (not microcontrollers) and a variety of other devices that would produce the desired 'bleeps', but had become undebuggable, and quite electrically flakey:


The original pre-microcontroller BleepBox on four small boards

I'd also made a non-sequencing "noise maker", which worked a treat, and had controls galore:


A noisemaker made from 4 IC's


After a time, I got into microcontrollers- specifically the Atmel 902313, which could easily do the job of those 13 IC's. However, I'd moved onto LED displays, and the bleep box idea lay idle for a while.

Recently, (after having left parallel programming of the 902313) I got into Arduino wholeheartedly, and decided I'd have another go at making a bleepy box.


The general form for such a thing is this:



A sequencer module triggers audio modules to play at appropriate times. Each audio module would be configured to produce a different type of sound. The way that the sequencer is programmed is not shown here; let's leave that open for now.


So I set to work, and got this far:

The BleepBox on two boards

To the left is a dedicated audio module that could produce a variety of sounds, that was always playing, and the sound was switched with a relay. After a while, I realised that relays weren't the best way to switch sounds- it's easier to trigger them digitally, so I removed the relays, added another microcontroller (the sound module) and produced this:

The BleepBox on one board. Only two microcontrollers and already it's a mess!

However, as you might be able to see, having multiple microcontrollers on a single board, with multiple I/O going on is a recipe for difficult debugging also.

So, as I start to write this blog and document my processes thoroughly, I'll be using the Simmstick system.


A new platform

A new platform


The "Simmstick" platform is based on (now very dated) 30 pin RAM sockets.

pic of a stick in a socket on a board

Perhaps the most useful thing from a practical point of view is that it's possible to plug and unplug 30 connections very easily, whereas doing this with multiple plugs with fewer connections each is prone to mis-plugging, and rat's nesting.

The other really cool thing about going this route is that it encourages your design to be modular. In the bleep box there will be a sequencer and 3 audio generation modules, and each of these can be designed on its own stick. Whenever I need to work on an individual module, I can unplug it from the motherboard, and even plug it in to a special testing board. It also encourages connection by convention.



The other aspect to Simmstick is an agreed convention for pin layout. Have a look at the image on the left. Each of the 30 lines (pins) has a defined use.

tell me more Simmstick modules ("sticks") can be part of a "buss", which means that those devices can share certain pins. An obvious choice of pins to share would be the SCL and SDA lines, which can be used for TWI (Two Wire Interface) communications. +5v, GND, RES are also shared, meaning that power and reset needs are taken care of.

Of course, there's nothing stopping a designer from defining their own usage on certain lines. For instance, the three audio modules in my system will (initially) use A1, A2 and A3 as the lines that trigger them. It should be noted that redefining +5V, GND and RES isn't a good idea!


Arduino users will be wondering where Arduino fits in to all of this. tell me more You'll notice that I've placed the Atmega8/168 chips on their own Simmstick. I've used either a mini-USB or a chip-less Arduino board to program the chips in circuit. I simply plug a two wire TX/RX cable into the appropriate pins on the Simmstick, and program away. I also ensure that when programming, the power for the motherboard is derived from Arduino's power. This ensures the devices on the Simmstick motherboard and the Arduino share the same ground connection.

The use of Simmstick also gives me the best chance possible that the Bleep Box will work. tell me more ..simply because I can easily separate the various modules and work on them independently. This is so important in microelectronics, and a mistake that is often made by designers new to electronics- they introduce more and more elements to a design and then wonder why all sorts of emergent behaviours occur; behaviours they are unable to track down.

Next- Design documentation


Documenting the Design

Documenting the Design


I use a vector shape drawing program to document my designs. It's a flexible means of laying everything out. There are at least 3 "views of the system" that I'll produce.

1. A software flowchart for the behaviour of each module
2. A schematic of the interconnections between the modules
3. A physically accurate layout of the hardware itself

Flowcharting
Flowcharting is at least 60 years old, and is useful today. There are standards for how to produce them, but I find it can be as simple as rectangles for steps that are performed, and diamonds for decision points. Arrows indicating the flow of control through the program are useful too.

pic of a flowchart


Hardware Schematic
A schematic is a diagram that represents the relationship between components, without representing the physical reality of the electronics themselves. It can also omit certain repetitive details. It's a 'high-level' view of the system. You'll notice that I've used an actual Atmega pin diagram to do this, but that's only because it's a handy record of what pins are available to use.


Physical Layout
A physically accurate layout is a diagram that gets down to actual dimensions. I use a standard .1" (2.54mm) spaced prototyping board, and this forms the basis of a planning stage which can really save you a lot of hassles later on. (I set a grid size of .1" with 10 divisions.) For any project over a certain size, this step is essential. It's during this phase that I'll move my designs around, looking for the best way to wire them up. This involves minimising wire lengths, and simplifying overall design.

As mentioned, I use standard prototyping boards for my work, because there's a series of tracks that can be cut so that any design may be implemented. Therefore, I'll document which tracks need to be cut in this physical layout document.

Handy Tip: To break a connection, I use a drill bit, hand-held, to drill out the track at a certain point.

In this step, I'll discover any physical impossibilities, such as attempting to fit too much into too little space. As I say, it's much easier to grapple with these issues before you go ahead and build your circuit. Make sure you don't cramp your designs! What seems roomy in a full-screen view of your design on-screen, will be much smaller in reality.

Next- The Bleep Box Brief.


The Bleep Box Brief

The Bleep Box Brief


My brief to myself is to produce the following:

  • A simple sequencer that can be physically switched, so that the User can play and sequence at the same time. The sequencer should have 16 beats, which can be either on or off.
  • A series of audio modules, controlled by the sequencer, capable of produce various sounds.
  • A provision to select which audio module is being referenced.
  • A visual representation of which beat is currently being played.
  • A means to save out the music that the User creates.
  • A nice visualisation of the music being played.

This is a lot to ask! It's easy to get overwhelmed, and so a good approach here is to break the design into modules, and also to start at a high level of design, only going to a lower level once you're happy that the design is established and satisfies the brief.

I chose to start with audio modules, essentially working backwards. I've simplified this task for myself by deciding that each of the three modules will be essentially identical. (Apart from the type of sound they produce). The first task then was to make an audio module that can be 'triggered'. In a future iteration, I'll expand the functionality of the audio modules by allowing them to be told to play a certain sound at a certain pitch. For now, the pitch will be determined by an analog slider, and each module can simply be told to 'play' or 'not play'.

To test the audio module, all I need to do is attach a simple switch to the pin that I'll use to trigger it. Later I'll join these audio modules to the sequencer.

Now begins the blog proper! Tomorrow I'll be taking receipt of the Simmstick boards that will form the basis of my modules. When that happens I'll start to build the audio modules.


Day One


Day One

Day One

15.8.2007

The Simmstick boards are here! I've finished my physical layout design:



.. and so it's time to actually start building. It's a good idea to set small goals for any part of the project, and so here are mine for the audio module:

  • Provide power, reset, and oscillation functionality to the module. tell me more A microcontroller needs power! Plus, a provision for resetting it is a good idea, particularly in a multi-module project such as this. An oscillator is required by the microcontroller in order to give it a timing signal.
  • Implement a simple power LED to show that the board has powered up correctly. tell me more This might seem unnecessary or even extravagant, but it's useful whilst developing. As you'll see, I've added a simple switch that lets me disable the LED after the development is completed.
  • Implement 1 bit (later 8, then 16 bit) sound output. tell me more 1 bit sound is easy- just attach a simple speaker to a digital output, and switch that output many times a second.
  • Implement a triggered input to cause the module to produce a fixed pitch sound. tell me more This takes the form of a single digital input, that will cause the audio module to play a sound when triggered.
  • Implement a single LED that can provide a visual status for any purpose I require. tell me more This is something I do quite often- a simple "I'm alive" indication. If there's no indication, there's no point debugging anything else!
  • Implement a simple status beep that occurs when the Arduino board has booted up. tell me more It's not always convenient to actually look at a project to know that it's working- you might be soldering something, for example. Using sound is a good way to re-enforce this feedback.

Another way to frame these goals is to specify what behaviours we should see when we turn the board on. (I'll use the terms "stick" and "board" interchangeably.)

1. Immediately after applying power, the power LED should light.
2. Approximately 10 seconds later, a short 'boot chirp' should be heard.
3. After the 'boot chirp, the module will be silent until its input is triggered.
4. As long as the trigger is held HIGH, the module will produce a fixed pitch sound.
5. When the trigger is brought LOW, the sound should stop.

This is a nice, easily achievable set of behaviours, and this is a good place to start.


Practicalities

I've used "Veroboard" for my modules. These have a standard .1" spacing, which is compatible with the SimmStick platform.

A SimmStick adapter and a piece of Veroboard


The SimmStick adapter is connected to the piece of Veroboard with two sets of header pins

The next step when I design circuits is to provide a socket for the microcontroller. Microcontrollers need oscillators, and so that's just what I did.

A socket for the microcontroller is soldered to the board


Notice that I've used 'posts' (basically a metal pin with a small piece of plastic insulation).
Looking at the underside of the board, you'll notice that I've used a hand-held drill bit to break connections where appropriate. Note that not all pins have been soldered.

The underside of the board shows how connections are broken

Power and reset connections need to be made. You'll notice that I'm using wire wrapping to make these connections- you could also solder wire between the posts, or else do away with the posts altogether and solder the wires into the holes in the prototype boards. The advantage of using posts in any case is that more than one wire may be soldered to them.

pic

There's a design pattern that I'll be using here called an "R2R network", which can convert a digital signal into an analog one. There's a bit of soldering to do here, and as per the goals above, I can save time by only doing part of this step- in essence using only 1 bit sound. Once I've established that this works, I can expand it. So all I need for now is a single output, that I'll send to a simple audio amplifier.

pic

I need to add the ability to trigger the module. By my own defined convention, Simmstick lines A1-A3 will be used to trigger audio modules 1-3, and so as this is the first module, I'll make a connection between A1 and Analog input 1. (The reason I'm using analog input 1 will become clear later.)

Here's the Arduino code that I've written to achieve the goals stated above. If for some reason you have trouble in Arduino due to dodgy characters, that's a character corruption issue related to how some web pages are interpreted by some browsers. If that's the case, you can download a .zip of the sketch here

When you're done there, move on to Day Two.


Bleep Box Audio Module code
Copyright 2007 Justin James Clayden
and Cool Fusion Multimedia
coolfusion.com.au

Version 0

Define pins. Using a #define saves one byte of RAM. (It adds up!)
The pin defined here is also the RX (Serial receive pin) but this isn't
A problem, because there will be no external circuitry *driving* this pin.

Sound output pin
int soundOut0 = 0;

If you haven't yet made the module on its own board,
and are uploading this sketch to an actual Arduino board,
you can uncomment the following line and you'll "see" the
sound on the LED attached to pin 13. If you have a pre-NG
Arduino you'll have to attach an LED to pin 13.

LED pin
int ledPin = 13;

Sound trigger pin
int soundTrigger = 0; ie Analog in 0.

void setup(){

A sound out is an output, after all.
pinMode(soundOut0,OUTPUT);

There's no need to define analog 0 as an input.

Startup message: 'Chirp' the sound out pin 3 times.
We start i from 1, because a delay of 0 is actually a very long delay.
for (int c=0; c<3; c++){

Light the status LED, if attached
digitalWrite(ledPin,HIGH);
for (int i=1; i<250; i++){
One chirp
oscillate(i);
}

Turn the status LED off
digitalWrite(ledPin,LOW);

Wait in between each chirp
delay(200);

}

}


void loop(){

This part is straightforward. If the trigger input is LOW,
do nothing. If it's high, play a constant pitch sound.

A digital input of 0V will give an analog read of 0,
and 5V will give a read of 1023. Checking a midpoint
such as 511 essentially makes the analog input a
digital input.
if (analogRead(soundTrigger) > 511){
oscillate once, with a delay of 250
oscillate(1250);
}
else{
nada
}



}


Turn the sound out off and on, with a specific pitch
For this version sounds will be played at a constant pitch,
but this function is written to allow variable pitches, so that
the 'chirp' at boot-time will sound different to the 'normal'
sound.
This routine produces a square wave, which sounds awful, but
is easily generated.
void oscillate(int rDelay){
setAmplitude(HIGH);
delayMicroseconds(rDelay);
setAmplitude(LOW);
delayMicroseconds(rDelay);
}

Set amplitude. Eventually this will take a byte (8 bits),
and then a word (16 bits), but for this version we
only need a boolean value (1bit).
void setAmplitude(boolean rValue){
digitalWrite(soundOut0,rValue);
}

}}}

agreed convention

agreed convention

Here's what I've decided on for the project's Simmstick usage convention:

A1: When this line is HIGH, audio module 1 is active (which could mean play)
A2: ditto for audio module 2
A3: ditto for audio module 3
PWR: unused
A4: N/C
A5: N/C
+5V: 5 volts, of course.
RES: reset
GND: ground
SCL: TWI clock
SDA: TWI data
SI: Start/Stop button
SO: OK button
A6: Pitch (analog - sound modules)
D0: Sound fx (analog - sound modules)
D1: Sound select (analog - sequencer a in 1)
D2: Tempo (analog - sequencer a in 2)
D3: Note Select (analog - sequencer a in 3)
D4:
D5: RX
D6: TX
D7: SwitchRow return
D8: SwitchRow address 1
D9: SwitchRow address 2
D10: SwitchRow address 3
D11: SwitchRow address 4
D12: Module Select LED 1
D13: Module Select LED 2
D14: Module Select LED 3
D15: Module Select LED 4


References


Below you'll find a list of references that you might find useful when learning about the concepts here at the Bleep Blog.

SimmStick

SimmStick


Based on 30-pin sockets, and an agreed convention, this platform is a handy way to keep your projects modular.


A SimmStick motherboard

SimmStick" is a 30 pin simm socket based Single Board Computer designed by Antti Lukats from Estonia..

(From http://www.simmstick.com/)

Right Menu

Google
 



Cool Fusion- cool

↑ Grab this Headline Animator