• Home
  • Back to Sonic Robots Main page
  • About
  • Contact

Recital

  • Learning
    • MR 808 Technique – Acoustics
    • MR-808 Technique – IT & Interaction
    • Browse all
    • Electronics
    • 3D-Printing
    • Modding
    • Arduino
    • Technical practice
    • Sensors
  • Music robots list
    • Browse all
    • Autonomous
    • Experimental
    • Glockenspiel & mallet
    • Floppy & retro
    • Piano robots
    • Robot bands
    • Robotic drum
    • String robots
  • Research
    • Lectures

Learning 12

Choosing the right optocoupler for your midi-in project (e.g. Arduino)

Choosing the right optocoppler for your midi-in project (e.g. Arduino)

The headlines almost says it all: when building an midi-input device for an µC-project e.g. an Arduino or an Raspberry Pi project, the first thing the MIDI cable “sees” is the optocoupler. And is important to choose the right one.
midiin


A lot of ciruits relate to the “4N28”. This is a passive optocoupler and to be frank it causes a lot of problems in the standard setup which mostly are not identified as an electrical problem.

  • no midi input at all
  • random loss of midi notes
  • random playing of other midi notes

(more…)

9 years ago Leave a reply Allgemein, Arduino, Electronics

Simple Arduino Square Pulse Generator

Creates a square pulse on Digital out in relation to two potentiometers on A0 and A2. The Pulse generator can be controlled in periode (10ms .. 1024ms) and puls width. It works without PWM and without delay() and is based on the blinkwithout sketch
periode

int state1 = 0; // state of the output1; 0 --> OFF, 1 --> ON
unsigned long currentMillis = millis(); // derive actual timestamp
unsigned long startMillis = millis(); // derive actual timestamp

void setup() {                
  // initialize the digital pin as an output.
  pinMode(3, OUTPUT);     
  pinMode(13, OUTPUT);   
  
  //////////////////////////////
  
  digitalWrite(3, LOW);    // turn the output off 
  currentMillis = millis(); // derive actual timestamp
  startMillis = millis(); // derive actual timestamp

}
   /////////////////////////////
   
void loop() {

  if(currentMillis - startMillis <= pulsewidth_1) {
    state1 = HIGH;
  }
  
  if (currentMillis - startMillis >= constrain(analogRead(A0), 5, analogRead(A1))) // Create the pulsewidth. Read Analog POT at A0, contraint (limit) the amount to maximum periode, more wouldnt make sense
  {
        state1 = LOW;
  }
  
  if (currentMillis - startMillis >= constrain((analogRead(A1)*1.5),10,20000 )) // Create the periode (hz). Read Analog POT at A1, contraint (limit) the amount to minimum 10ms
  {
        state1 = LOW;
        startMillis = millis();  
  }
  
    digitalWrite(3, state1);
    currentMillis = millis();

}

9 years ago Leave a reply Allgemein, Arduino, Electronics

Midi-in Pitchbend with an Arduino

pitchbend2 (3)

Connecting MIDI and Arduino is easy, especially with the new MIDI library. Most of the people use the Arduino to trigger midi signals when pressing buttons and moving faders. Today we want to do it the other way around: Controlling a little oszillator – a square output signal tone() – with an Midi-In signal from a keyboard. The speciality: we want to implement the pitchbend send by the midi master.

Midi Pitchbend

The pitchbend is a controller value that can be send from a midi master. It alters the pitch of a note. It is separated in 3 bytes as can be seen below: the first one states (more…)

9 years ago 3 Comments Allgemein, Arduino, Electronics

Plastikliebe – 3D Printing and 3D-Druck in Dresden

plastikliebeTHE ROBOTS ARE SORRY, BUT THIS ARTICLE IS ONLY IN GERMAN.
Als ich vor über einem Jahr den ersten Artikel zum meinem 3D-Drucker Makerbot in Dresden schrieb, hätte ich nicht erwartet, soviele Rückmeldungen zu erhalten.
Wegen des großen Interesses habe ich mich nun entschlossen die Seite plastikliebe.de online zu stellen, wo Infos zum Rapid Prototyping und 3D-Druck nochmal kurz zusammengefasst werden. Es geht mir nicht darum, (more…)

