LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire data from 8 sensors using I2C switch PCA9548

Good morning.

 

I’m trying to acquire data from 8 digital 3-axis magnetometers HMC4848, having an I2C digital interface. I’m using the NI USB-8451 data acquisition card and the 8-channel I2C-bus switch PCA9548A from NXP.

 

The PCA9548A.vi file that I attached (in Eight_magnetometers.zip) gives no errors, but I acquire constantly 0 from each axis of the magnetic sensor. Note that at the moment I’m just trying to acquire data from a single channel (namely the channel 0).

 

I use 10k pull-up resistor, connected between Vdd and SDA, SCL, RESET pins of the PCA9548A.

 

I also attached Single_magnetometer.zip that contains the HMC5843.vi file that I previously used to acquire data from a single sensor and which works properly.

 

Any suggestion is welcome.

 

Thanks in advance.

Dr. Caligari

Download All
0 Kudos
Message 1 of 6
(5,437 Views)

In the Eight_magnetometers example I don't see you changing the slave address when you want to talk to the HMC5843.

 

Other comments:

  • Your sequence frames are unnecessary. The error I/O wire forces an execution dependency. You can use the Time Delay function to insert a wait between VIs, as that has error I/O clusters. 
  • You should not create a new 8451 session in each iteration of the loop. Initialize before the loop, communicate inside, and close outside the loop after you're done.
  • Your "2's complement" VI can be simplified using numeric operations. See attached.
0 Kudos
Message 2 of 6
(5,392 Views)

Hi smercurio_fc.

 

Thanks for your answer.

 

I will try to fix these problems on Monday and I will keep you informed.

 

Best regards.

Dr. Caligari

0 Kudos
Message 3 of 6
(5,381 Views)

Good morning smercurio_fc.

 

I modified the code following your suggestions, but I’m still not able to acquire data from the sensors.

 

Actually, the problem is that I’m not sure about how to address the magnetometer when the PCA9848 has already been addressed.

 

In the example that I attached I added a second property node, with the address of the HMC5843 (namely 1E), but when I try to run the code I receive the following error message:

 

Error -301742 occurred at NI-845x I2C Write.vi:2

 

Possible reason(s):

NI-845x:  The slave did not acknowledge an address+direction byte transmitted by the I2C master. Reasons include the incorrect address set in the I2C configuration or the incorrect use of the 7-bit address. When entering an address to access a 7-bit device, do not include the direction bit. The NI-845x Basic I2C API internally sets the direction bit to the correct value, depending on the function (write or read). If your datasheet specfies the 7-bit device address as a byte, discard the direction bit (bit 0) and right-shift the byte value by one to create the 7-bit address.

 

The issue is – I guess – that I’m sending two different I2C address on the same bus and this result in an address conflict.

 

Could you please help me to understand how I could solve it?

 

Thanks again and best regards.

Dr. Caligari

 

P.S. I also attached the code for the single magnetometer modified.

0 Kudos
Message 4 of 6
(5,351 Views)

Hi Dr. Caligari,

 

This is Zhenyi, now i am doing my final year project using the USB 8451 to extract the data from the smart batteries through   PCA9548, I have also encountered the same problem with you. Beacuse it is very very urgent for me, then if you have fixed  out this problem, can you share it with me. Thanks very very much!!!

 

 

Best regards,

Zhenyi 

0 Kudos
Message 5 of 6
(4,965 Views)

Hi to all,

 

ihave an equal problem. I'm trying to connect several slaves (up to 10 sensors) with the usb-8451. The problem is that the slaves have an equal addresse.

My questions are:

- is there a need on the external Pull-Ups to connect them all to SDA, SCL lines?

- is it necessary to use some kind of switch (like PCA9548) when the slaves have the same addresse?

 

Best regards,

Andy

0 Kudos
Message 6 of 6
(4,920 Views)