chrisp Posted January 7, 2019 Share Posted January 7, 2019 I am trying to interface with a STM microcontroller via Labjack, I know the I2C works due to testing with an Aardvark. However when I try to send data over the Labjack I am unable to send the data payload. There must be something wrong with my code, but browsing the limited docuemntatyion on the matter yielded little fruit. Any help would be apprictated. Thanks! My Code: using("device.labjack.") try include("c:\program files (x86)\labjack\drivers\labjackud.h") catch() include("c:\program files\labjack\drivers\labjackud.h") endcatch global ID = 0 ePut(ID, LJ_ioPIN_CONFIGURATION_RESET, 0, 0, 0) AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chI2C_ADDRESS_BYTE, 0x62, 0, 0) AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chI2C_SCL_PIN_NUM, 0, 0, 0) AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chI2C_SDA_PIN_NUM, 1, 0, 0) AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chI2C_OPTIONS, 1, 0, 0) AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chI2C_SPEED_ADJUST, 0, 0, 0) GoOne(ID) numWrite = 2 array[0] = 0x07 array[1] = 0xd0 AddRequest(ID, LJ_ioI2C_COMMUNICATION, LJ_chI2C_WRITE, numWrite, array, 0) AddRequest(ID, LJ_ioI2C_COMMUNICATION, LJ_chI2C_GET_ACKS, 0, 0, 0) GoOne(ID) Scopeshot of the resulting transaction Link to comment Share on other sites More sharing options...
LabJackSupport Posted January 14, 2019 Share Posted January 14, 2019 It looks like your device isn't receiving an "ACK" from your I2C slave sensor so the I2C packet is failing. Can you double check the slave address and make sure that you have pull-up resistors installed? In our I2C app-note we recommend 4.7k resistors. If you haven't already tried switching to the EIO0 and EIO1 ports, please do that as well. Link to comment Share on other sites More sharing options...
LabJackSupport Posted January 15, 2019 Share Posted January 15, 2019 We discussed this issue today as a group and noticed one other potential issue. It doesn't look like you properly define your "numWrite" or "array" variables. There is a chance that you could be instructing DAQFactory to write no bytes to the device instead of two. You can easily test this by modifying the line: AddRequest(ID, LJ_ioI2C_COMMUNICATION, LJ_chI2C_WRITE, numWrite, array, 0) to be: AddRequest(ID, LJ_ioI2C_COMMUNICATION, LJ_chI2C_WRITE, 2, array, 0) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.