Incalcando has been collaborating with Instruō on a Eurorack module for wireless OSC to CV conversion.
The module was presented as part of the Modular Meets Leeds 2017 and has received widespread interest.
Watch the conversation between Jason Lim (Instruō) and Ben Wilson (DivKit) about this new module and how it enables to bring Parat+ unique and intuitive control features into the modular synth setup.
The previous post featured a code for the LSM9DSO0 accelerometer in combination with the Huzzah ESP8266. Since the LSM9DSO0 is not produced anymore, here is an alternative: Using the MPU-6050 acceleration and gyroscope sensor. Thanks for Jennifer Sykes for suggesting this alternative and assembling and testing the code.
When setting the Target IP in the ESP code to the network settings of Parat+, moving, tilting and rotating the sensor will send the sensor reading as OSC bundles (i.e. packages of separate OSC messages) to Parat+. These will appear as Source Faders:
/esp/accelX /esp/accelY /esp/accelZ
/esp/gyroX /esp/gyroY /esp/gyroZ
Use the range learn functions of the Parat+ Source faders to calibrate the data streams to the movements you wish to use.
Connect the ‘Value controlled by Source’ in the Fader Edit view of any Parat+ Fader to have that OSC and MIDI controller controlled by your sensor.
/////////////////////// // MPU6050 Setup // /////////////////////// // class default I2C address is 0x68 // specific I2C addresses may be passed as a parameter here // AD0 low = 0x68 (default for InvenSense evaluation board) // AD0 high = 0x69 MPU6050 accelgyro; //MPU6050 accelgyro(0x69); // <– use for AD0 high // uncomment “OUTPUT_READABLE_ACCELGYRO” if you want to see a tab-separated // list of the accel X/Y/Z and then gyro X/Y/Z values in decimal. Easy to read, // not so easy to parse, and slow(er) over UART. #define OUTPUT_READABLE_ACCELGYRO
// uncomment “OUTPUT_BINARY_ACCELGYRO” to send all 6 axes of data as 16-bit // binary, one right after the other. This is very fast (as fast as possible // without compression or data loss), and easy to parse, but impossible to read // for a human. //#define OUTPUT_BINARY_ACCELGYRO int16_t ax, ay, az; int16_t gx, gy, gz;
// A UDP instance to let us send and receive packets over UDP WiFiUDP Udp; //const IPAddress outIp(192, 168, 1, 95); const IPAddress outIp(192, 168, 0, 101); const unsigned int outPort = 10101;
void sendBundleViaOSC();
void getGyro(); void getAccel();
void setup() {
pinMode(0, OUTPUT); digitalWrite(0, HIGH); pinMode(2, OUTPUT); digitalWrite(2, HIGH); // join I2C bus (I2Cdev library doesn’t do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(4, 5); #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif // initialize serial communication // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but // it’s really up to you depending on your project) Serial.begin(38400);
Udp.beginPacket(outIp, outPort); bndl.send(Udp); // send the bytes to the SLIP stream Udp.endPacket(); // mark the end of the OSC Packet bndl.empty(); // empty the bundle to free room for a new one
This post describes the assembly of a wireless sensor transmitter suitable for music and art performance and installation setups. It has been very reliable for performance. At the time of writing I had to learn that the sensor used here (LSM9DS0 with i2c) is not produced anymore. I will update this post in the near future with a more up-to-date sensor breakout board.
Used Parts:
Huzzah ESP8266 – https://www.adafruit.com/product/2471 *| 9 Degrees of Freedom IMU Breakout – LSM9DS0 – https://www.sparkfun.com/products/retired/1263 but supplied code can be easily updated for the Adafruit 9-DOF Accel/Mag/Gyro+Temp Breakout Board – LSM9DS1LiPo charger and 3.7 1000mAh LiPo battery.
The LSM9DS0 sensor uses the I2C protocol. It is very straight forward to connect the sensor breakout board and the Huzzah ESP.
The sensor breakout board needs to be powered, so connect Gnd and +3.3V between the two circuits. The digital I2C communication uses two wires, the Data line SDA and a Clock line (SCL).
Below is the Arduino Code that will read the sensor data, format and send the readings as OSC bundles.
Ensure you are setting the Arduino IDE to the Huzzah ESP8266 Board (you might need to add this board in the Arduino Board manager, please see Adafruit overview/tutorials for more info.)
In the code, make sure you are setting the SSID name and password of the network you want to use.
Also ensure that the Wire.begin() contains the pin numbers of the SDA and SCL. Here it is 4 and 5.
/////////////////////// // LSM9DS0 I2C Setup // /////////////////////// // Comment out this section if you’re using SPI // SDO_XM and SDO_G are both grounded, so our addresses are: #define LSM9DS0_XM 0x1D // Would be 0x1E if SDO_XM is LOW #define LSM9DS0_G 0x6B // Would be 0x6A if SDO_G is LOW // Create an instance of the LSM9DS0 library called `dof` the // parameters for this constructor are: // [SPI or I2C Mode declaration],[gyro I2C address],[xm I2C add.] LSM9DS0 dof(MODE_I2C, LSM9DS0_G, LSM9DS0_XM); long sendCount = 0; long frameCount = 0; //const char* ssid = “BTHub3-PQ5N”; //const char* password = “78cbae358d”; const char* ssid = “piano+”; const char* password = “bbbbbbbb”;
// A UDP instance to let us send and receive packets over UDP WiFiUDP Udp; //const IPAddress outIp(192, 168, 1, 95); const IPAddress outIp(192, 168, 5, 111); const unsigned int outPort = 10101; float aX = 0.0f; float aY = 0.0f; float aZ = 0.0f;
// Use the begin() function to initialize the LSM9DS0 library. // You can either call it with no parameters (the easy way): uint16_t status = dof.begin(); // Or call it with declarations for sensor scales and data rates: //uint16_t status = dof.begin(dof.G_SCALE_2000DPS, // dof.A_SCALE_6G, dof.M_SCALE_2GS); // Set output data rates // Accelerometer output data rate (ODR) can be: A_ODR_3125 (3.225 Hz), A_ODR_625 (6.25 Hz), A_ODR_125 (12.5 Hz), A_ODR_25, A_ODR_50, // A_ODR_100, A_ODR_200, A_ODR_400, A_ODR_800, A_ODR_1600 (1600 Hz) dof.setAccelODR(dof.A_ODR_100); // Set accelerometer update rate at 100 Hz // Accelerometer anti-aliasing filter rate can be 50, 194, 362, or 763 Hz // Anti-aliasing acts like a low-pass filter allowing oversampling of accelerometer and rejection of high-frequency spurious noise. // Strategy here is to effectively oversample accelerometer at 100 Hz and use a 50 Hz anti-aliasing (low-pass) filter frequency // to get a smooth ~150 Hz filter update rate dof.setAccelABW(dof.A_ABW_50); // Choose lowest filter setting for low noise // Gyro output data rates can be: 95 Hz (bandwidth 12.5 or 25 Hz), 190 Hz (bandwidth 12.5, 25, 50, or 70 Hz) // 380 Hz (bandwidth 20, 25, 50, 100 Hz), or 760 Hz (bandwidth 30, 35, 50, 100 Hz) dof.setGyroODR(dof.G_ODR_95_BW_125); // Set gyro update rate to 190 Hz with the smallest bandwidth for low noise
// Magnetometer output data rate can be: 3.125 (ODR_3125), 6.25 (ODR_625), 12.5 (ODR_125), 25, 50, or 100 Hz dof.setMagODR(dof.M_ODR_100); // Set magnetometer to update every 80 ms // begin() returns a 16-bit value which includes both the gyro // and accelerometers WHO_AM_I response. You can check this to // make sure communication was successful.
Serial.print(“LSM9DS0 WHO_AM_I’s returned: 0x”); Serial.println(status, HEX); Serial.println(“Should be 0x49D4”); Serial.println();
// Connect to WiFi network Serial.println(); Serial.println(); Serial.print(“Connecting to “); Serial.println(ssid);
void sendBundleViaOSC() { OSCBundle bndl; bndl.add(“/esp/magX”).add(mX); bndl.add(“/esp/magY”).add(mY); bndl.add(“/esp/magZ”).add(mZ); bndl.add(“/esp/accelX”).add(aX); bndl.add(“/esp/accelY”).add(aY); bndl.add(“/esp/accelZ”).add(aZ); bndl.add(“/esp/gyroX”).add(gX); bndl.add(“/esp/gyroY”).add(gY); bndl.add(“/esp/gyroZ”).add(gZ); Udp.beginPacket(outIp, outPort); bndl.send(Udp); // send the bytes to the SLIP stream Udp.endPacket(); // mark the end of the OSC Packet bndl.empty(); // empty the bundle to free room for a new one
// Serial.println(mX); }
void getMag() { // To read from the magnetometer, you must first call the // readMag() function. When this exits, it’ll update the // mx, my, and mz variables with the most current data. dof.readMag();
// Now we can use the mx, my, and mz variables as we please. // Either print them as raw ADC values, or calculated in Gauss. mX = dof.calcMag(dof.mx); mY = dof.calcMag(dof.my); mZ = dof.calcMag(dof.mz); }
void getGyro() { // To read from the gyroscope, you must first call the // readGyro() function. When this exits, it’ll update the // gx, gy, and gz variables with the most current data. dof.readGyro(); gX = dof.calcGyro(dof.gx); gY = dof.calcGyro(dof.gy); gZ = dof.calcGyro(dof.gz);
}
void getAccel() { // To read from the accelerometer, you must first call the // readAccel() function. When this exits, it’ll update the // ax, ay, and az variables with the most current data. dof.readAccel();
// If you want to print calculated values, you can use the // calcAccel helper function to convert a raw ADC value to // g’s. Give the function the value that you want to convert. aX = dof.calcAccel(dof.ax); aY = dof.calcAccel(dof.ay); aZ = dof.calcAccel(dof.az);
Simple steps to link Parat+ to Max patches. Intuitive control and Gesture recorder to automate any of the mapped parameters promises great performances.
06.01.2017: Open Waters Festival @ The Sir James Dunn Theatre Halifax, Nova Scotia, Canada Brandon Auger (analog synthesizer), John DS Adams (analog interconnections) & Sebastian Lexer (piano+)