bbosse Posted July 17, 2019 Share Posted July 17, 2019 Hi there! I'm using a Lua script to control the output of my LabJack T7 to set DAC0 to 5V and DAC1 to 5V using: MB.W(1002, 3, 5) -- this turns the LED light off by turning the DAC1 to 5V MB.W(1000, 3, 5) -- TURN DAC0 to 5 V which is used as a reference for the BuckPuck Reference channel This works just fine. Now what I want to do is to send a trigger from Kipling to DAQFactory to tell it to start recording data. What is the best way to send a trigger signal from Kipling (Lua script) to DAQFactory sequence script? The approach I'm attempting is to set FIO0 channel to 1 using: MB.W(2000, 0, 1) -- set FIO0 to 1 to trigger DAQFactory to run its save script -- do other stuff here MB.W(2000, 0, 0) -- set FIO0 to back to 0 to after the trigger happens but, it isn't working. When I read channel FIO0 in DAQFactory using: // Set scans/second. private scanRate = 2000 // Set scans/read. This is how many scans are retrieved per call to the stream read // function, and thus controls the iteration rate of the loop below. private scansPerRead = scanRate / 2000 // Start the stream with a scan list of AIN0, AIN1, etc. These are streamable Names from the LabJack Modbus Map, not DF Channel names. LJM_eStreamStart(identifier, {"AIN0", "AIN1", "AIN2", "AIN3", "AIN4", "AIN5", "AIN6", "AIN7", "FIO0"}, scanRate, scansPerRead, 1) dataIn = LJM_eStreamRead(identifier) FIOvalue = dataIn.data.FIO0 FIOvalue just stays 1. Even if I try to set it back to 0 in Lua with MB.W(2000, 0, 0) it just stays 1 when I read it in DAQFactory. Perhaps I'm not using the MB.W function properly? I have searched for the documentation for the mbWrite function to know what each of the 3 parameters are, but haven't found the documentation yet. Or perhaps there is a better way to communicate from Kipling Lua script to DAQFactory sequence to trigger events? Thank you! B Link to comment Share on other sites More sharing options...
AzeoTech Posted July 19, 2019 Share Posted July 19, 2019 I'm going to let LabJack give you a more specific response, but in general you'd want to set some flag, possibly a digital output, or some virtual I/O point that is accessible through the LabJack driver. Create a channel for that point, and then use the Event of the channel to look for a particular state and trigger your sequence. Link to comment Share on other sites More sharing options...
LabJackSupport Posted July 19, 2019 Share Posted July 19, 2019 The modbus write function is documented here: https://labjack.com/support/datasheets/t-series/scripting/labjack-library I don't spot anything wrong in your calls to set FIO0 to output-high and output-low. Check out the Lua example "Toggle DIO 1Hz". We can continue troubleshooting that, but my approach might be a little different. How about using USER_RAM0_U16 and having the Lua script increment it when desired. Then DAQFactory can read that register and note if it has changed from the previous value. That way you never miss a trigger. https://labjack.com/support/datasheets/t-series/lua-scripting Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.