Go Down

Topic: Arduino+PCA9547PW (Read 346 times) previous topic - next topic

siriniti

Hello! I'm trying to assemble such a system: arduino uno -> PCA9547PW-> 8 accelerometer's LIS331dlh. When using the multiplexer PCA9547PW, the binding in accordance with the datasheet (SCL, SDA, RST via pull-up resistors 10k per power; SCL, SDA of each channel, respectively, pulled up to power. + And - power hung the capacitor 220nF). I encountered a problem: when using the library of arduino wire.h and its standard procedures, reading is always only from a sensor connected to the null channel. Displaying information from other channels on the monitor causes the program to freeze (because they are simply not initialized). What could be the problem? Are there any liifhaks for the optimal hardware connection of the multiplexer? Has anyone encountered a similar situation? Maybe someone has a working example for arduino?

Code: [Select]

#include <Wire.h>
#include <troyka-imu.h>
#include <lis331dlh.h>

#define MUX         0xE4  //Multiplexer Address

LIS331DLH_TWI accel_1(0x18);
LIS331DLH_TWI accel_2(0x18);

void setup()
{
 
  Wire.begin();
  Serial.begin(9600);
   Serial.println("Begin init...");
      mux(0);
   accel_1.begin();
      mux(5);
   accel_2.begin();
}

void loop()
{
   mux(0);
    Serial.print("Accelerometer 1");
    Serial.println("");
    Serial.print(accel_1.readGX());
    Serial.print("\t\t");
    Serial.print(accel_1.readGY());
    Serial.print("\t\t");
    Serial.print(accel_1.readGZ());
    Serial.print("\t\t");
    Serial.println("");
    mux(5);
    Wire.requestFrom(0xE5,1);
    while(Wire.available())
    {
    char c = Wire.read();
    Serial.print(c);
    }

    Serial.print("Accelerometer 2");
      Serial.println("");
    Serial.print(accel_2.readGX());
    Serial.print("\t\t");
    Serial.print(accel_2.readGY());
    Serial.print("\t\t");
    Serial.print(accel_2.readGZ());
    Serial.print("\t\t");
    Serial.println("");

   delay(1000);
 
}

void mux(byte channel)
{
  Wire.beginTransmission(MUX);
  Wire.write(channel);     //set to selected channel
  Wire.endTransmission();
}

Go Up