Tuesday, November 29, 2016

MIDI-Controlled 12-Bit Octo DAC







Download the code here: http://milkcrate.com.au/_other/downloads/arduino/MCP4922_OCT_DAC_MIDI/



Walls of Wollongong



















Wednesday, November 23, 2016

Ableton Link Comes to Cycling 74 Max

Available now in the Max Package Manager. The Link Package allows for synchronisation between apps and over networks between apps that support Ableton Link. Great stuff!



Tuesday, November 22, 2016

MIDI CC: High Res and Standard Res Single, Dual Quad and Oct Dials for Max for Live











Standard Data Range:

High Resolution: 

Monday, November 21, 2016

Moog Mother-32: MIDI to Quad DAC CV Control




An example of using two MCP4922 that are controlled via MIDI. The four DAC channels are used to control filter frequency, filter resonance, LFO frequency and VCA modulation. 

In Ableton Live, four LFO generators are used to send MIDI continuous controller data out to the Teensy, which in turn then uses the data to set the DAC voltage level of the MCP4922 chips via the SPI bus.

Multiple MIDI-Controlled 12-Bit DACs via Teensy / Arduino

Overview
The MCP4922 is a 12-bit, two channel, SPI-based DAC - and can be easily connect to a studio setup using a Teensy via MIDI!This is an easy way of adding a 0 - 5V or 0 - 3.3V 4096-step DAC to a MIDI sequencing environment. Using one Teensy, multiple MCP4922 chips can be easily controlled, and mapped via MIDI data.

The cost of these chips is relatively low - around AUD$3 per chip or $1.50 per DAC channel - and they don't require any additional components for basic implementation. 



Hardware
Hardware connection is very similar to the previous post on the MCP4922. To connect multiple MCP4922 to a Teensy microcontroller, the following connections should be made:

  • Teensy 5V or 3.3V (depending on model) to MCP4922 VDD (Pin 1) - all MCP4922 have this connection in common
  • Teensy SPI Chip Select pin (user-designated) to MCP4922 CS (Pin 3) - each individual MCP4922 chip has a corresponding pin on the Teensy microcontroller. In this example, I am using digital pin 4 for the CS pin of MCP4922 #1 and then digital pin 5 for the CS pin of MCP4922 #2. 
  • Teensy SPI Serial Clock pin (as defined in the SPI library) to MCP4922 SCK (Pin 4) - all MCP4922 have this connection in common
  • Teensy SPI Digital Out (as defined in the SPI library) to MCP4922 SDI (Pin 5) - all MCP4922 have this connection in common
  • Teensy 5V or 3.3V (depending on model) to MCP4922 V REF A (Pin 13) - all MCP4922 have this connection in common
  • Teensy ground to MCP4922 VSS (Pin 12) - all MCP4922 have this connection in common
  • Teensy 5V or 3.3V (depending on model)to MCP4922 V REF B (Pin 11) - all MCP4922 have this connection in common
  • Teensy 5V or 3.3V (depending on model) to MCP4922 SHDN - all MCP4922 have this connection in common
  • Teensy ground to MCP4922 LDAC - all MCP4922 have this connection in common
  • MCP4922 V OUT A (Pin 14) is the output for DAC A - all MCP4922 have this connection in common
  • MCP4922 V OUT B (Pin 10) is the output for DACB - all MCP4922 have this connection in common
Almost all connections are duplicated for each MCP4922 - with the exception of the CS (Chip Select) pin, which requires a unique digital pin on the Teensy for each MCP4922.

This way, only a particular MCP4922 is selected when data is written to the SPI bus.





Software
The SPI library can be used to easily write data to the DAC. In the example below,  a function is written that has a chip select pin value, a DAC channel value and a DAC output value between 0 - 4095. This function writes to the SPI bus and updates the DAC output.

This function is then connected to MIDI via MIDI control messages.

This particular sketch supports both high res MIDI and normal res MIDI. The controller number that is used determines the DAC channel number as well as the MCP4922 chip.

In this example, the mapping is as follows:
  • CC 0 paired with CC 32 will send a high resolution value to MCP4922 chip 1 DAC 0
  • CC 1 paired with CC 33 will send a high resolution value to MCP4922 chip 1 DAC 1
  • CC 2 paired with CC 34 will send a high resolution value to MCP4922 chip 2 DAC 0
  • CC 3 paired with CC 35 will send a high resolution value to MCP4922 chip 2 DAC 1
  • CC 64 will send a normal resolution value to MCP4922 chip 1 DAC 0
  • CC 65 will send a normal resolution value to MCP4922 chip 1 DAC1
  • CC 66 will send a normal resolution value to MCP4922 chip 2 DAC 0
  • CC 67 will send a normal resolution value to MCP4922 chip 2 DAC 1
The mapping is arbitrary, to some degree - so adjust as desired.

Download here: http://milkcrate.com.au/_other/downloads/arduino/MCP4922_DAC_MULTI_MIDI/





MIDI-controlled 12-bit DAC

Overview
The MCP4922 is a 12-bit, two channel, SPI-based DAC - and can be easily connect to a studio setup using a Teensy via MIDI!This is an easy way of adding a 0 - 5V or 0 - 3.3V 4096-step DAC to a MIDI sequencing environment.

The cost of these chips is relatively low - around AUD$3 per chip or $1.50 per DAC channel - and they don't require any additional components for basic implementation.  



