AzeoTech Posted January 27, 2021 Share Posted January 27, 2021 1) for any serial (or ethernet) device you have to create a "device" in DAQFactory. A serial device in DAQFactory consists of a port (like COM1 or 10.0.0.1) and a protocol like Modbus. In your case, the protocol will be "NULL Protocol" because you are going to script your own. To create this device, go to Quick -> Device Configuration in the main menu and select New Serial / Ethernet Device. Give the device a name that makes sense to you, then click on New Serial Port to create the port. Enter the comm parameters and give the port a name. Then select NULL Protocol and hit ok. Now you have a serial "device". For the script I'm going to assume you called it "myDevice" though I suggest something more descriptive 2) create 10 channels to hold your ten values. Each channel should be Device Type Test, A to D with a Timing of 0. The History should be big enough to hold however much data you want to trend. At 30 second update for a week, we are talking 720 data points a day = 5040, so I'd set the history to like 10000. The other parameters can be left at their defaults. For the script I'm going to assume you called the channels "chan0", "chan1", etc though again I suggest more descriptive 3) create a sequence to get the data. The script would look something like this: device.myDevice.purge() // clear out anything in the comm buffer private string sdatain private string datain while(1) try sdatain = device.myDevice.readUntil(13) datain = Parse(sdatain, -1, ",") if (numrows(datain) != 10) continue // didn't get a full row endif chan0.addValue(datain[0]) chan1.addValue(datain[1]) // ... etc for the 10 channels catch() ? strLastError // only keep this line during debugging otherwise you'll get a bunch of timeout errors endcatch delay(0.2) endwhile 4) run the sequence. If you still have that ? strLastError you'll likely get a timeout error in the Command/Alert every second. But it is good to have just in case you have a typo in the rest of the script. Once the script works reliably, comment out or delete the ? strLastError line. Data should now arrive in those channels which you can then plot or log or do whatever you want with. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.