9 years ago 1 Comment 3D Printing, Allgemein

Nerdtagebuch: Ein Jahr 3D-Druck mit dem Makerbot

Seit gut einem Jahr habe ich nun einen 3-D Drucker Replicator (erste Generation) von Makerbot und aufgrund der vielen Rückfragen zu meinem ersten Artikel möchte ich zusammentragen, was ich bisher für Erlebnisse hatte. Denn die meistgestellte Frage lautet nach wie vor: Lohnt sich die Anschaffung so eines 1500-2500€ teuren Gadgets.

Zuallererst: ich bin auch nach einem Jahr Arbeit mit dem Replicator 1 immer noch sehr zufrieden. Ich drucke im Schnitt alle zwei Tage, größtenteils für meine verschiedenen Kunst- und Technikprojekte, gelegentlich auch für Freunde oder Auftragsweise.

Ja, Ja, Ja – 3D-Drucker sind noch “für Bastler”. Will heißen: 3D Druck ist anspruchsvoller als Papierdruck. Mensch muss sich circa nach 3-10 Prints mit Reparaturen oder Neu-Einstellungen beschäftigen. Aber zwischen dem Neuprogrammieren einer alten CNC Fräse und dem Handyakkuwechseln gibt es ja Zwischentöne.
Die Punkte die ich im folgenden beschreibe, gelten für meinen Replicator 1 und ich denke grundsätzlich auch für den Replicator 2. Sie geben einen ganz guten Einblick, was man ungefähr für einen Aufwand aufbringen muss um einen 3D Drucker am Laufen zu halten.

Einrichtung und Einarbeitungszeit

Ich hatte mir Mitte 2012 einen frisch auf dem Markt befindlichen Replicator1 gekauft, (more…)

10 years ago 4 Comments 3D Printing, Allgemein

Yet another Arduinoboy Gameboy and Midi HowTo

Arduinoboy along with some other studio gear

Arduinoboy along with some other studio gear

I lately build an Arduinoboy (Gameboy + Arduino + Midi) for our Band “Sonic Robots” and found the information on the net quite dispersive for a 8bit-n00b like me. So here’s yet another Arduinoboy tutorial sharing my experience and adding some smaller hacks.
The use of 8-Bit sounds (more…)

10 years ago Allgemein, Arduino, Electronics, Repairing and moding stuff

Midi to DMX arduino control shield

Yesterday night I hacked together a quick and dirty Arduino MIDI-to-DMX control . It’s really simple! And here’s how I did it.

Goal:

I have two really cheap LED Par56 from Stairville (DMX controlled), a simple DMX-Dimmer pack and use Ableton Live for our sound setup. So all I want is to control the different colors and dimmer channels (DMX channels) with each one Midi-Note. The pitch (note) shall represent the channel, the midi velocity shall represent the actual DMX-value (brightness).

DMX-protocol

Some words about the DMX protocol: This is a really simple serial protocol, the connectors are 3-pole XLR and yep – you can use normal audio XLR-cables. The devices (my LED-Par for example) are connected in a chain. Each device can have one or more channels, there are up to 255 channels per chain possible. Let’s have a look at a standard LED PAR56 channel setup:
DMX-LED-PAR-Channels

So all we have to do is to send something from “0 to 63” to “channel 1” to set the device to RGB Mode and then the brightness value (0..255) to channel “1..3“ for the brightness of the different colors. Really easy. When you set another start address for the DMX Device, the 5 channels are shifted, e.g. to 7,8,9,10,11.

Circuit

I combined a MIDI-In Circuit with the “DMX.Simple” library. Here are the resources:
Simple DMX Code
Simple DMX Circuit

One Note: this circuit does not provide isolation. Be sure to connect all devices and the control to the same electrical loop (Phase).

