I2c on patch.init with daisyduino

I am currently experimenting with i2c communication on the patch.init module. My goal is to have a polyphonic synth which can be controlled via i2c similar to just friends being controlled by the monome crow module.

But i struggle to make the communication work.

My current test setup are two Adafruit QT Pys connected via i2c to establish valid i2c communication with typical Arduino examples. As pullups I use 10k resistors. Once I had this setup working I planed to replace the i2c receiver with the patch.init.

  1. I identified B7 and B8 (as labeled here datasheet) as SCL and SDA
  2. I soldered jumper wires to the interface PCB (front) and ensured that no shorts are present and that both button and switch are not connected to GND (default for button and down position for the switch)
  3. I replaced the receiving QT Py with the patch.init module
  4. communication did not work
  5. I added setSCL and setSDA as proposed here, but was unsure which pin naming convention to use
  6. I looked up the pin defines on github and realized that there is an “inconsistency” between the pin labeling in the datasheet and here
    DaisyDuino/daisy_patch_sm.h at eb2964f5a970115ffc33ffd568a78c1743562ee7 · electro-smith/DaisyDuino · GitHub
#define PIN_PATCH_SM_I2C_SCL PB8
#define PIN_PATCH_SM_I2C_SDA PB9

the code I used on the patch.init, should shortly flash the front panel LED to indicate received i2c communication. On start up it shortly flashes to indicate that the code is working so far. The code is as follows:


#include <elapsedMillis.h>
#include "DaisyDuino.h"


DaisyHardware patch;

elapsedMillis t;
bool state;

void AudioCallback(float **in, float **out, size_t size) {
}

/** Start here */
void setup() {
  /** Initialize the patch_sm hardware object */
  patch = DAISY.init(DAISY_PATCH_SM);

  Serial.begin(9600);

  Wire.setSCL(PIN_PATCH_SM_I2C_SCL);
  Wire.setSDA(PIN_PATCH_SM_I2C_SDA);
  Wire.begin(4);
  Wire.onReceive(receiveEvent);

  /** Start Processing the audio */
  //DAISY.begin(AudioCallback);

  patch.WriteCvOut(PIN_PATCH_SM_CV_OUT_2, 2.5);
  t = 0;
  state = true;
}

/** Loop forever */
void loop() {
  //patch.ProcessAllControls();
  if (t>500 && state) {
    state = false;
    patch.WriteCvOut(PIN_PATCH_SM_CV_OUT_2, 0);  
  }
}

void receiveEvent (int howMany) {
  Serial.println("!");
  
  while(0 < Wire.available()) // loop through all but the last
  {
    char c = Wire.read(); // receive byte as a character
    //Serial.print(c);         // print the character
  }

  t = 0;
  state = true;
  patch.WriteCvOut(PIN_PATCH_SM_CV_OUT_2, 2.5);
}

I would highly appreciate advice on how to solve this issue and would appreciate some example code. I know that the current solution is not optimal since the button and switch are not disabled, but I would love to create my own control hardware for which the i2c pins are reserved exclusively for communication and until then this is a prototyping setup.

  1. It looks like the perceived inconsistency is not actually a problem. PB8 and PB9 are the STM32 names for those pins. The Patch SM names for them are B7 and B8. So B7 = PB8 = SDA, and B8 = PB9 = SCL. Confusing, I know!

  2. Do you have pullup resistors on both I2C lines? You might try setting pinMode(PIN_PATCH_SM_I2C_SCL, INPUT_PULLUP); on both SDA and SCL.

Other than that your code looks good to me.
Let me know if that doesn’t work, we can troubleshoot some more ideas!

1 Like