Showing posts with label circuit bending basics. Show all posts
Showing posts with label circuit bending basics. Show all posts
Thursday, June 09, 2016
Circuit Bending Basics: Replacing Button Contacts
Button contacts can be replaced easily if there are other solder points already in the circuit that are directly connected to the two contact points of a button. Two wires can be easily soldered onto the pre-existing solder points.
The two wires, when connected, can then trigger the sound of the toy. Instead of physically connecting these wires, digital pins, relays or transistor-based solutions can be used to trigger the button.
Button contacts can be also replaced if there are no obvious solder points. Conductive area on the button pads can be scraped back, and then soldering directly onto by adding two wires connected to the button pads.
The two wires, when connected, can then trigger the sound of the toy. Instead of physically connecting these wires, digital pins, relays or transistor-based solutions can be used to trigger the button.
Labels:
circuit bending,
circuit bending basics
Thursday, June 02, 2016
Circuit Bending Basics: Using a Relay to Simulate A Button Being Pressed
Previously, I've written about different way in which a Teensy or other Arduino-based microcontroller can be used to trigger button presses on a toy.
A relay can be used to the same effect, and may be successful in situations where other methods fail.
A relay is an electromagnetic coil. When a current is passed through the coil of sufficient voltage, the magnetic field physically moves a switch, thus making a connection that was previously unconnected.
A relay will have at least four pins, in two pairs. The first pair is the coil, and this is what is used to open or close the connection. The second pair is the actual connecting contact points that are either open or closed, depending on whether or not the coil is charged. A digital pin on the Teensy is used to control the coil, thus making or breaking a circuit.
In the relay above, the four pins are arranged as pairs, and are perpendicular to one another (one short pair, one long pair). The pair that is the longest away from each other, along the length of the relay, are the contact pair and should be connected to any two points that are to be controlled by the relay. The pair of pins that are the shortest is the coil, and should be connected to the Darlington transistor array described below.
A Darlington transistor array is used between the Teensy and the relay for three reasons. The digital pin on the Teensy cannot provide enough voltage for the relay to trigger. The digital pin on the Teensy cannot provide enough current for the relay to trigger. The relay may damage the Teensy if connected directly.
For these reasons, the ULN2003 Darlington transistor array chip is used as a switching source, with the Teensy pin as an input and the relay as the output. The connections are quite straightforward, as shown below:
• Teensy digital pin 0 is connected to pin 1 of the ULN2003 (red jumper wire)
• Teensy ground is connected to pin 8 of the ULN2003 (blue jumper wire)
• Teensy 5V is connected to pin 9 of the ULN2003 (blue jumper wire)
• ULN2003 pin 1 is connected to one side of the relay coil (white jumper wire)
• Teensy 5V is connected to the other side of the relay coil (green jumper wire)
• One side of the relay contact is going to one contact point of a button press on a toy (orange jumper wire)
• The other side of the relay contact is going to the other contact point of a button press on a toy (orange jumper wire)
Once this has been set up, a HIGH state on Teensy digital pin 0 will energise the relay, and the two orange wires will be electrically connected. A LOW state on Teensy digital pin 0 will stop the relay, and the two orange wires will be electrically disconnected.
Example code is shown below to turn the relay on or off depending on incoming note on / note off events.
A relay can be used to the same effect, and may be successful in situations where other methods fail.
A relay is an electromagnetic coil. When a current is passed through the coil of sufficient voltage, the magnetic field physically moves a switch, thus making a connection that was previously unconnected.
A relay will have at least four pins, in two pairs. The first pair is the coil, and this is what is used to open or close the connection. The second pair is the actual connecting contact points that are either open or closed, depending on whether or not the coil is charged. A digital pin on the Teensy is used to control the coil, thus making or breaking a circuit.
In the relay above, the four pins are arranged as pairs, and are perpendicular to one another (one short pair, one long pair). The pair that is the longest away from each other, along the length of the relay, are the contact pair and should be connected to any two points that are to be controlled by the relay. The pair of pins that are the shortest is the coil, and should be connected to the Darlington transistor array described below.
A Darlington transistor array is used between the Teensy and the relay for three reasons. The digital pin on the Teensy cannot provide enough voltage for the relay to trigger. The digital pin on the Teensy cannot provide enough current for the relay to trigger. The relay may damage the Teensy if connected directly.
For these reasons, the ULN2003 Darlington transistor array chip is used as a switching source, with the Teensy pin as an input and the relay as the output. The connections are quite straightforward, as shown below:
• Teensy digital pin 0 is connected to pin 1 of the ULN2003 (red jumper wire)
• Teensy ground is connected to pin 8 of the ULN2003 (blue jumper wire)
• Teensy 5V is connected to pin 9 of the ULN2003 (blue jumper wire)
• ULN2003 pin 1 is connected to one side of the relay coil (white jumper wire)
• Teensy 5V is connected to the other side of the relay coil (green jumper wire)
• One side of the relay contact is going to one contact point of a button press on a toy (orange jumper wire)
• The other side of the relay contact is going to the other contact point of a button press on a toy (orange jumper wire)
Once this has been set up, a HIGH state on Teensy digital pin 0 will energise the relay, and the two orange wires will be electrically connected. A LOW state on Teensy digital pin 0 will stop the relay, and the two orange wires will be electrically disconnected.
Example code is shown below to turn the relay on or off depending on incoming note on / note off events.
Labels:
circuit bending,
circuit bending basics
Monday, May 30, 2016
Circuit Bending Basics: Two Easy Ways of Triggering Buttons on Toys
Introduction
It may be desirable to trigger a button on a toy using MIDI or some other type of data. For instance, a toy generates sound when one or more buttons are pressed. Instead of physically pressing the buttons, note on / note off events can be used to simulate the pressing of buttons.
To achieve this, consider common the types of connections that may be found in toys in terms of button interaction. Whenever a button or a switch is pressed, normally a circuit is closed by connecting two conductors. This is commonly achieved by having a conductive pad attached to a button which, when pressed, physically and electrically connects two previously separated conductive surfaces, as in the image below.
There are a number of ways in which such a button may be wired:
1) One pin of the button is connected to a pin on the microcontroller of the toy, and the other pin is connected to the positive terminal of the battery (may also be labelled Vdd or Vcc)
2) One pin of the button is connected to a pin on the microcontroller of the toy, and the other pin is connected to the negative terminal of the battery (may also be labelled Vee or Vss)
3) One pin of the button is connected to a pin on the microcontroller of the toy, and the other pin of the button is connected a different pin on the microcontroller of the toy
4) It is unknown or difficult to tell where one or both of the pins of the button is connected to
In the methods given below, a Teensy LC or Teensy 3.1 is used to trigger the button connections of a toy using MIDI note data. This simple guitar toy is used as an example. Naturally, these concepts can be expanded to include multiple buttons, different data types etc.
Using A Digital Pin as a Trigger
If the button in question is in category 1 or 2 of the four possibilities mentioned above, then it may be possible to use a digital pin on the Teensy to directly trigger the button connection.
The idea is straightforward - on side of the switch is connected to positive or negative, and the other side of the switch is connected to a pin on the microcontroller of the toy.
When the button is pressed, the positive or negative terminal of the battery is then connected to the pin on the microcontroller of the toy, thus registering a high or low signal and triggering the sound.
The Teensy can act as a replacement for the positive or negative terminal of the battery in this instance, and provide a high or low signal to simulate the connection of the battery to the input pin of the microcontroller.
The great thing about this is that the connections from the Teensy to the toy are very straightforward, as it is simply a matter of connecting the digital pin on the Teensy to the micrcontroller pin of the button of the toy.
If there are inconsistent results, note that it may be necessary to either:
• connect the ground of the Teensy to the negative battery terminal of the toy or
• remove the battery of the toy and power the toy from the 3V pin on the Teensy (assuming a total voltage in the range of 3V - 4.5V)
Consider the simple guitar toy. The connections of one of the buttons that triggers sound on the toy are shown above. Note that the manufacturer has conveniently labelled the two pins of the button with VDD and P11. VDD is connected directly the positive terminal of the battery, and P11 is connected to the microcontroller of the toy.
As a result, whenever a high state is registered on the pin marked P11, the toy assumes that the button has been pressed and the sound is triggered. Whenever a low state is registered on the pin marked P11, the toy assumes that the button has been depressed.
In this example, it is also necessary to power the guitar toy using the Teensy.
Three connections from the Teensy to the guitar toy are necessary to directly trigger P11:
• The battery is disconnected from the toy
• Ground from the Teensy to the point on the circuit board where the negative terminal of the battery was connected (white alligator lead)
• 3V from the Teensy to the point on the circuit board where the positive terminal of the battery was connected (red alligator lead)
• Teensy digital pin 0 to connection P11 on the guitar toy (black alligator lead)
Example code is shown below. Note that if this method is used (and the code expanded upon), each digital pin on the Teensy can be theoretically used to trigger a different button on a toy or multiple toys.
A demonstration video is shown of this setup. Note that the fastest triggering rate is approximately 45ms. Ableton Live is used to drive the data.
Using a 4066 IC to Simulate Button Presses
Although the above method will work in certain situations, a more complex method may be used in the following situations:
• One pin of the button is connected to a pin on the microcontroller of the toy, and the other pin of the button is connected a different pin on the microcontroller of the toy
• It is unknown or difficult to tell where one or both of the pins of the button is connected to
This method will use the 4066 IC to simulate button presses. This chip is a fourteen pin quad switch, meaning that the switch has the facility to make and break connections for four pairs of points. Each pair of connections can potentially be connected to pairs of button pins on toys to simulate button presses
The 4066 is shown below:
The pin functions are as follows:
Vdd - positive terminal of power supply
Vss - ground
in / out - one point on a switch, labelled A, B, C and D
out / in - the other point on a switch labelled A, B, C and D
control - the control mechanism that determines whether or not a particular switch is currently open or closed, labelled A, B, C and D
By applying a low signal to the control pin of a switch, the in / out and the out / in pins are disconnected. By applying a high signal to the control pin of a switch, the in / out and the out / in pins are connected.
In terms of connecting this chip to the Teensy and the toy, the following setup is required:
• Vss Pin 7 of 4066 to Teensy ground - an orange breadboard jumper
• Vdd Pin 14 of 4066 to Teensy 3V - another orange breadboard jumper
• Control A Pin 13 of the 4066 to Teensy digital pin 0 - a green breadboard jumper
• In / Out of Switch A Pin 1 of 4066 to toy button pin (in this case P11 on the guitar) - the black alligator lead
• Out / In of Switch A Pin 2 of 4066 to the other toy button pin (in this case Vdd on the guitar) - the red alligator lead
These connections are shown below:
Example code is shown below. Note that if this method is used (and the code expanded upon), each of the four 4066 switches can be theoretically used to trigger a different button on a toy or multiple toys. The code is identical to the previous method.
A demonstration video is shown of this setup. Note that the fastest triggering rate is approximately 56m - significantly slower than the previous method. Ableton Live is used to drive the data.
It may be desirable to trigger a button on a toy using MIDI or some other type of data. For instance, a toy generates sound when one or more buttons are pressed. Instead of physically pressing the buttons, note on / note off events can be used to simulate the pressing of buttons.
To achieve this, consider common the types of connections that may be found in toys in terms of button interaction. Whenever a button or a switch is pressed, normally a circuit is closed by connecting two conductors. This is commonly achieved by having a conductive pad attached to a button which, when pressed, physically and electrically connects two previously separated conductive surfaces, as in the image below.
There are a number of ways in which such a button may be wired:
1) One pin of the button is connected to a pin on the microcontroller of the toy, and the other pin is connected to the positive terminal of the battery (may also be labelled Vdd or Vcc)
2) One pin of the button is connected to a pin on the microcontroller of the toy, and the other pin is connected to the negative terminal of the battery (may also be labelled Vee or Vss)
3) One pin of the button is connected to a pin on the microcontroller of the toy, and the other pin of the button is connected a different pin on the microcontroller of the toy
4) It is unknown or difficult to tell where one or both of the pins of the button is connected to
In the methods given below, a Teensy LC or Teensy 3.1 is used to trigger the button connections of a toy using MIDI note data. This simple guitar toy is used as an example. Naturally, these concepts can be expanded to include multiple buttons, different data types etc.
Using A Digital Pin as a Trigger
If the button in question is in category 1 or 2 of the four possibilities mentioned above, then it may be possible to use a digital pin on the Teensy to directly trigger the button connection.
The idea is straightforward - on side of the switch is connected to positive or negative, and the other side of the switch is connected to a pin on the microcontroller of the toy.
When the button is pressed, the positive or negative terminal of the battery is then connected to the pin on the microcontroller of the toy, thus registering a high or low signal and triggering the sound.
The Teensy can act as a replacement for the positive or negative terminal of the battery in this instance, and provide a high or low signal to simulate the connection of the battery to the input pin of the microcontroller.
The great thing about this is that the connections from the Teensy to the toy are very straightforward, as it is simply a matter of connecting the digital pin on the Teensy to the micrcontroller pin of the button of the toy.
If there are inconsistent results, note that it may be necessary to either:
• connect the ground of the Teensy to the negative battery terminal of the toy or
• remove the battery of the toy and power the toy from the 3V pin on the Teensy (assuming a total voltage in the range of 3V - 4.5V)
Consider the simple guitar toy. The connections of one of the buttons that triggers sound on the toy are shown above. Note that the manufacturer has conveniently labelled the two pins of the button with VDD and P11. VDD is connected directly the positive terminal of the battery, and P11 is connected to the microcontroller of the toy.
As a result, whenever a high state is registered on the pin marked P11, the toy assumes that the button has been pressed and the sound is triggered. Whenever a low state is registered on the pin marked P11, the toy assumes that the button has been depressed.
In this example, it is also necessary to power the guitar toy using the Teensy.
Three connections from the Teensy to the guitar toy are necessary to directly trigger P11:
• The battery is disconnected from the toy
• Ground from the Teensy to the point on the circuit board where the negative terminal of the battery was connected (white alligator lead)
• 3V from the Teensy to the point on the circuit board where the positive terminal of the battery was connected (red alligator lead)
• Teensy digital pin 0 to connection P11 on the guitar toy (black alligator lead)
Example code is shown below. Note that if this method is used (and the code expanded upon), each digital pin on the Teensy can be theoretically used to trigger a different button on a toy or multiple toys.
A demonstration video is shown of this setup. Note that the fastest triggering rate is approximately 45ms. Ableton Live is used to drive the data.
Using a 4066 IC to Simulate Button Presses
Although the above method will work in certain situations, a more complex method may be used in the following situations:
• One pin of the button is connected to a pin on the microcontroller of the toy, and the other pin of the button is connected a different pin on the microcontroller of the toy
• It is unknown or difficult to tell where one or both of the pins of the button is connected to
This method will use the 4066 IC to simulate button presses. This chip is a fourteen pin quad switch, meaning that the switch has the facility to make and break connections for four pairs of points. Each pair of connections can potentially be connected to pairs of button pins on toys to simulate button presses
The 4066 is shown below:
The pin functions are as follows:
Vdd - positive terminal of power supply
Vss - ground
in / out - one point on a switch, labelled A, B, C and D
out / in - the other point on a switch labelled A, B, C and D
control - the control mechanism that determines whether or not a particular switch is currently open or closed, labelled A, B, C and D
By applying a low signal to the control pin of a switch, the in / out and the out / in pins are disconnected. By applying a high signal to the control pin of a switch, the in / out and the out / in pins are connected.
In terms of connecting this chip to the Teensy and the toy, the following setup is required:
• Vss Pin 7 of 4066 to Teensy ground - an orange breadboard jumper
• Vdd Pin 14 of 4066 to Teensy 3V - another orange breadboard jumper
• Control A Pin 13 of the 4066 to Teensy digital pin 0 - a green breadboard jumper
• In / Out of Switch A Pin 1 of 4066 to toy button pin (in this case P11 on the guitar) - the black alligator lead
• Out / In of Switch A Pin 2 of 4066 to the other toy button pin (in this case Vdd on the guitar) - the red alligator lead
These connections are shown below:
Example code is shown below. Note that if this method is used (and the code expanded upon), each of the four 4066 switches can be theoretically used to trigger a different button on a toy or multiple toys. The code is identical to the previous method.
A demonstration video is shown of this setup. Note that the fastest triggering rate is approximately 56m - significantly slower than the previous method. Ableton Live is used to drive the data.
Labels:
circuit bending,
circuit bending basics
Friday, May 24, 2013
Circuit Bending Basics 8: Independent Multi Button Triggering
Overview
This post assumes that you are familiar with the previous Circuit Bending Basics Posts.
Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!
Multi Button Triggering
A previous post demonstrated how to trigger a single button using a 4066 chip. The 4066 chip has four such functional blocks. This article demonstrates how to use all four of these blocks. It is a assumed that you have read the previous post in question.
Schematic
Code
Download here: http://milkcrate.com.au/_other/downloads/projects/_4066_example/_4066_example.ino
Example - Toy Keyboard
Video Demonstration
This post assumes that you are familiar with the previous Circuit Bending Basics Posts.
Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!
Multi Button Triggering
A previous post demonstrated how to trigger a single button using a 4066 chip. The 4066 chip has four such functional blocks. This article demonstrates how to use all four of these blocks. It is a assumed that you have read the previous post in question.
Schematic
The red pair, yellow pair, green pair and orange pair of connections each represent a pair of points on a circuit board that triggers sounds and thus replaces buttons.
Code
Download here: http://milkcrate.com.au/_other/downloads/projects/_4066_example/_4066_example.ino
Example - Toy Keyboard
Video Demonstration
Labels:
circuit bending,
circuit bending basics
Circuit Bending Basics 7: MIDI-controlled Toy Pitch / Speed
Overview
This post assumes that you are familiar with the previous Circuit Bending Basics Posts.
Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!
Digital Pot and Toy Control
This article is based around the MCP4212 digital pot and the Teensy - so if you're not familiar with either, please visit the Teensy website, read up a little on Arduino coding and check out my Teensy Basics series of posts. Also, be sure to check out the MCP4212 tutorial.
This article will provide a simple framework that can be used to control the pitch / speed of a toy using MIDI pitch data. The higher the pitch, the higher the speed of the toy.
In general, the process is like this:
• Build the barebones MCP4212 and Teensy setup as shown in the tutorial
• Find the clock resistor of a toy that you wish to control
• Remove the resistor
• Connect the two resistive points on the toy's circuit to the P0A and P0W pins of the MCP4212
• Write some code to control pot 0 of the MCP4212 via MIDI
Connecting the Digital Pot to the Toy - Example
Once again, we revisit the musical mat toy from the previous Circuit Bending Basics.
The resistor in this particular toy is simple to remove. The two resistive connections on the board were soldered to two white wires, which were then connected to P0A and P0W pins of the MCP4212.
In the first image, these connections are highlighted in purple.
Writing the Code
The code takes the pitch value of a note-on MIDI message, and sends that value to the digital pot. The digital pot then sets this as a resistance.
The code uses the same SPI library as in the MCP4212 example. The code uses the same user-defined MCP4212 function as in the MCP4212. The changes in the fact that the usbMIDI functions are connected to the digital pot.
Download the code here: http://milkcrate.com.au/_other/downloads/projects/MCP4241_104EP_Example_2/MCP4241_104EP_Example_2.ino
Example Video
This post assumes that you are familiar with the previous Circuit Bending Basics Posts.
Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!
Digital Pot and Toy Control
This article is based around the MCP4212 digital pot and the Teensy - so if you're not familiar with either, please visit the Teensy website, read up a little on Arduino coding and check out my Teensy Basics series of posts. Also, be sure to check out the MCP4212 tutorial.
This article will provide a simple framework that can be used to control the pitch / speed of a toy using MIDI pitch data. The higher the pitch, the higher the speed of the toy.
In general, the process is like this:
• Build the barebones MCP4212 and Teensy setup as shown in the tutorial
• Find the clock resistor of a toy that you wish to control
• Remove the resistor
• Connect the two resistive points on the toy's circuit to the P0A and P0W pins of the MCP4212
• Write some code to control pot 0 of the MCP4212 via MIDI
Connecting the Digital Pot to the Toy - Example
Once again, we revisit the musical mat toy from the previous Circuit Bending Basics.
The resistor in this particular toy is simple to remove. The two resistive connections on the board were soldered to two white wires, which were then connected to P0A and P0W pins of the MCP4212.
In the first image, these connections are highlighted in purple.
Writing the Code
The code takes the pitch value of a note-on MIDI message, and sends that value to the digital pot. The digital pot then sets this as a resistance.
The code uses the same SPI library as in the MCP4212 example. The code uses the same user-defined MCP4212 function as in the MCP4212. The changes in the fact that the usbMIDI functions are connected to the digital pot.
Download the code here: http://milkcrate.com.au/_other/downloads/projects/MCP4241_104EP_Example_2/MCP4241_104EP_Example_2.ino
Example Video
Labels:
circuit bending,
circuit bending basics
Thursday, May 23, 2013
Circuit Bending Basics 6: Dual Multiplexing for Many Different Button Triggers
Overview
This post assumes that you are familiar with the previous Circuit Bending Basics Posts.
Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!
Dual Multiplexing Concept
This post builds on a previous example, which explored the use of multiplexing in the context of triggering buttons of a toy.
In the previous example, a monophonic toy had eight musical buttons and many other non-musical sounds. The eight musical buttons were triggered using a multiplexer.
This post extends that basic idea by adding a second multiplexer to the mix.
Let's go back and examine the musical mat, and the way that the buttons are wired:
Upon testing all of the button pins, a pattern emerged. Let's consider the button pins as either being a letter (for the horizontal ones) or a number (for the vertical ones), as shown in the above image.
By connecting any of the pins labeled with letters (in purple) with the pins labeled with numbers (in green), a sound is triggered. Interesting, the letter determines the sound "category" whilst the number determines the actual button pressed.
Connecting A to 1 is the same as pressing the physical toy button on the musical mat for the note C. Connecting A to 2 is the same as pressing the physical toy button on the musical mat for the note D. Connecting A to 3 is the same as pressing the physical toy button on the musical mat for the note E and so on.
Let's illustrate this with a diagram:
Now, we have already triggered all of the A button group buttons using a single multiplexer in the previous example. But, if we look at the structure, there are actually a total of 32 trigger points, if all connections between numbers and letters are considered, like this:
So, the aim of this blog post is to describe and practically explore ways of combining two multiplexers to be able to recreate any one of the 32 connections shown above at will.
In fact, if there were up eight letters and eight numbers (64 connections), then this would be possible too.
Dual Multiplexing
In the previous example, we looked at the concept of having 8 inputs multiplexed to one output, like so:
Video
int ON_4066 = 6;
void setup() {
usbMIDI.setHandleNoteOn(OnNoteOn);
usbMIDI.setHandleNoteOff(OnNoteOff);
DDRB = B00011111;
pinMode(INH, OUTPUT);
pinMode(ON_4066, OUTPUT);
pinMode(11, OUTPUT);
digitalWrite(INH, HIGH);
digitalWrite(ON_4066, LOW);
digitalWrite(11, HIGH);
}
void loop() {
usbMIDI.read();
}
void OnNoteOn(byte channel, byte pitch, byte velocity) {
if(velocity > 0) {
PORTB = pitch % 32;
delay(1);
digitalWrite(INH, LOW);
digitalWrite(ON_4066, HIGH);
digitalWrite(11, HIGH);
}
else {
digitalWrite(INH, HIGH);
digitalWrite(ON_4066, LOW);
digitalWrite(11, LOW);
}
}
void OnNoteOff(byte channel, byte pitch, byte velocity) {
digitalWrite(INH, HIGH);
digitalWrite(ON_4066, LOW);
digitalWrite(11, LOW);
}
Toy Guitar Example
The same concept can be applied to other toys as well. Here is an example with a toy electric guitar:
Video
Code for Teensy
int INH = 5;
int delay_time = 100;
void setup() {
usbMIDI.setHandleNoteOn(OnNoteOn);
usbMIDI.setHandleNoteOff(OnNoteOff);
DDRB = PINB & B00001111;
pinMode(INH, OUTPUT);
pinMode(11, OUTPUT);
digitalWrite(INH, HIGH);
digitalWrite(11, HIGH);
}
void loop() {
usbMIDI.read();
}
void OnNoteOn(byte channel, byte pitch, byte velocity) {
if(velocity > 0) {
PORTB = pitch % 12;
digitalWrite(INH, LOW);
digitalWrite(11, HIGH);
}
else {
digitalWrite(INH, HIGH);
digitalWrite(11, LOW);
}
}
void OnNoteOff(byte channel, byte pitch, byte velocity) {
digitalWrite(INH, HIGH);
digitalWrite(11, LOW);
}
This post assumes that you are familiar with the previous Circuit Bending Basics Posts.
Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!
Dual Multiplexing Concept
This post builds on a previous example, which explored the use of multiplexing in the context of triggering buttons of a toy.
In the previous example, a monophonic toy had eight musical buttons and many other non-musical sounds. The eight musical buttons were triggered using a multiplexer.
This post extends that basic idea by adding a second multiplexer to the mix.
Let's go back and examine the musical mat, and the way that the buttons are wired:
Upon testing all of the button pins, a pattern emerged. Let's consider the button pins as either being a letter (for the horizontal ones) or a number (for the vertical ones), as shown in the above image.
By connecting any of the pins labeled with letters (in purple) with the pins labeled with numbers (in green), a sound is triggered. Interesting, the letter determines the sound "category" whilst the number determines the actual button pressed.
Connecting A to 1 is the same as pressing the physical toy button on the musical mat for the note C. Connecting A to 2 is the same as pressing the physical toy button on the musical mat for the note D. Connecting A to 3 is the same as pressing the physical toy button on the musical mat for the note E and so on.
Let's illustrate this with a diagram:
A connection between point A and point 1 is the same as pressing the C note on the mat.
Now, we have already triggered all of the A button group buttons using a single multiplexer in the previous example. But, if we look at the structure, there are actually a total of 32 trigger points, if all connections between numbers and letters are considered, like this:
So, the aim of this blog post is to describe and practically explore ways of combining two multiplexers to be able to recreate any one of the 32 connections shown above at will.
In fact, if there were up eight letters and eight numbers (64 connections), then this would be possible too.
Dual Multiplexing
In the previous example, we looked at the concept of having 8 inputs multiplexed to one output, like so:
The good thing about the 4051 chip is that it doesn't care what is an input and what is an output. That is to say, we can reverse this action, like so, and take one input and send it to many outputs (one output at a time, of course, depending on control mechanism):
Now, let's connect the normal multiplexer to the reverse mutliplexer,like so:
In this way, we can have up to 64 independent signals travelling through and being controlled by two 8 channel multiplexers.
Bringing it Together
If we combine the desire to emulate all of those button presses between the letter and number combination with the concept of a dual stage multiplexing setup, then we can end up with a concept like this:
Thus, any of the 32 possible sounds of the musical mat can be triggered!
Of course, in reality it looks a little messy...
Code for Teensy
int INH = 5; int ON_4066 = 6;
void setup() {
usbMIDI.setHandleNoteOn(OnNoteOn);
usbMIDI.setHandleNoteOff(OnNoteOff);
DDRB = B00011111;
pinMode(INH, OUTPUT);
pinMode(ON_4066, OUTPUT);
pinMode(11, OUTPUT);
digitalWrite(INH, HIGH);
digitalWrite(ON_4066, LOW);
digitalWrite(11, HIGH);
}
void loop() {
usbMIDI.read();
}
void OnNoteOn(byte channel, byte pitch, byte velocity) {
if(velocity > 0) {
PORTB = pitch % 32;
delay(1);
digitalWrite(INH, LOW);
digitalWrite(ON_4066, HIGH);
digitalWrite(11, HIGH);
}
else {
digitalWrite(INH, HIGH);
digitalWrite(ON_4066, LOW);
digitalWrite(11, LOW);
}
}
void OnNoteOff(byte channel, byte pitch, byte velocity) {
digitalWrite(INH, HIGH);
digitalWrite(ON_4066, LOW);
digitalWrite(11, LOW);
}
Toy Guitar Example
The same concept can be applied to other toys as well. Here is an example with a toy electric guitar:
Video
Code for Teensy
int INH = 5;
int delay_time = 100;
void setup() {
usbMIDI.setHandleNoteOn(OnNoteOn);
usbMIDI.setHandleNoteOff(OnNoteOff);
DDRB = PINB & B00001111;
pinMode(INH, OUTPUT);
pinMode(11, OUTPUT);
digitalWrite(INH, HIGH);
digitalWrite(11, HIGH);
}
void loop() {
usbMIDI.read();
}
void OnNoteOn(byte channel, byte pitch, byte velocity) {
if(velocity > 0) {
PORTB = pitch % 12;
digitalWrite(INH, LOW);
digitalWrite(11, HIGH);
}
else {
digitalWrite(INH, HIGH);
digitalWrite(11, LOW);
}
}
void OnNoteOff(byte channel, byte pitch, byte velocity) {
digitalWrite(INH, HIGH);
digitalWrite(11, LOW);
}
Labels:
circuit bending,
circuit bending basics
Circuit Bending Basics 5: On Desoldering SMD Resistors
Overview
This post assumes that you have read Circuit Bending Basics 1, 2, 3 and 4.
Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!
SMD Resistors
Sometimes, the clock resistor of a toy is easy to remove.
The resistor may be a through-hole resistor like this, and can be removed manually or by de-soldering easily.
With other circuits, the clock resistor may be a tiny component - like those shown below - called "surface mount resistors". These are more difficult to remove and can prove to be a nuisance sometimes.
My method for removing these is as follows:
• The surface mount resistor has a body and two terminals.
• The aim of removing the resistor might be so that we can connect something in place of the resistor - in which case we need access to the two terminals
• Carefully heat up the area right next to and underneath the body of the SMD resistor with a soldering iron.
• You should notice that the body of the resistor becomes loose
• With a little force, flick the body with the soldering iron tip, thereby removing the body from the circuit board completely
• Add a little solder to each of the terminals that are left over
• Solder wires directly to the terminals, thereby creating easy access to the resistive points for substitution
• You can then replace the static resistor with a variable resistor (e.g. pot, digi pot, LDR, flex etc).
This post assumes that you have read Circuit Bending Basics 1, 2, 3 and 4.
Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!
SMD Resistors
Sometimes, the clock resistor of a toy is easy to remove.
The resistor may be a through-hole resistor like this, and can be removed manually or by de-soldering easily.
With other circuits, the clock resistor may be a tiny component - like those shown below - called "surface mount resistors". These are more difficult to remove and can prove to be a nuisance sometimes.
My method for removing these is as follows:
• The surface mount resistor has a body and two terminals.
• The aim of removing the resistor might be so that we can connect something in place of the resistor - in which case we need access to the two terminals
• Carefully heat up the area right next to and underneath the body of the SMD resistor with a soldering iron.
• You should notice that the body of the resistor becomes loose
• With a little force, flick the body with the soldering iron tip, thereby removing the body from the circuit board completely
• Add a little solder to each of the terminals that are left over
• Solder wires directly to the terminals, thereby creating easy access to the resistive points for substitution
• You can then replace the static resistor with a variable resistor (e.g. pot, digi pot, LDR, flex etc).
Labels:
circuit bending,
circuit bending basics
Wednesday, May 22, 2013
Circuit Bending Basics 4: Multiplexing Common-Point Buttons
This post assumes that you have read Circuit Bending Basics 1, 2 and 3.
This post also assumes that you are familiar with Arduino and / or Teensy.
Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!
The aim of this post is to demonstrate how to trigger / emulate button presses of a toy using a microcontroller. In particular, this methodology - of using a multiplexer to emulate button presses - will only work in certain situations (as described below).
Nonetheless, this opens the door for many possibilities, such as MIDI control, oscillator control and so on.
Common-point Buttons
In the previous Circuit Bending Basics article, we looked at how to connect two points on a circuit, thereby emulating button presses.
Many circuits feature a "common point" series of buttons - that is to say, a series of buttons whereby, when pressed, two points are connected. However, more than one button shares a single, electrical connection point.
As an example, let's have another look at the musical mat from the previous three Circuit Bending Basics posts.
The above image shows the main circuit board of the musical mat. The horizontal and vertical pins are soldered to the main board, and here we can see those connections.
Upon testing all of the button pins, a pattern emerged. Let's consider the button pins as either being a letter (for the horizontal ones) or a number (for the vertical ones), as shown in the above image.
By connecting any of the pins labeled with letters (in purple) with the pins labeled with numbers (in green), a sound is triggered. Interesting, the letter determines the sound "category" whilst the number determines the actual button pressed.
Connecting A to 1 is the same as pressing the physical toy button on the musical mat for the note C. Connecting A to 2 is the same as pressing the physical toy button on the musical mat for the note D. Connecting A to 3 is the same as pressing the physical toy button on the musical mat for the note E and so on.
Let's illustrate this with a diagram:
A connection between point A and point 1 is the same as pressing the C note on the mat.
A connection between point A and point 2 is the same as pressing the D note on the mat.
A connection between point A and point 3 is the same as pressing the E note on the mat.
A connection between point A and point 4 is the same as pressing the F note on the mat.
A connection between point A and point 5 is the same as pressing the G note on the mat.
A connection between point A and point 6 is the same as pressing the A note on the mat.
A connection between point A and point 7 is the same as pressing the B note on the mat.
A connection between point A and point 8 is the same as pressing the C 8ve note on the mat.
Let's call this type of button series "common point buttons", because they all share a common point (i.e. point A). In fact, in the above example, let's call the 'A' the common point, and all of the other points individual points.
We can use this to our advantage, but to do so, we have to understand and explore the 4051 analog multiplexer.
Multiplexing with a 4051
A multiplexer has more than one input and only one output. Only one input is ever connected to the output at any one time. A selection mechanism chooses which of the inputs is connected to the output at any one time.
This is a representation of a "2 to 1" multiplexer. The multiplexer has two inputs, one output and a selection mechanism to select between the two inputs.
An example of an analog multiplexer-demultiplexer (mux demux) is the 4051 chip. The 4051 has eight inputs (or outputs), one output (or input) and a control mechanism for selecting which of the eight connections is connecting to the common output (or input).
Let's have a look at this physical and function layout of the 4051 chip:
VDD = 5V power
VSS = chip ground
VEE = analog signal ground
INH = ground for normal operation, 5V for inhibit
IN / OUT = multiple connections
OUT / IN = common connection
A, B and C = selection mechanism
The 4051 has eight channels (numbered 0 - 7) and a common connection pin.
Depending on the status of the three address pins A,B and C in combination determines which of the eight channels passes its present voltage to the common connection pin.
Logically, we can think of the eight channel pins as eight gates, of which only one can be open (ie. connected to the common pin) at any one time. The relationship between which gate is currently selected via the three address pins can be seen below in the truth table.
From the truth table, we can see that A, B and C are digital inputs. Different combinations set different multiplexer states. A is the lowest bit, B is the middle bit and C is the highest bit.
Examples of multiplexer states are as follows:
Multiplexing Common-Point Buttons Concept
With our common point buttons we have:
• Multiple buttons that share common points
With our multiplexer we have:
• A device that connects things together, that share a common point
Obviously, they complement each other!
We can summarise this complimentary relationship in the following diagram:
Basically, the 4051 "selects" which of the button pins 1 - 8 to connect with the common button pin A. A microcontroller such as the Arduino or the Teensy can control the multiplexer easily.
Connecting the Multiplexer - Example
But, how do we connect the multiplexer to the circuit?
In general, we connect the common pin of the buttons to the common output pin on the mulitplexer, and we connect each individual button pin to each input pin on the multiplexer.
For example, with the music mat:
• Connect the "A" pin to the common output pin of the 4051
• Connect the numbered pins "1", "2", etc to the input pins 1, 2 etc of the 4051.
Now, lets connect the multiplexer to the Arduino or Teensy!
• Arduino / Teensy ground goes to pins 6, 7 and 8 of the 4051 as well as ground from the toy
• Arduino / Teensy 5V goes to pin 16 of the 4051
• Digital pins 0, 1 and 2 of the Teensy or digital pins 8, 9 and 10 go to pins 11, 10 and 9 of the 4051
Example wiring for Teensy:
Example wiring for Arduino:
Actual Wiring Example:
Programming the Arduino / Teensy - Basic Example
To write a simple program for the Arduino / Teensy, we need to consider that we want to manipulate PORTB of the microcontroller. As a result, this will select the 4051. Below is some example code, which will switch between all eight buttons, changing once every 100ms.
void setup() {
DDRB = PINB | B00000111;
}
void loop() {
for(int i = 0; i < 8; i ++) {
PORTB = i;
delay(100);
}
}
Programming the Teensy - MIDI Note Pitch Example
An extended example links a MIDI note with selecting the button press. Different pitches will trigger different buttons.
int delay_time = 100;
void setup() {
usbMIDI.setHandleNoteOn(OnNoteOn);
usbMIDI.setHandleNoteOff(OnNoteOff);
DDRB = PINB & B00000111;
pinMode(ON_PIN, OUTPUT);
pinMode(11, OUTPUT);
pinMode(11, HIGH);
}
void loop() {
usbMIDI.read();
}
void OnNoteOn(byte channel, byte pitch, byte velocity) {
if(velocity > 0) {
PORTB = pitch % 8;
digitalWrite(11, HIGH);
}
else {
digitalWrite(11, LOW);
}
}
void OnNoteOff(byte channel, byte pitch, byte velocity) {
digitalWrite(11, LOW);
}
Demonstration Video
Conclusion
Many toys seem to use a common buttons approach to circuit structure, and this technique allows relatively easy control over the button pressing.
The code and circuit can both be refined and extended.
Labels:
circuit bending,
circuit bending basics
Subscribe to:
Posts (Atom)