Parts list: (~10€ w/o Arduino)

  • R 3,3K Ohm
  • R 220 Ohm
  • Diode 1N4148
  • Opto copler 4N28
  • Serial transmitter 75176AP
  • XLR Jack female
  • 5-Pin DIN Jack female (Midi Jack)
  • Arduino Uno (Nano, Duemilanove and all the others will probably work as well) (~30€)

You have two sections: opto copler 4N28 for handling the MIDI-In. You can probably use other types like the 4N38 as well. Secondly the DMX output section that consists of a serial converter 75176, here you could also use the standard chip MAX481 (see this tutorial)

Code

Preparation: You have to install the Simple.DMX library (howto install a Arduino library) get the library here
The code is not too nice written, but works as supposed and can be easily adapted.

// welcome to MIDI to DMX by moritz Simon geist.
// Ressources, setup and hardware: http://sonicrobots.com/?p=864
// DmxSimple is available from: http://code.google.com/p/tinkerit/
// Help and support: http://groups.google.com/group/dmxsimple       */

#include 
byte incomingByte;
byte note;
byte velocity;
int statusLed = 13;   // select the pin for the LED
int action=2; //0 =note off ; 1=note on ; 2= nada

void setup() {
    pinMode(statusLed,OUTPUT);   // declare the LED's pin as output
  //start serial with midi baudrate 31250 or 38400 for debugging
  Serial.begin(31250);       
  /* The most common pin for DMX output is pin 3, which DmxSimple
  ** uses by default. If you need to change that, do it here. */

  DmxSimple.usePin(3);

  /* DMX devices typically need to receive a complete set of channels
  ** even if you only need to adjust the first channel. You can
  ** easily change the number of channels sent here. If you don't
  ** do this, DmxSimple will set the maximum channel number to the
  ** highest channel you DmxSimple.write() to. */

  DmxSimple.maxChannel(5);

}
void loop () {
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // wait for as status-byte, channel 1, note on or off
    if (incomingByte== 144){ // note on message starting starting
      action=1;
    }else if (incomingByte== 128){ // note off message starting
      action=0;
    }else if (incomingByte== 208){ // aftertouch message starting
       //not implemented yet
    }else if (incomingByte== 160){ // polypressure message starting
       //not implemented yet
    }else if ( (action==0)&&(note==0) ){ // if we received a "note off", we wait for which note (databyte)
      note=incomingByte;
      playNote(note, 0);
      note=0;
      velocity=0;
      action=2;
    }else if ( (action==1)&&(note==0) ){ // if we received a "note on", we wait for the note (databyte)
      note=incomingByte;
    }else if ( (action==1)&&(note!=0) ){ // ...and then the velocity
      velocity=incomingByte;
      playNote(note, velocity);
      note=0;
      velocity=0;
      action=0;
    }else{
      //nada
    }
  }
}

void playNote(byte note, byte velocity){
  int value=0;
  if (velocity >10){
      value=255;
  }else{
   value=0;
  }
  // =DEVICE 1=
  // DMX CHANEL 1: "2" for seting DMX Mode
  // DMX CHANEL 2: 0 .. 255 Control Red     --> .... MIDI Note "1" (possible C-2)
  // DMX CHANEL 3: 0 .. 255 Control Green   --> .... MIDI Note "2"
  // DMX CHANEL 4: 0 .. 255 Control Blue    --> .... MIDI Note "3"
  // DMX CHANEL 5: NADA
  
  // =DEVICE 2=
  // DMX CHANEL 8: "2" for seting DMX Mode  
  // DMX CHANEL 9: 0 .. 255 Control Red      --> .... MIDI Note 4
  // DMX CHANEL 10: 0 .. 255 Control Green   --> .... MIDI Note 5
  // DMX CHANEL 11: 0 .. 255 Control Blue    --> .... MIDI Note 6
  // DMX CHANEL 12: NADA
  
  

// ADAPT THIS to match your Midi Notes to your DMX Channels
 if(note>=1 && note<10){

    switch (note) {
    case 1:
    DmxSimple.write(2, velocity); 
      break;
    case 2:
    DmxSimple.write(3, velocity); 
      break;
    case 3:
    DmxSimple.write(4, velocity); 
      break;
    case 4:
    DmxSimple.write(9, velocity); 
      break;
    case 5:
    DmxSimple.write(10, velocity); 
      break;
    case 6:
    DmxSimple.write(11, velocity); 
      break;
      //[ ... ] add more channels
  }
   

 }

}



  