Hardware
Hardware connection is identical to the previous post on the MCP4922. To connect the MCP4922 to a Teensy microcontroller, the following connections should be made:

  • Teensy 5V or 3.3V (depending on model) to MCP4922 VDD (Pin 1)
  • Teensy SPI Chip Select pin (either user-designated or as defined in the SPI library) to MCP4922 CS (Pin 3)
  • Teensy SPI Serial Clock pin (as defined in the SPI library) to MCP4922 SCK (Pin 4)
  • Teensy SPI Digital Out (as defined in the SPI library) to MCP4922 SDI (Pin 5)
  • Teensy 5V or 3.3V (depending on model) to MCP4922 V REF A (Pin 13)
  • Teensy ground to MCP4922 VSS (Pin 12)
  • Teensy 5V or 3.3V (depending on model)to MCP4922 V REF B (Pin 11)
  • Teensy 5V or 3.3V (depending on model) to MCP4922 SHDN
  • Teensy ground to MCP4922 LDAC
  • MCP4922 V OUT A (Pin 14) is the output for DAC A
  • MCP4922 V OUT B (Pin 10) is the output for DACB





Software
The SPI library can be used to easily write data to the DAC. In the example below,  a function is written that has a chip select pin value, a DAC channel value and a DAC output value between 0 - 4095. This function writes to the SPI bus and updates the DAC output.

This function is then connected to MIDI via MIDI control messages.

This particular sketch supports both high res MIDI and normal res MIDI. 

Download here: http://milkcrate.com.au/_other/downloads/arduino/MCP4922_DAC_MIDI/





Teensy and MCP4922 Dual Channel 12-Bit DAC

Overview
The MCP4922 is a 12-bit, two channel, SPI-based DAC. As microcontrollers do not often have many DAC outputs (and are often limited to PWM outputs), cheap external DACs are a great way of increasing the analog output options of a microcontroller such as the Teensy.

The cost of these chips is relatively low - around AUD$3 per chip or $1.50 per DAC channel - and they don't require any additional components for basic implementation. 


Hardware
To connect the MCP4922 to a Teensy microcontroller, the following connections should be made:

  • Teensy 5V or 3.3V (depending on model) to MCP4922 VDD (Pin 1)
  • Teensy SPI Chip Select pin (either user-designated or as defined in the SPI library) to MCP4922 CS (Pin 3)
  • Teensy SPI Serial Clock pin (as defined in the SPI library) to MCP4922 SCK (Pin 4)
  • Teensy SPI Digital Out (as defined in the SPI library) to MCP4922 SDI (Pin 5)
  • Teensy 5V or 3.3V (depending on model) to MCP4922 V REF A (Pin 13)
  • Teensy ground to MCP4922 VSS (Pin 12)
  • Teensy 5V or 3.3V (depending on model)to MCP4922 V REF B (Pin 11)
  • Teensy 5V or 3.3V (depending on model) to MCP4922 SHDN
  • Teensy ground to MCP4922 LDAC
  • MCP4922 V OUT A (Pin 14) is the output for DAC A
  • MCP4922 V OUT B (Pin 10) is the output for DACB





Software
The SPI library can be used to easily write data to the DAC. In the example below,  a function is written that has a chip select pin value, a DAC channel value and a DAC output value between 0 - 4095. This function writes to the SPI bus and updates the DAC output.

Download here: http://milkcrate.com.au/_other/downloads/arduino/MCP4922_DAC/




Sunday, November 20, 2016

Moog Mother-32 CV Input Controlled via Teensy 3.5 Onboard DAC

The Teensy 3.5 DAC can be used to control the CV inputs on the Moog Mother-32. Although the voltage rang is not as large as to cover the entire range, it is still definitely workable.

Connection is simple - Teensy 3.5 DAC 0 or DAC 1 out to tip, ground to sleeve.

Even MIDI control numbers 0 - 30 control DAC 0. Odd MIDI controller numbers 1 - 31 control DAC 1. High resolution is supported.

The DAC is 12-bit, so the high resolution MIDI range of 0 - 16383 is scaled to 0 - 4095.


Download the code here: http://milkcrate.com.au/_other/downloads/arduino/High_Res_MIDI_AnalogWrite.ino










Sending High Resolution MIDI Data from Ableton Live via Max for Live







A basic Max for Live patch that sends high resolution MIDI data via pairs of controller messages. Four parameters per device.

Download here: http://milkcrate.com.au/_other/downloads/M4L/little-scale.High.Resolution.CC.amxd

Receiving High Resolution MIDI Control Data using Teensy

High resolution MIDI control data can be sent from one device to another by combining two, standard MIDI continuous control messages - giving 14 bits of resolution (16384 values) as opposed to just 7 (128 values).

The high seven bits are sent first via a MIDI control message using controller 0 - 31. The low seven bits are sent second via a MIDI control message using controller 32 - 63. Thus, each channel can send up to 32 different pairs of high resolution.

To receive this data using a Teensy and the relevant USB MIDI functions, it's simply a matter of reversing this process to reconstruct the data values.

In this example, a two-dimensional array holds the high byte values in preparation for the low values. Values are reconstructed, and then printed to the serial port for viewing on the Serial Monitor. A basic Max patch is used to send high resolution MIDI data.





Download here: http://milkcrate.com.au/_other/downloads/arduino/High_Res_MIDI_Receive.ino