Omega Speaker Systems TC-08 manual Example, ==================================================

Page 13

Technical reference

9

Example

The following code is a fragment of a C application demonstrating how to use

Streaming mode with the USB TC-08 driver:

//==================================================

//Setting up and running the unit in Streaming mode //==================================================

usb_tc08_set_mains(handle, 0); // use 50Hz mains noise rejection

for (channel = 0; channel < 9; channel++)

{

//set each channel up as a type K thermocouple

//channel 0 is the cold junction and will be enabled

//by setting the third argument to anything other than ' ' usb_tc08_set_channel(handle, channel, 'K');

}

//find out how fast the unit can sample in its current setup state minimum_interval = usb_tc08_get_minimum_interval_ms(handle);

usb_tc08_run(handle, minimum_interval); // sample as fast as possible

//not required (just illustrates that the application

//can be idle while the driver collects the readings) Sleep(10000);

//use a two dimensional array with an array of readings for each channel

//In a real application, this would be a nested loop to regularly poll

//the unit for readings

for (channel = 0; channel < 9; channel++)

{

no_of_readings = usb_tc08_get_temp( handle, &reading_buffer[channel], ×_buffer[channel], buffer_length, &overflows[channel], channel,

0, // degrees Celsius units

0); // do not fill missing readings

}

//finished polling, now do something with the readings

//if overflows[channel] is high, then one of the readings

//in reading_buffer[channel] has exceeded the input range

//of the USB TC-08

//only stop the unit when we've completely finished streaming usb_tc08_stop(handle);

Note: You should close down all other applications while you are performing any timing-critical data logging tasks. Check that the Windows scheduler does not have any activities planned during the logging session.

Image 13
Contents User’s Guide Servicing North America Contents Page Overview Installing the driver Connecting the USB TC-08Refresh TC-08 Users GuideTC-08 Channels window, double-click on Channel 1 unused Safety grounding Safety warningMaximum input range Mains voltagesSpecifications How a thermocouple works Modes of operation IntroductionIntroduction Streaming mode ================================================== ExampleGet Single mode Usbtc08setmains handle, 0 // use 50Hz mains noise rejection Legacy mode Now do something with the cold junction temperature New USB mode only Routine Description New USB and serial modeLegacy mode only Driver routinesShort usbtc08openunit void New USB mode and legacy modeNone ArgumentsReturns Positive shortStore the handle in an array handlearrayi = newhandle Arguments None Returns Short usbtc08openunitasync voidHandle any error conditions if result == Progress HandleArguments handle Short tc08closeunit Short handleShort usbtc08stop Short handle Sixtyhertz Short usbtc08setmains Short handle, short sixtyhertzMinimum Long usbtc08getminimumintervalms Short handleInterval Info Short usbtc08getunitinfo Shorthandle, USBTC08INFO * infoStringlength Short usbgetformattedinfo Handle Char UnitinfoUSBTC08MAXINFOCHARS characters long User/Developer error codes Error Further information Code Short usbtc08getlasterror Short handleReserved error codes ErrorCode Channel New USB mode onlyTctype Long usbtc08run Short handle, long interval Overflowflags TempUnits Tempbuffer Long usbtc08gettemp Short Handle Float * tempbufferTimesmsbuffer OverflowShort Channel Units Fillmissing Long usbtc08gettempdeskew Short Handle Float * temp TimesShort usbtc08legacyrun Short handle Legacy mode onlyFilterfactor Filtered Short usbtc08legacygetcoldjunction Long * temp, short handle Driver version Number Short usbtc08legacygetdriverversion VoidVersion Short usbtc08legacygetversion Short * version, short handleCycle Short usbtc08legacygetcycle Long * cycle, short handleC++ ProgrammingDelphi LabVIEW ExcelVisual Basic Agilent VEEKey TroubleshootingCold junction compensation. See CJC GlossaryTechnical reference Page Index TC-08 Users Guide WARRANTY/DISCLAIMER Shop online at omega.com