MIDI-Programming

So what we have here is, that we control each of the DMX channels with one note and its velocity. We can for example set red from LED PAR1 to 255 (100%) and blue and green from LEDPAR2 to each 128 (50%). The light will cease when the Midi note-off command is sent.

In Ableton I opened up a new Midi track where I can control the lights with notes. What I did to have a hardware master fader: I added a Midi device to control the velocity of all the notes, and midi mapped it to my APC40 midi controller. Like that I additionally have a hardware master fader!

Troubleshooting & FAQ

It doesn’t work!

When you build the circuit be sure to debug one thing after the other.

  • First you can check if the MIDI-In circuit works with this little program I have written. It simply lights the status LED 13 when Midi data is coming in. When it doesn’t, you better check your input circuit or your midi device.
  • Next you can check the DMX output stage with the “Fade” sketch that came with your DMX Library. Play around with the DMX.write() commands until you see something.
  • Did you check the DMX settings of your device? Normally they can be set to “manual”, “DMX” or “Auto” Mode with little switches. The DMX starting address is also set here. Be sure to consult the manual to do it right.

What about Isolation?

This circuit doesn’t provide isolation, so be sure to connect all devices, and the control to ONLY ONE ELECTRIC LOOP (Phase). If you don’t, you can possible blow your equipment.

10 years ago 6 Comments Allgemein, Arduino, Electronicsdmx, midi, midi2dmx

A latency control concept for midi driven mechanic robotic instruments

When combining different robo-mechanic instruments and let them jam together, the most crucial point (beside from making awesome music) is to set the latencies right. The setup is mostly the same: we have a robotic music instrument (e.g. a snare with an solenoid actor), a somewhat electric power unit (Relay, Motordriver / FET-drive and an Arduino) and a unit to generate the information, e.g. keyboard or a midi-program like Ableton.
Each instrument has its own unique latency, given by the time between the “note on” signal (e.g. Ableton triggering a note in the sequencer), and the time when the tone finally leaves the physical instrument. These latencies can be up to several 100 microseconds, a delay that a human ear will definitely recognize. The latency consists of (more…)

10 years ago Leave a reply Allgemein, learning, Media Art Installation - Techniquecontroller, controlling, latency, midi, robotics

The PWM Controller TLC 5940, the Arduino and a high current output circuit

THERE IS AN UPDATE TO THIS ARTICLE

The TLC 5940 is a superb PWM Controller that provides 16 PWM outputs which can be controlled individually over an serial interface using only 5 pins of an Arduino. Many people use it to control RGB LEDs, but it can also be used when controlling Motors, Servos and Solenoids. (more…)

10 years ago 4 Comments Allgemein, Arduino, Electronicsarduino, electronics, LED, solenoid, tlc5490
Newer posts
Recent Posts
  • Popcorn Drums Piezo Midi Controller
  • Touch Piano with MIDI USB on Arduino Leonardo
  • Volca Korg External Power DC Plug
  • How to Build Techno Music Robots
  • Stephan Eicher und die Automaten
Recent Comments
  • Brynjulf Blix on Midi-in Pitchbend with an Arduino
  • Nick Patel on Spotify and the native windows 7 firewall
  • jhon on Problem with network printer not printing through windows firewall
  • Luqman on M@P Group – Robot Guitar
  • Arne on External power for the Korg Monotron and the Stylophone
Imprint
Impressum
Contact

Love or hate? Get in touch!

Email: contact@sonicrobots.com

2016 © Sonic Robots - Learning