~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ Sequence.Init_I2C_IOW, Priority: 1 global IOWHandle private res private bufferIn private bufferOut extern("C:\DAQFactory\iowkit.dll","DWORD IowKitOpenDevice()","IowKitOpenDevice","stdcall") extern("C:\DAQFactory\iowkit.dll","ULONG IowKitWrite(DWORD, ULONG ,byte[256], ULONG)","IowKitWrite","stdcall") extern("C:\DAQFactory\iowkit.dll","byte IowKitSetTimeout(DWORD, ULONG )","IowKitSetTimeout","stdcall") extern("C:\DAQFactory\iowkit.dll","ULONG IowKitRead(DWORD, ULONG,byte[256], ULONG)","IowKitRead","stdcall") extern("C:\DAQFactory\iowkit.dll","void IowKitCloseDevice(DWORD)","IowKitCloseDevice","stdcall") IOWHandle=IowKitOpenDevice() res=IowKitSetTimeout(IOWHandle,1000) ?res bufferOut[0]=0x40 bufferOut[1]=0xF1 ?bufferOut[0] res=IowKitWrite(IOWHandle, ,@bufferOut, 2) ?res ?bufferOut res=IowKitRead(IOWHandle, 0 ,@bufferIn, 4) ?res ?bufferIn IowKitCloseDevice(IOWHandle) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ Sequence.Init_I2C_T7, Priority: 5 - Acquisition Private datain = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} Private Ack Private send={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} device.LabJackM.LJM_eWriteName("ANY","I2C_SDA_DIONUM",0) device.LabJackM.LJM_eWriteName("ANY","I2C_SCL_DIONUM",1) device.LabJackM.LJM_eWriteName("ANY","I2C_SPEED_THROTTLE",65516) device.LabJackM.LJM_eWriteName("ANY","I2C_OPTIONS",0) device.LabJackM.LJM_eWriteName("ANY","I2C_SLAVE_ADDRESS",0x60) send[0]=1//pointer sur pressure device.LabJackM.LJM_eWriteName("ANY","I2C_NUM_BYTES_TX",16) device.LabJackM.LJM_eWriteName("ANY","I2C_NUM_BYTES_RX",4) device.LabJackM.LJM_eWriteNameArray("ANY","I2C_DATA_TX",16,send) device.LabJackM.LJM_eWriteName("ANY","I2C_GO",1) Ack = device.LabJackM.LJM_eReadName("ANY","I2C_ACKS") ?"ack aprés ecriture"+Ack ?send // lit la valeur sur le senseur datain = device.LabJackM.LJM_eReadNameArray("ANY","I2C_DATA_RX") Ack = device.LabJackM.LJM_eReadName("ANY","I2C_ACKS") ?"ack aprés lecture"+Ack ?datain //Ack = device.LabJackM.LJM_eReadName("ANY","I2C_ACKS") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ Sequence.StartUp, Priority: 5 - Acquisition // This sequence is set to "Auto-Start" above, so it will run // when this CTL is first loaded. It does not have any loops, // so will quickly run and then be done. If you make changes, // click "Apply" above and then right-click on the sequence // name in the Workspace pane and select "Begin Sequence" so // that it runs again. //Allow supported calls to the LabJack LJM library. using("device.labjackm") // We'll use a global variable for the identifier so that // for all script code we only have to set it here if a // change is needed. This does not affect the D# used in the // DF "Channels" list (which is also the identifier for LJM), // so those need to be changed manually in that list if needed. global string identifier = "any" // Set AIN0-AIN3 ranges to +/-10V, +/-10V, +/-1V, and +/-0.1V. LJM_eWriteName(identifier, "AIN0_RANGE", 10) LJM_eWriteName(identifier, "AIN1_RANGE", 10) LJM_eWriteName(identifier, "AIN2_RANGE", 1) LJM_eWriteName(identifier, "AIN3_RANGE", 0.1) // At this time DF supports eWriteName() and eReadName(), along // with stream functions shown in a different example. // // LJM_eWriteName(string identifier, string Name, double Value) // http://labjack.com/support/ljm/users-guide/function-reference/ljmewritename // // double Value = LJM_eReadName(string identifier, string Name) // http://labjack.com/support/ljm/users-guide/function-reference/ljmereadname // // If there is an error, DF will automatically catch it and display in the // Command / Alert window. // // In the normal LJM versions of these functions the first parameter is // a Handle you get from an Open call, but DF automatically calls LJM_Open // as needed, so the first parameter in DF is the Identifier parameter as // would be passed to LJM_Open. Note that DF always calls LJM_Open // with DeviceType=Any and ConnectionType=Any, so if a device is connected // by USB & Ethernet & WiFi, and you pass an Identifier other than an IP // address, the USB connection will likely be found first and used. // // http://labjack.com/support/ljm/users-guide/function-reference/ljmopen // http://labjack.com/support/ljm/users-guide/function-reference/opening-and-closing/identifier-parameter // // What Names are there to read or write? See the applicable section // of the T7 Datasheet and/or the Modbus Map: // // http://labjack.com/support/datasheets/t7 // http://labjack.com/support/modbus/map // // Likely names you might want to use for AIN configuration: // AIN#(0:254)_RANGE // AIN#(0:254)_NEGATIVE_CH // AIN#(0:254)_RESOLUTION_INDEX // AIN#(0:254)_SETTLING_US // AIN_ALL_RANGE // AIN_ALL_NEGATIVE_CH // AIN_ALL_RESOLUTION_INDEX // AIN_ALL_SETTLING_US