Creating a Device and accessing a USB datalogger


cannonpm

Recommended Posts

I have an Omega TC-08 8-channel USB thermocouple datalogger. I would like to use the Omega API to access the temperatures from this box. I have tried connecting the T/C's directly to my LabJack U6 with CB37 board, but I keep getting wildly fluctuating readings. So I thought I would try the API route.

I have created a new Device, and added all the functions exposed in the omega DLL. The functions are entered using the Extern() function in the On Load event of this device. I added an I/O of type Input-Numeric.

I have all the documentation from Omega as to the parameters expected for their functions, etc.

But I am confused as to what I next need to do. How do I actually get the data into the channel? In other words, where do I actually start using the functions?

In plain English, I have to programatically open the TC-08, then put it in a streaming mode to send data every x milliseconds, and then it returns the readings into a buffer referred to by a pointer as an argument to the function.

And when it is all said and done, and it is time to shut down the DAQFactory, I plan to add a Sequence called OnShutdown which will close and unload the driver.

Any suggestions or pointers would be quite helpful to get me started on the right path. Thanks.

Link to comment
Share on other sites

Unless you are going to reuse this hardware in lots of different DAQFactory applications, the easiest thing to do is write a little sequence that does these steps. The sequence would have a loop that performed the steps required. Initialization that only occurs once should go in a separate sequence marked "auto-start", probably along with the extern() statements. To get the data into channels, use the addvalue() function of the channel. So if you have a value in a private variable called "data", and you want to put it into a channel called "mychannel", you'd do:

mychannel.addvalue(data)

There are lots of examples using AddValue() in the forum. Though for different purposes, the concept is the same.

Link to comment
Share on other sites

After much trial and error (mainly due to inconsistencies in the Omega API documentation), I have gotten DF to access the Omega device and stuff values into a V channel, all by using a sequence (thanks for the idea!).

From reading the manual and the forum, I get the impression that using V channels can be a bit archaic and old-school, as better alternatives are available (like export set or a test channel).

My questions are these:

* After reading the manual, I am a bit uncertain as to which alternative is better, the export set or test channel, for this application. Any comments?

* I have the data coming from the Omega box to a V channel, but I also have data coming from instruments connected to a LabJack U6 which is tied to DF and shows up on real channels. I am interested in doing real-time logging as opposed to export set so if the computer crashes, my data is still safe. If I set the history on both real and V channels to a great enough value, say 5000 (since I am logging every other second for perhaps 8 hours) will the data in both real and V channels stay stored in DF after it crashes or closes?

* How do I relatively sync the timestamps so that it reads from the Omega box at the same time as it reads from the LabJack? I remember reading about a way to input a tolerance for timestamp variation, is this the way? Accuracy for which I am looking is within 5-10 seconds.

*I understand that using an export set might be more flexible. It can handle both real and V channels, correct (what I mean by this is I can have some channels be real, and some be V, and export will still work)?

*If I use a Test Channel, can this be logged using the standard logger (i.e. it is a 'real' channel and not a V channel)? In other words, I could add these test channels to the logger, and have it function correctly even with all the other real channels in the logger.

I really appreciate any insight, thank you very much! This forum has been a big help!

Link to comment
Share on other sites

Yes, you probably don't want V channels. They lack persistance and can't be logged with a logging set. They were originally designed for when DAQFactory didn't have variables, but people still use them a lot, presumably because its easy to see their contents. There is no "export set" solution. Export sets are often used to write one line of data at a time from script, but not for keeping historical data in memory so it can be used by screen elements and the like. For that, use a channel and the addvalue() function as I described.

So, your questions:

1) just answered. Use a Test channel. Just remember to set the Timing to 0.

2) again, use channels for both the LabJack and the Omega. Set the Persist setting for the channels to the same size as the history (or bigger) and it will remain when you restart DAQFactory

3) Time sync: Two ways: a) use an event on one of the LabJack channels to do the Omega read instead of using a separate sequence, or B) use a sequence to read both the LabJack and the Omega. Trying to sync a sequence to a channel is a bit more involved, so using one or the other is a better choice.

Oh, and actually it might be better to create yet another Test channel, called "OmegaTrigger" or something that has the same Timing as your LabJack channels, but a slightly different offset (say 0.01). Then in its event put all your omega reading code. Don't log this Test channel because it'll just have junk data in it, but log your other Test channels (the ones that have a Timing = 0 and you used AddValue() on with your omega data)

4) Export sets can log anything. Logging sets only log channels. If your data is slow, you can use an export set being triggered from a sequence to log the lines when you want them (i.e. after a polling loop is complete). The result is not as time precise as logging sets, but for slow things, that is usually not a problem.

5) A Test channel is a 'real' channel. There is even a driver that gets called if you have a non-zero timing or try and set an output. The driver returns a sine wave. So, the Test channel works with everything your LabJack channels do. That's why I recommend using AddValue on Test channels (with Timing = 0 to avoid the driver being called) to stuff data from your Omega rather than V channels.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.