Post Go back to editing

Communication between ADg2128 and AD5940 in EVAL-CN0565-ARDZ

Category: Software
Product Number: EVAL-CN0565-ARDZ

Hi everyone, I have trouble with ADG2128. My objective is 4-wire BIA measuring in 'EVAL-CN0565-ARDZ' using Arduino Wemos D1. Specifically, after configuring AD5940 depending on this code:

(github.com/.../BodyImpedance.c)

It worked, there was a sine waveform at CE0 (capacitor C1). But I tried many ways to configure ADG2128 but it didn't work. At first, it cannot communicate to ADG2128 (I2C). I reconfigured AD5940's GPIO, and then it can (I can read the value 0x70 and 0x71 of the two ADG2128. But up to now, there has been no signal or waveform at CN0565's pins (in the picture). The full I2C Arduino code is attached below (The code for Ad5940 is in the link).


Thank you very much. I'm really grateful for that.

struct adg2128_pinmap {
  uint8_t chip_addr;  // I2C address
  uint8_t selector;   // Mux config (X input)
};

struct adg2128_pinmap board_map[ADG2128_MUX_SIZE] = {
  {0x71, 0x80}, // Electrode 0, I2C addr = 0x71, X0
  {0x71, 0x88}, // Electrode 1, I2C addr = 0x71, X1
  {0x71, 0x90}, // Electrode 2, I2C addr = 0x71, X2
  {0x71, 0x98}, // Electrode 3, I2C addr = 0x71, X3
  {0x71, 0xA0}, // Electrode 4, I2C addr = 0x71, X4
  {0x71, 0xA8}, // Electrode 5, I2C addr = 0x71, X5
  {0x71, 0xC0}, // Electrode 6, I2C addr = 0x71, X6
  {0x71, 0xC8}, // Electrode 7, I2C addr = 0x71, X7
  {0x71, 0xD0}, //Electrode x, I2C addr = 0x71, Mux Config (X8 to Yn)
	{0x71, 0xD8}, //Electrode x, I2C addr = 0x71, Mux Config (X9 to Yn)
	{0x71, 0xE0}, //Electrode x, I2C addr = 0x71, Mux Config (X10 to Yn)
	{0x71, 0xE8}, //Electrode x, I2C addr = 0x71, Mux Config (X11 to Yn)

  {0x70, 0x80}, // Electrode 8, I2C addr = 0x70, X0
  {0x70, 0x88}, // Electrode 9, I2C addr = 0x70, X1
  {0x70, 0x90}, // Electrode 10, I2C addr = 0x70, X2
  {0x70, 0x98}, // Electrode 11, I2C addr = 0x70, X3
  {0x70, 0xA0}, // Electrode 12, I2C addr = 0x70, X4
  {0x70, 0xA8}, // Electrode 13, I2C addr = 0x70, X5
  {0x70, 0xC0}, // Electrode 14, I2C addr = 0x70, X6
  {0x70, 0xC8},  // Electrode 15, I2C addr = 0x70, X7
  {0x70, 0xD0}, //Electrode x, I2C addr = 0x70, Mux Config (X8 to Yn)
	{0x70, 0xD8}, //Electrode x, I2C addr = 0x70, Mux Config (X9 to Yn)
	{0x70, 0xE0}, //Electrode x, I2C addr = 0x70, Mux Config (X10 to Yn)
	{0x70, 0xE8},  //Electrode x, I2C addr = 0x70, Mux Config (X11 to Yn)
};

// Electrode Combo Structure (4 electrodes for Y0-Y3)
struct electrode_combo {
  uint16_t y0;
  uint16_t y1;
  uint16_t y2;
  uint16_t y3;
};

void setMuxSwitch(struct electrode_combo sw, uint16_t nElCount) {
  uint8_t i2c_addr;
  uint8_t muxData[2] = {0, 0x00}; // Latch bit 0x00 (immediate update)
  uint16_t *Y = (uint16_t *)&sw;  // Access sw as array
  uint16_t curr_el;
  uint8_t i;

  // Compute electrode factor
  uint16_t el_factor = (uint16_t)ADG2128_MUX_SIZE / nElCount;
  if (el_factor != 0 && ((el_factor & (el_factor - 1)) == 0)) {

    // Configure switches for Y0-Y3
    for (i = 0; i < 4; i++) {
      if ((*(Y + i)) < ADG2128_MUX_SIZE) {
        curr_el = (*(Y + i)) * el_factor;
        i2c_addr = board_map[curr_el].chip_addr;
        muxData[0] = board_map[curr_el].selector + (i << 1); // Adjust Y output

        Wire.beginTransmission(i2c_addr);
        Wire.write(muxData[0]);
        Wire.write(muxData[1]);
        int error = Wire.endTransmission();

        if (error == 0) {
          Serial.print("ADG2128 0x"); Serial.print(i2c_addr, HEX);
          Serial.print(": Electrode "); Serial.print(curr_el);
          Serial.print(" to Y"); Serial.println(i);
        } else {
          Serial.print("I2C Error for 0x"); Serial.print(i2c_addr, HEX);
          Serial.print(": "); Serial.println(error);
        }
      }
    }
    delayMicroseconds(1); // Replace no_os_udelay
  }
}

void setup()[ // it should be '//'
  SPI.begin();
  Wire.begin();
  Wire.setClock(100000);
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(CS_PIN, OUTPUT);
  Serial.println("");
  struct electrode_combo sw = {0, 20, 15, 7};
  setMuxSwitch(sw, 24); // Use all 16 electrodes

  digitalWrite(CS_PIN, HIGH); 
  Serial.println("");
  AD5940_Main();
  ] 

Thread Notes

Parents
  • Hi  ,

    The attached image appears to contain an incorrect interpretation of the EVAL-CN0565-ADRZ P1 connector pinout.

    In the reference example code, the two ADG2128 multiplexers are accessed in the following I²C order:

    • 0x71 (second switch) is accessed first

    • 0x70 (first switch) is accessed second

    Due to this access sequence, the electrode channel mapping is effectively reversed between the two switches:

    • Channels E0–E11 are assigned to the second switch (0x71)

    • Channels E12–E23 are assigned to the first switch (0x70)

    As a result:

    • Pin 14 corresponds to E0

    • Pin 15 corresponds to E1, and so on

    To summarize:

    • Switch at 0x71 (second switch) → E0–E11P1 pins 14–25

    • Switch at 0x70 (first switch) → E12–E23P1 pins 1–13


    This reversed mapping is important to keep in mind when interpreting connector pinouts or designing electrode configurations for use with this evaluation board.

    Please let us know if you have any further questions or need assistance with your setup.

    Regards,
    Michelle

Reply
  • Hi  ,

    The attached image appears to contain an incorrect interpretation of the EVAL-CN0565-ADRZ P1 connector pinout.

    In the reference example code, the two ADG2128 multiplexers are accessed in the following I²C order:

    • 0x71 (second switch) is accessed first

    • 0x70 (first switch) is accessed second

    Due to this access sequence, the electrode channel mapping is effectively reversed between the two switches:

    • Channels E0–E11 are assigned to the second switch (0x71)

    • Channels E12–E23 are assigned to the first switch (0x70)

    As a result:

    • Pin 14 corresponds to E0

    • Pin 15 corresponds to E1, and so on

    To summarize:

    • Switch at 0x71 (second switch) → E0–E11P1 pins 14–25

    • Switch at 0x70 (first switch) → E12–E23P1 pins 1–13


    This reversed mapping is important to keep in mind when interpreting connector pinouts or designing electrode configurations for use with this evaluation board.

    Please let us know if you have any further questions or need assistance with your setup.

    Regards,
    Michelle

Children
No Data