I am trying to read data from a Relative Humidity/Temperature sensor and I keep getting error C1086 on line 53 " tempC = 175*tempx / 65535 - 45" when I am using this code on a Labjack U6 running numerous sequences for various processes. This error does not occur when I run it on an isolated Labjack with only sensor attached. I have checked all of my pin connections and there is nothing else running off of these pins, so there shouldn't be any conflicts. Can you point me in the right direction for troubleshooting this error, is there something wrong with my code or is there a conflict with this code and another sequence that I need to look into. I have attached the code below.
// Set the I2C address
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chI2C_ADDRESS_BYTE,136,0,0)
// SCL to CIO0
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chI2C_SCL_PIN_NUM,16,0,0)
// SDA to CIO2
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chI2C_SDA_PIN_NUM,18,0,0)
// Default (0) I2C options
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chI2C_OPTIONS,0,0,0)
//MISO is FIO3 conflict and not used? So commented out
//AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chSPI_MISO_PIN_NUM,3,0,0)
//CLK is CIO0
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chSPI_CLK_PIN_NUM,16,0,0)
//CS is CIO2
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chSPI_CS_PIN_NUM,18,0,0)
//Execute the requests on a single LabJack.
GoOne(ID)
ErrorHandler(ID)
This part above is done in a separate sequence but I included it as I think it may be related to the issue
// initialize the variables
private numWriteBytes=2
private writeArray
writeArray[0] = 36
writeArray[1] = 0
private dataArray
private numreadBytes = 6
private tempx
private tempC
private rh
while(1)
//Transfer the data (single shot acquisition command)
ePut(ID, LJ_ioI2C_COMMUNICATION, LJ_chI2C_WRITE, numWriteBytes, @writeArray)
ErrorHandler(ID)
// Wait 20ms for the acquisition time
delay(0.02)
dataArray[0] = 0
dataArray[1] = 0
dataArray[2] = 0
dataArray[3] = 0
dataArray[4] = 0
dataArray[5] = 0
// Read the returned data
eGet(ID, LJ_ioI2C_COMMUNICATION, LJ_chI2C_READ, numReadBytes, @dataArray)
ErrorHandler(ID)
// Convert the raw bytes to actual readings
tempx = dataArray[0]*256 + dataArray[1]
tempC = 175*tempx / 65535 - 45
rh = dataArray[3]*256 + dataArray[4]
rh = 100*rh / 65535
// print the read to the command / alert window. Of course you'll probably do something a bit more exciting with the data
temperature.AddValue(tempC)
humidity.AddValue(rh)
?Format("temperature=%0.4fC\nrh=%0.4f\n", tempC, rh)
delay(0.5)
endwhile