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:


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







Video


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);
}
 
 


0 comments: