Home

LabJack U3 User's Guide (-LV & -HV)

image

Contents

1. 87 Table 4 3 Group Level Errorcodes Sre area a a nennen nnnm nnns nana rennen nnns 88 vi 1 Installation on Windows The LJUD driver requires a PC running Windows 98 ME 2000 XP or Vista For other operating systems go to labjack com for available support Software will be installed to the LabJack directory which defaults to c Program Files LabJack Install the software first Install the software using the CD or by downloading the latest UD installer from labjack com Although all necessary software is available at labjack com do not discard the CD as it includes a fully licensed copy of DAQFactory Express which is not available by download Connect the USB cable The USB cable provides data and power After the UD software installation is complete connect the hardware and Windows should prompt with Found New Hardware and shortly after the Found New Hardware Wizard will open When the Wizard appears allow Windows to install automatically by accepting all defaults Run LJControlPanel From the Windows Start Menu go to the LabJack group and run LJControlPanel Click the Find Devices button and an entry should appear for the connected U3 showing the serial number Click on the USB 1 entry below the serial number to bring up the U3 configuration panel Click on Test in the configuration panel to bring up the test panel where you can view and control the various I O on th
2. 69 F SAANG OUUU ERES 71 4 3 53Blgital C E TEE 71 4 3 0 Timers amp Counters 2 Wa ae iea ai ae EE 72 4 38 Mode anren BW ieee sce We EE E E E E EE oes 74 4 3 8 Raw nennen nene nene nnne nennen nnns 78 2 3 E38 PUNCHONS iai coped MM LULA pe I 78 4 3 10 SPI Serial Communication essem 80 4 3 11 C Serial CORITIUIe3tbiss s ones reet aree E ta ete btt iter lbid 81 4 3 12 Asynchronous Serial Communication ssssssssseeennn 82 4 3 15 Watchdog tete a arte bea gie ae bee reb see a fette cena ei ese ts 83 4 3 14 Miscellaneous REN sess saved e XR RR ARN REN EN X MRR 85 4 4 IE rrorcOdeS 86 5 Low Level Function Reference 89 5 1 General Protoco ttt tere ia Ce eror dd eel ec e rt rte gts 89 5 2 LoweLevel Functlons i iret rire erre Ehre R E eH 92 5 2 1 BadChecksumi i e er RH ERA donde IRE REOR GER UE IRR ERA 92 5 2 2 CONMQUS vce E 93 DZ 73 COMM EET 96 524 Config TITHIBFOTOG I sete del 98 Ie qu 99 5 2 6 ReadMem ReadGal bene po getto to det ce des dedu en
3. 8 1 2 Self Upgrade Application 11 2 Hardware Description sssssssssssss emen ener 13 21 MS E acatnd 13 2 2 Status tat cs Ga ers ale Pt he elt Aceh a ae et 14 2 9 GND arid 5 iir E 14 ee 14 2 5 Flexible TO TEIOIBIG inet eene tabo 14 PRI wach 16 2 6 1 Channel N mb ers 2 5 itd Ete tiene e hears ert cesi 16 2 6 2 Converting Binary Readings to Voltages 17 2 6 3 Typical Analog Input Connections esee enn 20 2 6 4 Internal Temperature Sensor sss 26 zd DAL ci e iouis ru eC 26 2 7 1 Typical Analog Output COnngeuornis ipia oe tele Dee 27 2 8 Digital cs vay eed Gilet Las Mele den BRA 28 2 8 1 Typical Digital Connections intro cde rode pa d paved rante fec haut tec 29 2 9 Timers Counlers er a EIE e EROR PRESE EUR dade EARN ATE EE RR EE RR P Kr Pa FR ieee 33 2 9 1 Timer Mode Descriptions sss eene ene eene 35 2 9 2 Timer Operation Performance
4. 40 2 0 q and SCLISDAISCA ote esatto af pea misse ties a Pn stub tes 40 21i DBIS E dU buta ai acie Duran IE aorta 40 2 11 1 CB15 Terminal Board sss eene mene enne 41 2 11 2 RB12 Relay Board te eiie b canoe Cre ER Xu ELI Fo 41 PURPOSE P 42 2 13 Hardware TSevisiOn NDIGs foede cete ot torte 43 3 44 3 T Command Response ni eret eph tpe tei te ett e a ur EE E T Breeders 44 3 2 Stream Mode eiecit ee e ree gu ER RETE HERE TEL EX HEX ETC EN EY e 46 3 2 1 Streaming Digital Inputs Timers and Counters 47 4 LabJackUD High Level Drver us eere renti ridens puer ben Et e Een bae 49 ASV OVOIVIOW cte tit ott t eet m e a E ERES 49 FP nction aden sya eee e rac rue n epe Dae iesus 51 4 1 2 Multi Threaded 52 4 2 Function Reference 54 S at 54 2 2 2 Ope kabJack s asas cutcase mote fuiife ect LA ETE IM Acre 55 4 and el Ul 56 AD A atti mt 57 4 2 5 AddBRegquest
5. This disables all timers and counters sets the timer counter pin offset to 4 sets the timer clock base to 48 MHz no divisor sets the timer clock divisor to 0 and sets all flexible I O to digital A simpler option is using the following IOType created exactly for this purpose which does the same thing as the 8 function calls above ePut lngHandle LJ ioPIN CONFIGURATION RESET 0 0 0 There are two IOTypes used to write or read general configuration parameters LJ ioPUT CONFIG LJ ioGET CONFIG The following constants are then used in the channel parameter of the config function call to specify what is being written or read LJ chLOCALID LJ chHARDWARE VERSION LJ chSERIAL NUMBER LJ chFIRMWARE VERSION LJ chBOOTLOADER VERSION LJ chPRODUCTID LJ chLED STATE Following is example pseudocode to write and read the local ID Set the local ID to 4 ePut lngHandle LJ ioPUT CONFIG LJ chLOCALID 4 0 Read the local ID eGet lngHandle LJ ioGET CONFIG LJ chLOCALID amp dblValue 0 4 3 3 Analog Inputs The lOTypes to retrieve a command response analog input reading are 69 LJ ioGET AIN Singl nded Negative channel is fixed as 31 LJ ioGET AIN DIFF Specify negative channel in xl The following are special channels used with the get put config OTypes to configure parameters that apply to all analog inputs LJ chAIN RESOLUTION QuickSample enabled if TRUE LJ chAIN SETTL
6. RUNNING LJE INVALID PARAMETER LJE INVALID STREAM FREQUENCY LJE INVALID RANGE LJE STREAM CHECKSUM ERROR LJE STREAM COMMAND ERROR LJE STREAM ORDER ERROR LJE AD PIN CONFIGURATION ERROR LJE REQUEST NOT PROCESSED LJE SCRATCH ERROR LJE DATA BUFFER OVERFLOW LJE ADCO BUFFER OVERFLOW LJE FUNCTION INVALID LJE SWDT TIME INVALID LJE FLASH ERROR LJE STREAM IS ACTIVE LJE STREAM TABLE INVALID LJE STREAM CONFIG INVALID LJE STREAM BAD TRIGGER SOURCE LJE STREAM INVALID TRIGGER LJE STREAM ADCO BUFFER OVERFLOW LJE STREAM SAMPLE NUM INVALID LJE STREAM BIPOLAR GAIN INVALID LJE STREAM SCAN RATE INVALID Table 4 1 Request Level Errorcodes Part 1 Description Warning Defaults used instead Warning Defaults used instead Channel that does not exist e g DAC2 on a 9 or data from stream is requested on a channel that is not in the scan list Overrun of the UD stream buffer Stream packet received out of sequence Analog request on a digital pin or vice versa Previous request had an error 86 Errorcode Name 36 LJE TIMER INVALID MODE 37 LJE TIMER QUADRATURE AB ERROR 38 LJE TIMER QUAD PULSE SEQUENCE 39 LJE TIMER BAD CLOCK SOURCE 40 LJE TIMER STREAM ACTIVE 41 LJE TIMER PWMSTOP MODULE ERROR 42 LJE TIMER SEQUENCE ERROR 43 LJE TIMER SHARING ERROR 44 LJE TIMER LINE SEQUENCE ERROR 45 LJE EXT OSC NOT STABLE 46 LJE INVALID POWER SETTING 47 LJE PLL NOT LOCKED 48 LJE INVALID PIN 49 LJE IO
7. e VS CIO1 CIO3 EIOO EIO2 ElO4 EIO6 GND ZODAN FIO1 FIO3 GND DAC1 GND FIO5 FIO7 GND SPC SCL on lt 1 30 GND 42 2 13 Hardware Revision Notes U3A U3B U3C Revision 1 20 Revision 1 21 Revision 1 30 Starting September of 2006 all U3 shipments changed from hardware revision 1 20 to 1 21 Following are the some of the main changes in revision 1 21 The default timer clock frequency is 48 MHz All TimerBaseClock frequencies are twice the previous frequencies The input timer edge limit is now 30 000 edges second compared to the old limit of 10 000 edges second Stream mode is now supported See Section 3 2 Other new functions are supported including Watchdog SPI Asynch I2C and SHT1X Typical supply current is 50 mA Revision 1 20 can be upgraded to 1 21 by LabJack for a small fee For information about upgrading a rev 1 20 unit contact LabJack Corporation Hardware revision 1 30 was released in mid March 2008 with 2 variations U3 LV and U3 HV The U3 LV is the most compatible with the previous U3 and the only changes possibly affecting backwards compatibility are Timers Counters cannot appear on FIOO 3 TimerCounterPinOffset must be 4 8 value of 0 3 will result in an error This error can be suppressed by a power up default setting in LJControlPanel If suppressed a 0 3 will result in an offset of 4 The 3 66 reference voltage is no longer available on the REF DAC1 terminal
8. 7 o PotbRead 28 1 Portbirwrite 29 7 DACO t 34 2 o0 Dact bt 35 2 oo 02001600 38 3 o0 DACi i b 39 3 o 4 a4 Tme CoWg 4 44 4 TmerCoWg 45 oo s 2 a4 Comei 5 2 a Buzr NINI AA LAIA ISOIVINININI gt INI gt INININININININ 100 5 2 5 1 AIN lOType 1 AIN 3 Command Bytes 0 lOType 1 1 Bits 4 0 Positive Channel Bit 6 LongSettling Bit 7 QuickSample 2 Negative Channel 2 Response Bytes 0 AIN LSB 1 AIN MSB This IOType returns a single analog input reading e Positive Channel 0 15 for AINO AIN15 30 for temp sensor or 31 for Vreg Note that AINO AIN7 appear on FIOO FIO7 and AIN8 AIN15 appear EIOO EIO7 e LongSettling If this bit is set additional settling time is added between the multiplexer configuration and the analog to digital conversion e QuickSample If this bit is set a faster analog input conversion is done at the expense of increased noise e Negative Channel 0 15 for AINO AIN15 30 for Vref or 31 for single ended Note that AINO AIN7 appear on FIOO FIO7 and AIN8 AIN15 appear on EIO0 EIO7 e AIN LSB 84 MSB Analog input reading is returned justified as a 16 bit value always unsigned 5 2 5 2 WaitSh
9. const char plOType const char pChannel Declaration LJ ERROR stdcall AddRequest LJ HANDLE Handle long lOType long Channel double Value long x1 double UserData Parameter Description Returns LabJack errorcodes or 0 for no error Inputs Handle Handle returned by OpenLabJack The type of request See Section 4 3 Channel The channel number of the particular Value Value passed for output channels X1 Optional parameter used by some UserData Data that is simply passed along with the request and returned unmodified by GetFirstResult or GetNextResult Can be used to store any sort of information with the request to allow a generic parser to determine what should be done when the results are received Outputs e None 4 2 6 Go After using AddRequest to make an internal list of requests to perform call Go to actually perform the requests This function causes all requests on all open LabJacks to be performed After calling Go call GetResult or similar to retrieve any returned data or errors Go can be called repeatedly to repeat the current list of requests Go does not clear the list of requests Rather after a call to Go the first subsequent AddRequest call to a particular device will clear the previous list of requests on that particular device only 58 Note that for a single or GoOne call the order
10. 3 If there is no activity from the U3 s LED after following the above steps please contact support 12 2 Hardware Description The U3 has 3 different I O areas e Communication Edge e Screw Terminal Edge e DB Edge The communication edge has a USB type B connector with black cable connected in Figure 2 1 All power and communication is handled by the USB interface The screw terminal edge has convenient connections for the analog outputs and 8 flexible I O digital I O analog inputs timers or counters The screw terminals are arranged in blocks of 4 with each block consisting of Vs GND and two I O There is also a status LED located on the left edge The DB Edge has a D sub type connectors called DB15 which has the 8 EIO lines and 4 ClO lines The EIO lines are flexible like the FIO lines while the CIO are dedicated digital I O Figure 2 1 LabJack U3 2 1 USB For information about USB installation see Section 1 The U3 has a full speed USB connection compatible with USB version 1 1 or 2 0 This connection provides communication and power Vusb USB ground is connected to the U3 ground GND and USB ground is generally the same as the ground of the PC chassis and AC mains 13 The details of the U3 USB interface are handled by the high level drivers Windows LabJackUD DLL so the following information is really only needed when developing low level drivers The LabJack vendor ID is OxOCD5 The product
11. Comm A UESControl U3 Connect by Getting U3 version numbers U3 Firmware Version 1 320 LocalID uH Iv Use first found U3 Bootloader Version 0 110 C Ethernet IP Address 192 fies 209 Figure 1 5 Self Upgrade Application If problems are encountered during programming try the following 1 Unplug the U3 wait 5 seconds then reconnect the U3 Click OK then press program again 11 2 If step 1 does not fix the problem unplug the U3 and watch the LED while plugging the U3 back in Follow the following steps based on the LED s activity a If the LED is blinking continuously connect a jumper between F104 and SPC FIOO to SCL on U3 1 20 1 21 then unplug the U3 wait 5 seconds and plug the U3 back in If the LED blinks several times and stays on connect a jumper between FIO5 and SPC FIO1 to SCL on 1 20 1 21 then unplug the U3 wait 5 seconds and plug the U3 back in If the LED blinks several times and stays off the U3 is not enumerating Please restart your computer and try to program again If there is no LED activity connect a jumper between FIO5 and SPC FIO1 to SCL on U3 1 20 1 21 then unplug the U3 wait 5 seconds and plug the U3 back in If the LED is blinking continuously click OK and program again If the LED does not blink connect a jumper between 4 and SPC FIOO to SCL on 1 20 1 21 then unplug the wait 5 seconds and plug the U3 back in
12. Hardware Version A newer firmware version is available online To upgrade please close LJControlPanel and run LJSelfUpgrade Exit F4 Found 2 USB 1 UDP 0 specified Figure 1 1 LJControlPanel Main Window Find Devices Figure 1 1 shows the results from a typical search The application found one U3 connected by USB The USB connection has been selected in Figure 1 1 bringing up the configuration window on the right side Refresh Reload the window using values read from the device Write Values Write the Local ID from the window to the device Config IO Defaults Opens the window shown in Figure 1 2 Reset Click to reset the selected device Test Opens the window shown in Figure 1 3 Analog Input FIO Al Set Default Digital 10 and DAC Yalues Digital Direction FIO Digital State FIO B E Mm M 00 01 02 03 04 05 06 07 EIO Be 00 01 02 O3 04 05 06 07 EIQ E NOE 02 03 04 05 06 07 EID 00 01 02 O3 04 05 06 07 Checked Analog Unchecked Digital 00 01 02 03 04 05 06 07 cid 00 01 02 03 103 02 03 04 05 0607 00 01 02 03 Checked Output Checked High Analog Outputs DACO 0 0679 ES DAC 0 0673 E Write Factory Values Enabled Figure 1 2 LJControlPanel U3 Configure Defaults Window Figure 1 2 shows the configuration window for
13. LabJack LabJack U3 User s Guide LV amp HV Hardware Revision 1 30 Revision 1 08 March 9 2009 LabJack Corporation www labjack com support labjack com For the latest version of this and other documents go to www labjack com LabJack designs and manufactures measurement and automation peripherals that enable the connection of a PC to the real world Although LabJacks have various redundant protection mechanisms it is possible in the case of improper and or unreasonable use to damage the LabJack and even the PC to which it is connected LabJack Corporation will not be liable for any such damage Except as specified herein LabJack Corporation makes no warranties express or implied including but not limited to any implied warranty or merchantability or fitness for a particular purpose LabJack Corporation shall not be liable for any special indirect incidental or consequential damages or losses including loss of data arising from any cause or theory LabJacks and associated products are not designed to be a critical component in life support or systems where malfunction can reasonably be expected to result in personal injury Customers using these products in such applications do so at their own risk and agree to fully indemnify LabJack Corporation for any damages resulting from such applications LabJack assumes no liability for applications assistance or customer product design Customers are responsible for the
14. alngTimerModes adblTimerValues 0 0 Read and reset the input timer Timerl read and reset Counter0 and update the value duty cycle of the output timer Timer0 Fill the arrays with the desired values then make the call alngReadTimers 0 1 Read Timerl alngUpdateResetTimers 1 1 Update Timer0 and reset Timerl alngReadCounters 1 0 Read Counter0O alngResetCounters 1 0 Reset Counter0 adblTimerValues 32768 0 Change Timer0 duty cycle to 50 79 ZZ eTCValues Handle aReadTimers aUpdateResetTimers aReadCounters aResetCounters aTimerValues aCounterValues Reservedl Reserved2 eTCValues lngHandle alngReadTimers alngUpdateResetTimers alngReadCounters alngResetCounters adblTimerValues adblCounterValues 0 0 printf Timerl value 0f n adblTimerValues 1 printf Counter0O value 0f n adblCounterValues 0 4 3 10 SPI Serial Communication The U3 hardware version 1 21 only supports Serial Peripheral Interface SPI communication as the master only SPI is a synchronous serial protocol typically used to communicate with chips that support SPI as slave devices This serial link is not an alternative to the USB connection Rather the host application will write read data to from the U3 over USB and the USB communicates with some other device using the serial protocol Using this serial protocol is considered an advan
15. then multiply by the proper high voltage slope divide by the single ended low voltage slope and add the proper high voltage offset The UD driver handles these conversions automatically Although the binary readings have 12 bit resolution they are returned justified as 16 bit values so the approximate nominal conversion from binary to voltage is Volts uncalibrated Bits 65536 Span Single Ended Volts uncalibrated Bits 65536 Span Span 2 Differential Binary readings are always unsigned integers Where span is the maximum voltage minus the minimum voltage from the tables above The actual nominal conversions are provided in the tables below and should be used if the actual calibration constants are not read for some reason Most applications will use the actual calibrations constants Slope and Offset stored in the internal flash Volts Slope Bits Offset Since the U3 uses multiplexed channels connected to a single analog to digital converter ADC all low voltage channels have the same calibration for a given configuration High voltage channels have individual scaling circuitry out front and thus the calibration is unique for each channel Table 2 7 shows where the various calibration values are stored in the Mem area Generally when communication is initiated with the U3 four calls will be made to the ReadMem function to retrieve the first 4 blocks of memory This information can then be used to convert all a
16. For accurate measurements the temperature of the entire U3 must stabilize relative to the ambient temperature which can take on the order of 1 hour Best results will be obtained in still air in an environment with slowly changing ambient temperatures With the UD driver the internal temperature sensor is read by acquiring single ended analog input channel 30 and returns degrees K 2 7 DAC The LabJack has 2 analog outputs DACO and DAC71 that are available on the screw terminals Each analog output can be set to a voltage between about 0 04 and 4 95 volts with 10 bits of resolution 8 bits on older hardware revision 1 20 1 21 The maximum output voltage is limited by the supply voltage to the U3 Starting with hardware revision 1 30 DAC1 is always enabled and does not affect the analog inputs but with older hardware the second analog output is only available in certain configurations With hardware revisions 1 30 if the analog inputs are using the internal 2 4 volt reference the most accurate option then DAC1 outputs a fixed voltage of 1 5 Vref Also with hardware revisions 1 30 if DAC1 is enabled the analog inputs use Vreg 3 3 volts as the ADC reference which is not as stable as the internal 2 4 volt reference The DAC outputs are derived as a percentage of Vreg and then amplified by 1 5 so any changes in Vreg will have a proportionate affect on the DAC outputs Vreg is more stable than Vs 5 volt supply voltage as it
17. Rather than specifying the IOType and Channel of the result to be read the GetFirst GetNext functions retrieve the results in order Normally GetFirst GetNext are best used in a loop but here they are simply called in succession Retrieve AIN2 voltage GetFirstResult returns the IOType Channel Value x1 and UserData from the first request In this example we are just retrieving the results in order and Value is the only parameter we need GetFirstResult lngHandle 0 0 amp dblValue 0 0 Get the AINI AIN6 voltage GetNextResult lngHandle 0 0 amp dblValue 0 0 Get the AINi Vref voltage GetNextResult lngHandle 0 0 amp dblValue 0 0 70 Get the 1 voltage GetNextResult lngHandle 0 0 amp dblValue 0 0 Get the AIN1 voltage special 0 3 6 volt range GetNextResult lngHandle 0 0 amp dblValue 0 0 4 3 4 Analog Outputs The IOType to set the voltage on an analog output is LJ ioPUT DAC The following are IOTypes used to write read the enable bit for DAC1 LJ ioPUT DAC ENABLE Ignored on hardware rev 1 304 as DAC1 always enabled LJ ioGET DAC ENABLE The following is a special channel used with the get put config OTypes to configure a parameter that applies to all DACs LJ chDAC BINARY Following is example pseudocode to set DACO to 2 5 volts Set DACO to 2 5 volts ePut lngHandle LJ ioPUT DAC 0 2 50 0 4 3 5 Digital I O T
18. There is no longer a buzzer SDA terminal is gone SCL terminal changed to SPC UART Asynch functionality no longer uses SDA and SPC terminals but rather uses terminals dynamically assigned after timers and counters Other changes Analog outputs are now specified for 10 bit resolution and DAC1 is always enabled The higher resolution is available with a new in the low level Feedback function which the high level UD driver uses automatically This causes the DACs to have more noise when the timer clock is decreased from the default of 48 MHz so there is a compatibility option available in LJControlPanel to use 8 bit DACs On the U3 HV only the first four flexible I O are fixed as analog inputs AINO AIN3 and have scaling such that the input range is 10 volts normally and 20 to 10 volts when using the Special range The input impedance of these four lines is roughly 1 MQ which is good but less than the normal low voltage analog inputs Analog digital configuration and all other digital operations on these pins are ignored FIO4 EIO7 are still available as flexible I O same as the U3 LV Revision 1 20 21 U3s cannot be upgraded to 1 30 43 3 Operation 3 1 Command Response Everything besides streaming is done in command response mode meaning that all communication is initiated by a command from the host which is followed by a response from the U3 For everything besides pin configuration the low le
19. 2006 Contact LabJack for information about upgrading older U3s Stream is a continuous hardware timed input mode where a list of channels is scanned at a specified scan rate The scan rate specifies the interval between the beginning of each scan The samples within each scan are acquired as fast as possible As samples are collected they are placed in a small FIFO buffer on the U3 until retrieved by the host The buffer typically holds 984 samples but the size ranges from 512 to 984 depending on the number of samples per packet Each data packet has various measures to ensure the integrity and completeness of the data received by the host Since the data buffer on the U3 is very small it uses a feature called auto recovery If the buffer overflows the U3 will continue streaming but discard data until the buffer is emptied and then data will be stored in the buffer again The U3 keeps track of how many packets are discarded and reports that value Based on the number of packets discarded the UD driver adds the proper number of dummy samples 9999 0 such that the correct timing is maintained The table below shows various stream performance parameters Some systems might require a USB high high configuration to obtain the maximum speed in the last row of the table A USB high high configuration means the U3 is connected to a high speed USB2 hub which is then connected to a high speed USB2 host Even though the U3 is not a high speed USB d
20. 5 Self Upgrade 11 Fig e 21 LAD JACK quc 13 Table 2 1 Analog Input Pin Locatioris n retreat ar 15 Table 2 2 ConfiglO Factory Default Values 15 Table 2 3 ConfigTimerClock Factory Default 15 Table 2 4 Positive Channel Numbers x 2 n 17 Table 2 5 Negative Channel 17 Table 2 6 Nominal Analog Input Voltage Ranges for Low Voltage Channels 17 Table 2 7 Nominal Analog Input Voltage Ranges for High Voltage Channels 18 Table 2 8 Normal Calibration Constant Memory Locations 19 Table 2 9 Additional High Voltage Calibration Constant Memory Locations 19 Table 2 10 Fixed Point Conversion Examples 19 Table 2 11 Nominal Analog Input Voltage Ranges DAC1 20 Figure 2 2 Non Inverting Op Amp Configuration seennnem m 22 Figure 2 3 Voltage Divider Circuit per et Re 23 Figure 2 4 Buffered Voltage Divider Circuit nnne 24 Figure 2 5 Current Measurement With Arbitrary Load 2
21. Checksum8 1 OxF8 2 0x05 3 0x09 4 Checksum16 LSB 5 Checksum16 MSB 6 WriteMask Bit 0 Write 7 WatchdogOptions Bit 5 Reset on Timeout Bit 4 Set DIO State on Timeout 8 9 TimeoutPeriod 10 DlOConfig Bit 7 State Bit 0 4 DIO 11 Reserved 12 Reserved 13 Reserved 14 Reserved 15 Reserved 116 Response Byte 0 Checksum8 1 2 3 4 5 6 7 OxF8 0x05 0x09 Checksum16 LSB Checksum16 MSB Errorcode WatchdogOptions TimeoutPeriod DlOConfig Reserved Reserved Reserved Reserved Reserved WatchdogOptions The watchdog is enabled when this byte is nonzero Set the appropriate bits to reset the device and or update the state of 1 digital output TimeoutPeriod The watchdog timer is reset to zero on any incoming USB communication Note that most functions consist of a write and read but StreamData is outgoing only and does not reset the watchdog If the watchdog timer is not reset before it counts up to TimeoutPeriod the actions specified by WatchdogOptions will occur The watchdog timer has a clock rate of about 1 Hz so a TimeoutPeriod range of 1 65535 corresponds to about 1 to 65535 seconds DIOConfig Determines which digital I O is affected by the watchdog and the state it is set to The specified DIO must have previously been configured for output DIO is a value from 0 19 according to the following 0 7 FIOO FIO7 8 15 EIOO EIO 7 16 19 117 5 3 15 SPI Requires U3 hardware ver
22. DAC command and AIN read in a single low level call while in the second example using ePut eGet two low level commands are used Examples in the following documentation will use both the add go get method and the ePut eGet method and they are generally interchangeable See Section 4 3 for more pseudocode examples All the request and result functions always have 4 common parameters and some of the functions have 2 extra parameters e Handle This is an input to all request result functions that tells the function what LabJack it is talking to The handle is obtained from the OpenLabJack function e lOType This is an input to all request result functions that specifies what type of action is being done e Channel This is an input to all request result functions that generally specifies which channel of I O is being written read although with the config IOTypes special constants are passed for channel to specify what is being configured e Value This is an input or output to all request result functions that is used to write or read the value for the item being operated on e X1 This parameter is only used in some of the request result functions and is used when extra information is needed for certain e UserData This parameter is only used in some of the request result functions and is data that is simply passed along with the request and returned unmodified by the result Can be used to store any sort of informati
23. In the case of multiple channels the scan rate is also considered See Sections 3 1 and 3 2 2 6 3 1 Signal from the LabJack One example of measuring a signal from the itself is with an analog output All I O on the U3 share a common ground so the voltage on an analog output DAC can be measured by simply connecting a single wire from that terminal to an AIN terminal FIO EIO The analog output must be set to a voltage within the range of the analog input 2 6 3 2 Unpowered isolated signal An example of an unpowered isolated signal would be a photocell where the sensor leads are not shorted to any external voltages Such a sensor typically has two leads where the positive lead connects to an AIN terminal and the negative lead connects to a GND terminal 2 6 3 3 Signal powered by the LabJack A typical example of this type of signal is a 3 wire temperature sensor The sensor has a power and ground wire that connect to Vs and GND on the LabJack and then has a signal wire that simply connects to an AIN terminal Another variation is a 4 wire sensor where there are two signal wires positive and negative rather than one If the negative signal is the same as power ground or can be shorted ground then the positive signal can be connected to AIN and a single ended measurement can be made A typical example where this does not work is a bridge type sensor such as pressure sensor providing the raw bridge output and no amplifier In thi
24. LSB 5 Checksum16 MSB 6 Echo 7 63 IlOTypes and Data Response Byte 0 Checksum8 1 OxF8 2 1 5 Number of Data Words If Errorcode 0 3 0x00 4 Checksum16 LSB 5 Checksum16 MSB 6 Errorcode 7 ErrorFrame 8 Echo 9 63 Data e lOTypes amp Data One or more can be passed in a single command up to the maximum packet size More info about the available lOTypes is below In the outgoing command each IOType is passed and accompanied by 0 or more data bytes In the incoming response only data bytes are returned without the IOTypes e Echo This byte is simply echoed back in the response A host application might pass sequential numbers to ensure the responses are in order and associated with the proper command 99 e ErrorFrame If Errorcode is not zero this parameter indicates which IOType caused the error For instance if the 3 passed IOType caused the error the ErrorFrame would be equal to 3 Also note that data is only returned for IOTypes before the one that caused the error so if any IOType causes an error the overall function response will have less bytes than expected lOTypes for Feedback Command Wah 5 2 l o Watong 8 2 o0 TE BiStaeRead 10 2 1 BisteWre 11 2 BiDiRead 12 13 2 PotStteRead 2 1 o 3 PotStseWrte 2
25. MAX233 which inverts the logic and shifts the voltage levels Command Byte 0 Checksum8 1 OxF8 2 0x02 3 0x14 4 Checksum16 LSB 5 Checksum16 MSB 6 0x00 7 AsynchOptions Bit 7 Update Bit 6 UARTEnable Bit 5 Reserved 8 Reserved 9 10 9 BaudFactor16 BaudFactor8 for hardware 1 21 Response Byte 0 Checksum8 1 OxF8 2 0x02 3 0x14 4 Checksum16 LSB 5 Checksum16 MSB 6 Errorcode 7 AsynchOptions 8 Reserved 0 9 10 9 BaudFactor16 BaudFactor8 for hardware 1 21 e AsynchOptions If Update is true the new parameters are written otherwise just a read is done If UARTEnable is true the UART is enabled and the RX line will start buffering any incoming bytes e BaudFactor16 BaudFactor8 This 16 bit value sets the baud rate according the following formula BaudFactor16 2 16 48000000 2 Desired Baud For example a BaudFactor16 63036 provides a baud rate of 9600 bps With hardware revision 1 21 the value is only 8 bit and the formula is BaudFactor8 2 8 TimerClockBase Desired Baud 120 5 3 17 AsynchTX Requires U3 hardware version 1 21 Sends bytes to the U3 UART which will be sent asynchronously on the transmit line Command Byte Checksum8 OxF8 1 NumAsynchWords 0x15 Checksum16 LSB Checksum16 MSB 0x00 NumAsynchBytesToSend AsynchByteO Response Checksum8 OxF8 0x02 0x15 Checksum16 LSB Checksum16 MSB Errorcode NumAsynchBytesSent NumAsy
26. OxF8 NumChannels 3 0x11 Checksum16 LSB Checksum16 MSB NumChannels SamplesPerPacket 1 25 Reserved ScanConfig Bit 7 Reserved Bit 6 Reserved Bit 3 Internal stream clock frequency 4 MHz b1 48 MHz Bit 2 Divide Clock by 256 Bits 0 1 Resolution 00 12 8 bit effective b01 11 9 bit effective b10 11 3 bit effective b11 10 5 bit effective 10 11 Scan Interval 1 65535 12 PChannel 13 NChannel O Repeat 12 13 for each channel Response Byte 0 Checksum8 1 OxF8 2 0x01 3 0x11 4 Checksum16 LSB 5 Checksum16 MSB 6 Errorcode 7 0x00 NumChannels This is the number of channels you will sample per scan 1 25 SamplesPerPacket Specifies how many samples will be pulled out of the U3 FIFO buffer and returned per data read packet For faster stream speeds 25 samples per packet are required for data transfer efficiency A small number of samples per packet 111 would be desirable for low latency data retrieval Note that this parameter is not necessarily the same as the number of channels per scan Even if only 1 channel is being scanned SamplesPerPacket will usually be set to 25 so there are usually multiple scans per packet ScanConfig Has bits to specify the stream bas clock and effective resolution Scaninterval 1 65535 This value divided by the clock frequency defined in the ScanConfig parameter gives the interval in seconds between scans PChannel NChannel For each channel
27. about 0 to 3 6 volts For the four high voltage channels on the U3 HV the special channel negative channel also puts Vref on the negative This results in an overall range of about 10 to 20 volts on the positive input 2 6 2 Converting Binary Readings to Voltages Following are the nominal input voltage ranges for the low voltage analog inputs This is all analog inputs on the U3 LV and AIN4 AIN15 on the U3 HV Max V Min V Single Ended 244 0 0 Differential 2 44 2 44 Special 0 3 6 3 6 0 0 Table 2 6 Nominal Analog Input Voltage Ranges for Low Voltage Channels 17 Max V Min V Single Ended 10 3 10 3 Differential N A N A Special 10 20 20 1 10 3 Table 2 7 Nominal Analog Input Voltage Ranges for High Voltage Channels Note that the minimum differential input voltage of 2 44 volts means that the positive channel can be as much as 2 44 volts less than the negative channel not that a channel can measure 2 44 volts less than ground The voltage of any low voltage analog input pin compared to ground must be in the range 0 3 to 3 6 volts The special range 0 3 6 on low voltage channels and 10 20 volts on high voltage channels is obtained by doing a differential measurement where the negative channel is set to the internal Vref 2 44 volts For low voltage channels simply do the low voltage differential conversion as described below then add the stored Vref value For high voltage channels do the same thing
28. bounces Some solutions to this issue are e Software Debounce If it is known that a real closure cannot occur more than once some interval then software can be used to limit the number of counts to that rate Firmware Debounce See section 2 10 1 for information about timer mode 6 Active Hardware Debounce Integrated circuits are available to debounce switch signals This is the most reliable hardware solution See the MAX6816 maxim ic com or EDE2008 elabinc com e Passive Hardware Debounce A combination of resistors and capacitors can be used to debounce a signal This is not foolproof but works fine in most applications 31 VS ur Digital Input GND Figure 2 11 Passive Hardware Debounce Figure 2 12 shows one possible configuration for passive hardware debounce First consider the case where the 1 kQ resistor is replaced by a short circuit When the switch closes it immediately charges the capacitor and the digital input sees logic low but when the switch opens the capacitor slowly discharges through the 22 kQ resistor with a time constant of 22 ms By the time the capacitor has discharged enough for the digital input to see logic high the mechanical bouncing is done The main purpose of the 1 resistor is to limit the current surge when the switch is closed 1 limits the maximum current to about 5 mA but better results might be obtained with smaller resistor values 2 8 1 4 Output Control
29. but have 50 of source impedance that will cause voltage drop To avoid this voltage drop an op amp can be used to buffer the output such as the non inverting configuration shown in Figure 2 2 A simple RC filter can be added between the DAC output and the amp input for further noise reduction Note that the ability of the amp to source sink current near the power rails must still be considered A possible op amp choice would be the TLV246x family ti com 2 7 1 2 Different Output Ranges The typical output range of the DACs is about 0 04 to 4 95 volts For other unipolar ranges an op amp in the non inverting configuration Figure 2 2 can be used to provide the desired gain For example to increase the maximum output from 4 95 volts to 10 0 volts a gain of 2 02 is required If R2 in Figure 2 3 is chosen as 100 kQ then an R1 of 97 6 kQ is the closest 1 27 resistor that provides gain greater than 2 02 The V supply for the op amp would have to be greater than 10 volts For bipolar output ranges such as 10 volts a similar op amp circuit can be used to provide gain and offset but of course the op amp must be powered with supplies greater than the desired output range depending on the ability of the op amp to drive it s outputs close to the power rails If 10 12 or 15 volt supplies are available consider using the LT1490A op amp linear com which can handle a supply span up to 44 volts A reference voltage is also req
30. constants from the device 49 Use the following line to open the first found LabJack U3 over USB and get a handle to the device The general form of the open function is OpenLabJack DeviceType ConnectionType Address FirstFound Handle Open the first found LabJack U3 over USB ingErrorcode OpenLabJack LJ_dtU3 LJ ctUSB 1 TRUE amp lngHandle Second a list of requests is built in the UD driver using AddRequest calls This does not involve any low level communication with the device and thus the execution time is relatively instantaneous Request that DACO be set to 2 5 volts The general form of the AddRequest function is AddRequest Handle IOType Channel Value x1 UserData lngErrorcode AddRequest l1ngHandle LJ ioPUT DAC 0 2 50 0 0 Request a read from AIN3 FIO3 assuming it has been enabled as an analog line ingErrorcode AddRequest l1ngHandle LJ ioGET AIN 3 0 0 0 Third the list of requests is processed and executed using a Go call In this step the driver determines which low level commands must be executed to process all the requests calls those low level functions and stores the results This example consists of two requests one analog input read and one analog output write which can both be handled in a single low level Feedback call Section 5 2 5 Execute the requests ingErrorcode GoOne lngHandle Finally GetResult calls are used to r
31. digital I O are output Direction d1048575 If FIOO FIO2 are output EIOO EIO2 are output are output and all other I O are input b000000010000011100000111 Direction d67335 5 2 5 12 PortDirWrite 29 PortDirWrite 7 Command Bytes 0 IOType 29 1 3 WriteMask 4 6 Direction 0 Response Bytes This IOType writes the direction of all digital where 0 7 FIO 8 15 EIO and 16 19 Note that the desired lines must be configured as digital not analog e WriteMask Each bit specifies whether to update the corresponding bit of I O e Direction Each bit of this value corresponds to the specified bit of I O such that 1 Output and 0 Input To configure all as input Direction dO For all 20 standard digital I O as output Direction d1048575 To configure FIOO FIO2 as output EIOO 104 ElO2 as output CIOO as output and all other I O as input b000000010000011100000111 Direction d67335 5 2 5 13 DAC 8 bit lOType 34 35 DAC 8 bit 2 Command Bytes 0 lOType 34 35 1 Value Response Bytes This IOType controls a single analog output e Value O Minimum 255 Maximum 5 2 5 14 DACH 16 bit IOType 38 39 DAC 16 bit 3 Command Bytes 0 IOType 38 39 1 Value LSB 2 Value MSB 0 Response Bytes This IOType controls a single analog output e Value O Minimum 65535 Maximum 5 2 5 15 Timer lOType 42 44 Timer 4 Command Bytes 0 IOType 42 44 1 Bit 0 UpdateReset 2 Value LSB 3 Va
32. extended command 16 bit checksum Get the subarray consisting of bytes 6 and up Convert bytes to U16 and sum into a U16 accumulator can t overflow Then do the following for the 8 bit extended checksum Get the subarray consisting of bytes 1 through 5 Convert bytes to U16 and sum into a U16 accumulator Divide by 2 8 and sum the quotient and remainder Divide by 2 8 and sum the quotient and remainder Destination bit This bit specifies whether the command is destined for the local or remote target This bit is ignored on the U3 Multi byte parameters In the following function definitions there are various multi byte parameters The least significant byte of the parameter will always be found at the lowest byte number For instance bytes 10 through 13 of CommConfig are the IP address which is 4 bytes long Byte 10 is the least significant byte LSB and byte 13 is the most significant byte MSB Masks Some functions have mask parameters The WriteMask found in some functions specifies which parameters are to be written If a bit is 1 that parameter will be updated with the new passed value If a bit is 0 the parameter is not changed and only a read is performed The AINMask found in some functions specifies which analog inputs are acquired This is a 16 bit parameter where each bit corresponds to AINO AIN15 If a bit is 1 that channel will be acquired The digital I O masks such as FlOMask specify that the pas
33. from flowing on the ground Use a small wattage resistor typically 1 8 or 1 4 watt so that it blows if too much current does flow The only current that should flow on the ground is the return of the analog input bias current which is only microamps The SGND terminals on the same terminal block as SPC can be used instead of GND for externally powered signals A series resistor is not needed as SGND is fused to prevent overcurrent but a resistor will eliminate confusion that can be caused if the fuse is tripping and resetting In general if there is uncertainty a good approach is to use a DMM to measure the voltage on each signal ground wire without any connections to the U3 If no large voltages are noted connect the ground to U3 SGND with a 100 O series resistor Then again use the DMM to measure the voltage of each signal wire before connecting to the U3 Another good general rule is to use the minimum number of ground connections For instance if connecting 8 sensors powered by the same external supply or otherwise referred to the same external ground only a single ground connection is needed to the U3 Perhaps the ground leads from the 8 sensors would be twisted together and then a single wire would be connected to a 100 resistor which is connected to U3 ground 2 6 3 5 Amplifying small signal voltages The best results are generally obtained when a signal voltage spans the full analog input range of the LabJack If the signal
34. information All the digital I O include an internal series resistor that provides overvoltage short circuit protection These series resistors also limit the ability of these lines to sink or source current Refer to the specifications in Appendix A 28 All digital on the U3 have possible states input output high or output low Each bit of I O can be configured individually When configured as an input a bit has a 100 pull up resistor to 3 3 volts all digital I O are 5 volt tolerant When configured as output high a bit is connected to the internal 3 3 volt supply through a series resistor When configured as output low a bit is connected to GND through a series resistor The power up condition of the digital I O can be configured by the user From the factory all digital I O are configured to power up as inputs Note that even if the power up default for a line is changed to output high or output low there is a delay of about 5 ms at power up where all digital I O are in the factory default condition The low level Feedback function Section 5 2 5 writes and reads all digital I O For information about using digital under the Windows LabJackUD driver see Section 4 3 5 See Section 3 1 for timing information Many function parameters contain specific bits within a single integer parameter to write read specific information In particular most digital parameters contain the information for each bit of I
35. into the code The first type of constant is an which is always passed in the IOType parameter of a function call One example of an IOType is the constant 2 ioPur pac which is used to update the value of an analog output DAC The second type of constant is a Channel Constant also called a Special Channel These constants are always passed in the Channel parameter of a function call For the most part these are used when a request is not specific to a particular channel and go with the configuration lOTypes nz ioPuT LJ_ioGET_CONFIG One example of a Special Channel is the constant 2 cnrzocarrp which is used to write or read the local ID of the device The third major type of constant used by the UD driver is a Value Constant These constants are always passed in the Value parameter of a function call One example of a Value Constant is the constant 27 8 which specifies a timer mode This constant has a numeric value of 1 which could be passed instead but using the constant makes for programming code that is easier to read Following is pseudocode that performs various actions First a call is done to open the device The primary work done with this call is finding the desired device and creating a handle that points to the device for further function calls In addition opening the device performs various configuration and initialization actions such as reading the calibration
36. is the output from a 3 3 volt regulator The DACs are derived from PWM signals that are affected by the timer clock frequency Section 2 9 The default timer clock frequency of the U3 is set to 48 MHz and this results in the minimum DAC output noise If the frequency is lowered the DACs will have more noise where the frequency of the noise is the timer clock frequency divided by 2 This effect is more exaggerated with the 10 bit DACs on hardware revision 1 30 compared to the 8 bit DACs on previous hardware revisions The noise with a timer clock of 48 12 4 1 MHz is roughly 5 20 100 600 mV If lower noise performance is needed at lower timer clock frequencies use the power up default setting in LJControlPanel to force the device to use 8 bit DAC mode uses the low level CompatibilityOptions byte documented in Section 5 2 2 A large capacitor at least 220 uF from DACn to GND can also be used to reduce noise The analog outputs have filters with a 3 dB cutoff around 16 Hz limiting the frequency of output waveforms to less than that 26 The analog output commands are sent as raw binary values low level functions For a desired output voltage the binary value can be approximated as Bits uncalibrated Volts 4 95 256 For a proper calculation though use the calibration values Slope and Offset stored in the internal flash on the processor Table 2 7 Bits Slope Volts Offset The previous apply when using the origina
37. not valid with DAC1 enabled When DAC1 is enabled the slope offset calibration constants are not used to convert raw readings to voltages Rather the Vreg value is retrieved from the Mem area and used with the approximate single ended or differential conversion equations above where Span is Vreg single ended or 2Vreg differential 2 6 3 Typical Analog Input Connections A common question is can this sensor signal be measured with the U3 Unless the signal has a voltage referred to U3 ground beyond the limits in Appendix A it can be connected without damaging the U3 but more thought is required to determine what is necessary to make useful measurements with the U3 or any measurement device Voltage versus ground The single ended analog inputs on the U3 measure a voltage with respect to U3 ground The differential inputs measure the voltage difference between two channels but the voltage on each channel with respect to ground must still be within the common mode limits specified in Appendix A When measuring parameters other than voltage or voltages too big or too small for the U3 some sort of sensor or transducer is required to produce the proper voltage signal Examples are a temperature sensor amplifier resistive voltage divider or perhaps a combination of such things Impedance When connecting the U3 or any measuring device to a signal source it must be considered what impact the measuring device will have on the si
38. of execution of the request list cannot be predicted Since the driver does internal optimization it is quite likely not the same as the order of AddRequest function calls One thing that is known is that configuration settings like ranges stream settings and such will be done before the actual acquisition or setting of outputs Declaration LJ ERROR stdcall Go Parameter Description Returns LabJack errorcodes or O for no error Inputs e None Outputs e None 4 2 7 GoOne After using AddRequest to make an internal list of requests to perform call GoOne to actually perform the requests This function causes all requests on one particular LabJack to be performed After calling GoOne call GetResult or similar to retrieve any returned data or errors GoOne can be called repeatedly to repeat the current list of requests GoOne does not clear the list of requests Rather after a particular device has performed a GoOne the first subsequent AddRequest call to that device will clear the previous list of requests on that particular device only Note that for a single Go or GoOne call the order of execution of the request list cannot be predicted Since the driver does internal optimization it is quite likely not the same as the order of AddRequest function calls One thing that is known is that configuration settings like ranges stream settings and such will be done before the actual acquisition or se
39. open is the same as below except for const char pDeviceType const char pConnectionType Declaration LJ ERROR _stdcall ListAll long DeviceType long ConnectionType long pNumFound long pSerialNumbers long pIDs double pAddresses Parameter Description Returns LabJack errorcodes or for no error Inputs e DeviceType The type of LabJack to search for Constants are in the labjackud h file 54 e ConnectionType Enter the constant for the type of connection to use in the search Currently only USB is supported for this function e pSerialNumbers Must pass a pointer to a buffer with at least 128 elements e plDs Must pass a pointer to a buffer with at least 128 elements e pAddresses Must pass a pointer to a buffer with at least 128 elements Outputs e pNumFound Returns the number of devices found and thus the number of valid elements in the return arrays e pSerialNumbers Array contains serial numbers of any found devices e plIDs Array contains local IDs of any found devices e pAddresses Array contains IP addresses of any found devices The function DoubleToStringAddress is useful to convert these to string notation 4 2 2 OpenLabJack Call OpenLabJack before communicating with a device This function can be called multiple times however once a LabJack is open it remains open until your application ends or the DLL is unloaded If OpenLabJack is called repeated
40. plus 0 7 data words Extended 3 command words plus 0 125 data words Normal commands have a smaller packet size and can be faster in some situations Extended commands provide more commands better error detection and a larger maximum data payload Normal command format Byte 0 Checksume8 Includes bytes 1 15 1 Command Byte DCCCCWWW Bit 7 Destination bit 0 Local 1 Remote Bits 6 3 Normal command number 0 14 Bits 2 0 Number of data words 2 15 Data words Extended command format Byte 0 Checksum8 Includes bytes 1 5 1 Command Byte D1111CCC Bit 7 Destination bit 0 Local 1 Remote Bits 6 3 1111 specifies that this is an extended command Bits 2 0 Used with some commands 2 Number of data words 3 Extended command number 4 Checksum16 LSB 5 Checksum16 MSB 6 255 Data words 89 Checksum calculations All checksums are a 1 s complement checksum Both the 8 bit and 16 bit checksum are unsigned Sum all applicable bytes in an accumulator 1 at a time Each time another byte is added check for overflow carry bit and if true add one to the accumulator In a high level language do the following for the 8 bit normal command checksum Get the subarray consisting of bytes 1 and up Convert bytes to U16 and sum into a U16 accumulator Divide by 2 8 and sum the quotient and remainder Divide by 2 8 and sum the quotient and remainder In a high level language do the following for an
41. rev 1 304 ePut lngHandle LJ ioPUT ANALOG ENABLE PORT 0 0 16 15 or with a single request to the following IOType created exactly for this purpose ePut lngHandle LJ ioPIN CONFIGURATION RESET 0 0 0 2 6 AIN The LabJack has up to 16 analog inputs available on the flexible I O lines FIOO FIO7 and EIOO EIO7 Single ended measurements be taken of any line compared to ground or differential measurements can be taken of any line to any other line Analog input resolution is 12 bits The range of single ended analog inputs is normally about 0 2 44 and there is a special 0 3 6 volt range available The range of differential analog inputs is typically 2 4 volts but is pseudobipolar not true bipolar The difference positive channel minus negative channel can be 2 4 volts but neither input can have a voltage less than 0 3 volts to ground For valid measurements the voltage on every low voltage analog input pin with respect to ground must be within 0 3 to 3 6 volts See Appendix A for voltage limits to avoid damage On the U3 HV compared to the LV the first four flexible I O are fixed as analog inputs AINO AIN3 and have scaling such that the input range is a true bipolar 10 volts normally and 10 to 20 volts when using the special range The input impedance of these four lines is roughly 1 MO which is good but less than the normal low voltage analog inputs Analog digital co
42. signal sources might require a load with higher resistance in which case a buffer should be used The following figure shows a resistive voltage divider followed by an op amp configured as non inverting unity gain i e a buffer V R1 Vin 1 R2 V hd AINx GND Figure 2 4 Buffered Voltage Divider Circuit The op amp is chosen to have low input bias currents so that large resistors can be used in the voltage divider For 0 5 volt applications where the amp will be powered from Vs and GND a good choice would be the OPA344 from Texas Instruments ti com The OPA344 has a very small bias current that changes little across the entire voltage range Note that when powering the amp from Vs and GND the input and output to the op amp is limited to that range so if Vs is 4 8 volts your signal range will be 0 4 8 volts The information above also applies to resistance measurement A common way to measure resistance is to build a voltage divider as shown in Figure 2 4 where one of the resistors is known and the other is the unknown If Vin is known and Vout is measured the voltage divider equation can be rearranged to solve for the unknown resistance 2 6 3 7 Measuring current including 4 20 mA with a resistive shunt The following figure shows a typical method to measure the current through a load or to measure the 4 20 mA signal produced by a 2 wire loop powered current loop sensor The current shunt s
43. these two parameters specify the positive and negative voltage measurement point PChannel is 0 7 for FIOO FIO7 8 15 for EIOO EIO15 30 for temp sensor 31 for Vreg or 193 224 for digital timer counter channels NChannel is 0 7 for FIOO FIO7 8 15 for EIOO EIO15 30 for Vref 31 for single ended 112 5 2 11 StreamStart Once the stream settings are configured this function is called to start the stream Requires U3 hardware version 1 21 Command Byte 0 0xA8 1 OxA8 Response Byte 0 Checksum8 1 OxA9 2 Errorcode 3 0x00 113 5 2 12 StreamData After starting the stream the data will be sent as available in the following format Reads oldest data from buffer Requires U3 hardware version 1 21 Response Byte 0 Checksum8 1 OxF9 2 4 SamplesPerPacket 3 0xCO 4 Checksum16 LSB 5 Checksum16 MSB 6 9 TimeStamp 10 PacketCounter 11 Errorcode 12 13 Sampled 62 max Backlog 63 max 0x00 SamplesPerPacket From StreamConfig function e TimeStamp Not currently implemented during normal operation but after auto recovery this reports the number of packets missed 1 65535 e PacketCounter An 8 bit 0 255 counter that is incremented by one for each packet of data Useful to make sure packets are in order and no packets are missing e Sample Stream data is placed in a FIFO first in first out buffer so SampleO is the oldest data read from the buffer The analog input reading is returned justified as a 16 bit va
44. 0 Power up the U3 with a short from FIO6 to SPC FIO2 to SCL on U3 1 20 1 21 then remove the jumper and power cycle the device again If WriteMask is nonzero some or all default values are written to flash The U3 flash has a rated endurance of at least 20000 writes which is plenty for reasonable operation but if this function is called in a high speed loop with a nonzero WriteMask the flash could eventually be damaged Command Byte 0 Checksum8 1 OxF8 2 3 0x08 4 Checksum16 LSB 5 Checksum16 MSB 6 WriteMaskO Bit 5 CompatibilityOptions Bit 4 TimerClockConfig amp TimerClockDivisor Bit 3 LocallD Bit 2 DAC Defaults Bit 1 Digital Defaults Bit 0 Reserved 7 WriteMask1 Reserved LocallD 9 TimerCounterConfig Bits 4 7 TimerCounterPinOffset Bit 3 Enable Counter Bit 2 Enable CounterO Bits 0 1 Number of timers enabled 10 FlOAnalog 11 FlODirection 12 FlOState 13 ElOAnalog 14 ElODirection 15 ElOState 16 ClODirection 17 ClOState 18 DAC1Enable 19 DACO 20 DAC1 21 TimerClockConfig 22 TimerClockDivisor 0 256 23 CompatibilityOptions 24 0x00 25 0x00 93 Response U Checksum8 OxF8 0x10 0x08 Checksum16 LSB Checksum16 MSB Errorcode Reserved Reserved FirmwareVersion 11 12 BootloaderVersion 13 14 HardwareVersion 15 18 SerialNumber 19 20 ProductID LocallD TimerCounterMask FlOAnalog FlODirection FlOState ElOAnalog ElODirect
45. 04 204 204 255 255 255 255 0 2000000000 73 20 5 0 0 0 0 0 0 0000775030 225 122 20 110 2 0 0 0 2 4300000000 102 102 102 38 42 1 0 0 298 1500000000 Table 2 10 Fixed Point Conversion Examples 2 6 2 1 Analog Inputs With DAC1 Enabled Hardware Revisions 1 20 amp 1 21 only This Section only applies to the older hardware revisions 1 20 and 1 21 Starting with hardware revision 1 30 DAC1 is always enabled and does not affect the analog inputs 19 The previous information assumed that DAC1 is disabled If DAC1 is enabled then the internal reference Vref 2 44 volts is not available for the ADC and instead the internal regulator voltage Vreg 3 3 volts is used as the reference for the ADC Vreg is not as stable as Vref but more stable than Vs 5 volt power supply Following are the nominal input voltage ranges for the analog inputs assuming that DAC1 is enabled Max V Min V Single Ended 3 3 0 0 Differential 3 3 3 3 Special 0 3 6 N A N A Table 2 11 Nominal Analog Input Voltage Ranges DAC1 Enabled Note that the minimum differential input voltage of 3 3 volts means that the positive channel can be as much as 3 3 volts less than the negative channel not that a channel can measure 3 3 volts less than ground The voltage of any analog input pin compared to ground must be in the range 0 3 to 3 6 volts for specified performance See Appendix A for voltage limits to avoid damage Negative channel numbers 30 and 32 are
46. 1 21 That means that in the case of a single timer there should be no more than 1 edge 33 us For multiple timers all can process an edge simultaneously but if for instance both timers get an edge at the same time 66 us should be allowed before any further edges are applied If streaming is occurring at the same time the maximum edge rate will be less 7 000 per second and since each edge requires processing time the sustainable stream rates can also be reduced 2 10 SPC and SCL SDA SCA The SPC terminal is use for manually resetting default values or jumping in out of flash programming mode Hardware revision 1 20 and 1 21 had terminals labeled SCL SDA and or SCA On revision 1 20 these terminals did nothing except that SCL is used for the SPC functionality described above On revision 1 21 these terminals were used for asynchronous functionality and SCL is used for the SPC functionality described above Note that these terminals never have anything to do with lC 2 11 DB15 The DB15 connector brings out 12 additional digital I O It has the potential to be used as an expansion bus where the 8 EIO are data lines and the 4 CIO are control lines In the Windows LabJackUD driver the EIO are addressed as digital I O bits 8 through 15 and the CIO are addressed as bits 16 19 0 7 FIOO FIO7 8 15 EIOO EIO 7 16 19 40 These 12 channels include an internal series resistor that provides overvoltag
47. 2 9 1 11 Period Measurement 16 Bit Modes 12 amp 13 Similar to the 32 bit edge to edge timing modes described above modes 2 amp 3 except that hardware capture registers are used to record the edge times This limits the times to 16 bit 39 values but is accurate to the resolution of the clock and not subject to any errors due to firmware processing delays Note that the minimum measurable period is limited by the edge rate limit discussed in Section 2 9 2 2 9 2 Timer Operation Performance Notes Note that the specified timer clock frequency is the same for all timers That is TimerClockBase and TimerClockDivisor are singular values that apply to all timers Modes 0 1 2 3 4 7 12 and 13 all are affected by the clock frequency and thus the simultaneous use of these modes has limited flexibility This is often not an issue for modes 2 and 3 since they use 32 bit registers The output timer modes 0 1 and 7 are handled totally by hardware Once started no processing resources are used and other U3 operations do not affect the output The edge detecting timer input modes do require U3 processing resources as an interrupt is required to handle each edge Timer modes 2 3 5 9 12 and 13 must process every applicable edge rising or falling Timer modes 4 and 8 must process every edge rising and falling To avoid missing counts keep the total number of processed edges all timers less than 30 000 per second hardware V
48. 2 kQ or less to make sure the voltage on the I O line when low is pulled below 0 8 volts The other possible consideration with the basic push pull signal is the ground connection If the signal is known to already have a common ground with the U3 then no additional ground connection is used If the signal is known to not have a common ground with the U3 then the signal ground can simply be connected to U3 GND If there is uncertainty about the relationship between signal ground and U3 ground e g possible common ground through AC mains then a ground connection with a 10 series resistor is generally recommended see Section 2 7 3 4 29 Rseries Push Pull Digital Signal Input Ei Rground GND or round SGND Figure 2 8 Driven Signal Connection To Digital Input Figure 2 8 shows typical connections Rground is typically 0 100 Rseries is typically 0 Q short circuit for 3 3 5 volt logic or 22 max for high voltage logic Note that an individual ground connection is often not needed for every signal Any signals powered by the same external supply or otherwise referred to the same external ground should share a single ground connection to the U3 if possible When dealing with a new sensor a push pull signal is often incorrectly assumed when in fact the sensor provides an open collector signal as described next 2 8 1 2 Input Open Collector Signals Open collector also called open drain or NPN is a very commo
49. Address and ConnectionType parameters are ignored and the driver opens the first LabJack found with the specified DeviceType Generally only recommended when a single LabJack is connected Currently only supported with USB If a USB device is not found it will try Ethernet but with the given Address Outputs 55 e pHandle A pointer to a handle for a LabJack 4 2 3 eGet and ePut The eGet and ePut functions do AddRequest Go and GetResult in one step The eGet versions are designed for inputs or retrieving parameters as they take a pointer to a double where the result is placed but can be used for outputs if pValue is preset to the desired value This is also useful for things like StreamRead where a value is input and output number of scans requested and number of scans returned The ePut versions are designed for outputs or setting configuration parameters and will not return anything except the errorcode eGetS and ePutS are special versions of these functions where is a string rather than a long This is useful for passing string constants in languages that cannot include the header file and is generally used with all IOTypes except put get config The string should contain the constant name as indicated in the header file such as LJ ioANALOG INPUT The declarations for the S versions are the same as the normal versions except for const char plOType eGetSS and ePutSS are special ver
50. C and Digital I O Sections for more information about grounding 2 4 Vs The Vs terminals are designed as outputs for the internal supply voltage nominally 5 volts This will be the voltage provided from the USB cable The Vs connections are outputs not inputs Do not connect a power source to Vs in normal situations All Vs terminals are the same 2 5 Flexible FIO EIO The first 16 I O lines FIO and EIO ports on the LabJack U3 can be individually configured as digital input digital output or analog input In addition up to 2 of these lines can be configured as timers and up to 2 of these lines can be configured as counters If a line is configured as analog it is called AINx according to the following table 14 AINO FIOO AIN8 EIO0 AIN1 FIO1 AIN9 EIO1 AIN2 FIO2 AIN10 2 AIN3 FIO3 AIN11 AIN4 FIO4 AIN12 ElO4 AIN5 FIO5 AIN13 EIO5 AIN6 FIO6 AIN14 EIOG AIN7 FIO7 AIN15 EIO7 Table 2 1 Analog Input Pin Locations On the U3 HV compared to the LV the first four flexible I O are fixed as analog inputs AINO AIN3 with a nominal 10 volt input range A digital operations including analog digital configuration are ignored on these 4 fixed analog inputs Timers and counters can appear on various pins but other I O lines never move For example Timer1 can appear anywhere from FIO4 to EIO1 depending on TimerCounterPinOffset and whether TimerO is enabled On the other hand FIO5 for example is always on th
51. FIG LJI_chSWDT_DISABLE 0 0 84 4 3 14 Miscellaneous The following are special channels used with the get put config OTypes to read write the calibration memory and user memory LJ chCAL CONSTANTS LJ chUSER MEM For more information see the low level descriptions in Sections 5 2 6 5 2 8 and see the Memory example in the VC6 LJUD archive The following wait IOType is used to create a delay between other actions LJ ioPUT WAIT Channel ignored Value 0 8388480 microseconds Actual resolution is 128 microseconds Any value in microseconds from 0 8388480 can be passed but the actual resolution is 128 microseconds This is typically used to put a small delay between two actions that will execute in the same low level Feedback command It is useful when the desired delay is less than what can be accomplished through software For example a 1 024 millisecond pulse can be created by executing a single Add Go Get block that sequentially requests to set FIO4 to output high wait 1024 microseconds then set FIO4 to output low 85 4 4 Errorcodes All functions return an LJ ERROR errorcode as listed in the following tables Errorcode Name 2 1 LJE UNABLE TO READ CALDATA LJE DEVICE NOT CALIBRATED LJE NOERROR LJE INVALID CHANNEL NUMBER LJE INVALID RAW INOUT PARAMETER LJE UNABLE TO START STREAM LJE UNABLE TO STOP STREAM LJE NOTHING TO STREAM LJE UNABLE TO CONFIG STREAM LJE_BUFFER_OVERRUN LJE STREAM
52. ID for the U3 is 0x0003 The USB interface consists of the normal bidirectional control endpoint 0 OUT amp IN 3 used bulk endpoints 1 OUT 2 IN 3 IN and 1 dummy endpoint 3 OUT Endpoint 1 consists of a 64 byte OUT endpoint address 0x01 Endpoint 2 consists of a 64 byte IN endpoint address 0x82 Endpoint consists of a dummy OUT endpoint address 0x03 and a 64 byte IN endpoint address 0x83 Endpoint 3 OUT is not supported by the firmware and should never be used All commands should always be sent on Endpoint 1 and the responses to commands will always be on Endpoint 2 Endpoint 3 is only used to send stream data from the U3 to the host 2 2 Status LED There is a green status LED on the LabJack U3 This LED blinks on reset and then remains steadily lit Other LED behavior is generally related to flash upgrade modes Section 1 2 2 3 GND and SGND The GND connections available at the screw terminals and DB connectors provide a common ground for all LabJack functions This ground is the same as the ground line on the USB connection which is often the same as ground on the PC chassis and therefore AC mains ground SGND is located near the upper left of the device This terminal has a self resetting thermal fuse in series with GND This is often a good terminal to use when connecting the ground from another separately powered system that could unknowingly already share a common ground with the U3 See the AIN DA
53. ING TIME LongSettling enabled if TRUE LJ chAIN BINARY Following is example pseudocode to read analog inputs Execute the pin configuration reset IOType so that all pin assignments are in the factory default condition The ePut function is used which combines the add go get ePut lngHandle LJ ioPIN CONFIGURATION RESET 0 0 0 Configure FIO1 FIO2 and FIO6 as analog all others as digital see Section 4 3 2 The ePut function is used which combines the add go get ePut lngHandle LJ ioPUT ANALOG ENABLE PORT 0 70 16 Now an add go get block to execute multiple requests Request a single ended read from AIN2 AddRequest l1ngHandle LJ ioGET AIN 2 0 0 0 Request a differential read of AIN1 AIN6 AddRequest lngHandle LJ ioGET AIN DIFF 1 0 6 0 Request a differential read of AINI Vref AddRequest l1ngHandle LJ ioGET AIN DIFF 1 0 30 0 Request a single ended read of AINI AddRequest l1ngHandle LJ ioGET AIN DIFF 1 0 31 0 Request a read of AIN1 using the special 0 3 6 volt range AddRequest lngHandle LJ ioGET AIN DIFF 1 0 32 0 Execute the requests GoOne l1ngHandle Since multiple requests were made with the same IOType and Channel and only x1 was different GetFirst GetNext must be used to retrieve the results The simple GetResult function does not use the x1 parameter and thus there is no way to specify which result is desired
54. INVALID CONNECTION TYPE LJE INVALID MODE Table 4 3 Group Level Errorcodes Description Errors above this number stop all requests Unrecognized error that is caught AddRequest called even though Open failed GetResult called without calling a Go function or a channel is passed that was not in the request list LabJack not found at the given id or address Unable to send or receive the correct number of bytes The first two tables list errors which are specific to a request For example LJE INVALID CHANNEL NUMBER If this error occurs other requests are not affected The last table lists errors which cause all pending requests for a particular Go to fail with the same error If this type of error is received the state of any of the request is not known For example if requests are executed with a single Go to set the AIN range and read an AIN and the read fails with an LJE COMM FAILURE it is not known whether the AIN range was set to the new value or whether it is still set at the old value 88 5 Low Level Function Reference This section describes the low level functions of the U3 These are commands sent over USB directly to the processor on the U3 The majority of Windows users will use the high level UD driver rather than these low level functions 5 1 General Protocol Following is a description of the general U3 low level communication protocol There are two types of commands Normal 1 command word
55. INX Current Ex Shunt Supply 7 0 100 SGND Figure 2 6 Current Measurement With 3 Wire 4 20 mA Sourcing Sensor The sensor shown in Figure 2 6 is a sourcing type where the signal sources the 4 20 mA current which is then sent through the shunt resistor and sunk into ground Another type of 3 wire sensor is the sinking type where the 4 20 mA current is sourced from the positive supply sent through the shunt resistor and then sunk into the signal wire If sensor ground is connected to U3 ground the sinking type of sensor presents a problem as at least one side of the resistor has a high common mode voltage equal to the positive sensor supply If the sensor is isolated a possible solution is to connect the sensor signal or positive sensor supply to U3 ground instead of sensor ground This requires a good understanding of grounding and isolation in the system The LJTick CurrentShunt is often a simple solution Both Figure 2 5 and 2 6 show a 0 100 resistor in series with SGND which is discussed in general in Section 2 6 3 4 In this case if SGND is used rather than GND a direct connection 0 should be good The best way to handle 4 20 mA signals is with the LJTick CurrentShunt which is a two channel active current to voltage converter module that plugs into the U3 screw terminals More information is available at labjack com 2 6 3 8 Floating Unconnected Inputs The reading from a floating no external conne
56. J ioPIN CONFIGURATION RESET 0 0 0 Now an add go get block to execute multiple requests Request a read from FIO2 AddRequest lngHandle LJ ioGET DIGITAL BIT 2 0 0 0 Request a read from FIO4 EIO5 10 bits starting from digital channel 4 AddRequest lngHandle LJ ioGET DIGITAL PORT 4 0 10 0 Set FIO3 to output high AddRequest lngHandle LJ ioPUT DIGITAL 3 1 0 0 Set EIO6 CIO2 5 bits starting from digital channel 14 to b10100 d20 That is EIO6 0 EIO7 0 CIOO0 1 CIO1 0 and CIO2 1 AddRequest lngHandle LJ ioPUT DIGITAL PORT 14 20 5 0 Execute the requests GoOne l1ngHandle Get the FIO2 read GetResult l1ngHandle LJ ioGET DIGITAL 2 amp dblValue Get the FIO4 EIO5 read GetResult l1ngHandle LJ ioGET DIGITAL PORT 4 amp dblValue 4 3 6 Timers amp Counters There are eight IOTypes used to write or read timer and counter information LJ ioGET COUNTER LJ ioPUT COUNTER ENABLE LJ ioGET COUNTER ENABLE LJ ioPUT COUNTER RESET LJ ioGET TIMER LJ ioPUT TIMER VALUE LJ ioPUT TIMER MODE LJ ioGET TIMER MODE In addition to specifying the channel number the following mode constants are passed in the value parameter when doing a request with the timer mode LJ tmPWM16 16 bit PWM output LJ tmPWM8 8 bit PWM output LJ tmRISINGEDGES32 Period input 32 bit rising edges LJ tmFALLINGEDGES32 Period input 32 bit
57. M INVALID STREAM BIPOLAR GAIN INVALID STREAM SCAN RATE INVALID STREAM AUTORECOVER ACTIVE STREAM AUTORECOVER REPORT STREAM AUTORECOVER OVERFLOW 126 Errorcodes Continued TIMER INVALID MODE TIMER QUADRATURE AB ERROR TIMER QUAD PULSE SEQUENCE TIMER BAD CLOCK SOURCE TIMER STREAM ACTIVE TIMER PWMSTOP MODULE ERROR TIMER SEQUENCE ERROR TIMER LINE SEQUENCE ERROR TIMER SHARING ERROR EXT OSC NOT STABLE INVALID POWER SETTING PLL NOT LOCKED INVALID PIN PIN CONFIGURED FOR ANALOG PIN CONFIGURED FOR DIGITAL SYNCH ERROR INVALID OFFSET VALID PIN OFFSET MUST 4 8 127 A Specifications Specifications at 25 degrees C and Vusb Vext 5 0V except where noted Parameter Conditions Min Typical Units _ General USB Cable Length meters Supply Voltage volts Supply Current 1 Hardware V1 21 mA Operating Temperature C Clock Error 40 to 85 C Typ Command Execution Time 2 USB high high ms USB other ms Vs Outputs Typical Voltage 3 Self Powered Bus Powered Maximum Current 3 Self Powered Bus Powered 1 Typical current drawn by the U3 itself not including any user connections 2 Total typical time to execute a single Feedback function with no analog inputs Measured by timing a Windows application that performs 1000 calls to the Feedback function See Section 3 1 for more timing information 3 These specifications are rel
58. M output starts by setting the digital line to output low for the specified amount of time The output does not necessarily start instantly but rather waits for the internal clock to roll For example if the PWM frequency is 100 Hz that means the period is 10 milliseconds and thus after the command is received by the device it could be anywhere from 0 to 10 milliseconds before the start of the PWM output 2 9 1 2 PWM Output 8 Bit Mode 1 Outputs a pulse width modulated rectangular wave output Value passed should be 0 65535 and determines what portion of the total time is spent low out of 65536 total increments The lower byte is actually ignored since this is 8 bit PWM That means the duty cycle can be varied from 100 0 out of 65536 are low to 0 4 65280 out of 65536 are low The overall frequency of the PWM output is the clock frequency specified by TimerClockBase TimerClockDivisor divided by 28 The following table shows the range of available PWM frequencies based on timer clock settings PWMB8 Frequency Ranges TimerBaseClock Divisor 1 Divisor 256 0 4 MHz 15625 00 N A 1 12 MHz 46875 00 N A 2 48 MHz Default 187500 00 N A 3 1 MHz Divisor 3906 25 15 259 4 4 MHz Divisor 15625 00 61 035 5 12 MHz Divisor 46875 00 183 105 6 48 MHz Divisor 187500 00 732 422 Note that the clocks above apply to the U3 hardware revision 1 21 With hardware revision 1 20 all clocks are half of those values The same clock applies to all timer
59. O in one integer where each bit of I O corresponds to the same bit in the parameter e g the direction of FIOO is set in bit of parameter FlODir For instance the low level function ConfigU3 the parameter FlODirection is a single byte 8 bits that writes reads the power up direction of each of the 8 FIO lines if FlODirection is 0 all FIO lines are input if FlODirection is 1 2 FIOO is output FIO1 FIO7 are input if FlODirection is 5 2 2 FIOO and FIO2 are output all other FIO lines are input if FlODirection is 255 2 2 FIOO FIO7 are output 2 8 1 Typical Digital Connections 2 8 1 1 Input Driven Signals The most basic connection to a U3 digital input is a driven signal often called push pull With a push pull signal the source is typically providing a high voltage for logic high and zero volts for logic low This signal is generally connected directly to the U3 digital input considering the voltage specifications in Appendix A If the signal is over 5 volts it can still be connected with a series resistor The digital inputs have protective devices that clamp the voltage at GND and VS so the series resistor is used to limit the current through these protective devices For instance if a 24 volt signal is connected through a 22 kQ series resistor about 19 volts will be dropped across the resistor resulting in a current of 1 1 mA which is no problem for the U3 The series resistor should be 2
60. OO AddRequest lngHandle LJ ioPUT CONFIG LJ chSPI CLK PIN NUM 0 0 0 Set CS to 1 AddRequest lngHandle LJ ioPUT CONFIG LJ chSPI CS PIN NUM 1 0 0 Execute the configuration requests GoOne lngHandle Following is pseudocode to do the actual SPI communication Transfer the data eGet lngHandle LJ ioSPI COMMUNICATION 0 amp numBytesToTransfer array 4 3 11 2 Serial Communication The U3 hardware version 1 21 only supports Inter Integrated Circuit I C or 12C communication as the master only is a synchronous serial protocol typically used to communicate with chips that support as slave devices Any 2 digital I O lines are used for SDA and SCL Note that the I C bus generally requires pull up resistors of perhaps 4 7 from SDA to Vs and SCL to Vs and also note that the screw terminals labeled SDA and SCL if present are not used for l C This serial link is not an alternative to the USB connection Rather the host application will write read data to from the U3 over USB and the USB communicates with some other device using the serial protocol Using this serial protocol is considered an advanced topic A good knowledge of the protocol is recommended and a logic analyzer or oscilloscope might be needed for troubleshooting There is one IOType used to write read I C data LJ ioI2C COMMUNICATION The following are special channels used with the 1 C IOType above LJ chlI2C READ Value
61. OxBO Response Byte 0 Checksum8 1 OxB1 2 Errorcode 3 0x00 115 5 3 14 Watchdog Requires U3 hardware version 1 21 Controls a firmware based watchdog timer Unattended systems requiring maximum up time might use this capability to reset the U3 or the entire system When any of the options are enabled an internal timer is enabled which resets on any incoming USB communication If this timer reaches the defined TimeoutPeriod before being reset the specified actions will occur Note that while streaming data is only going out so some other command will have to be called periodically to reset the watchdog timer If the watchdog is accidentally configured to reset the processor with a very low timeout period such as 1 second it could be difficult to establish any communication with the device In such a case the reset to default jumper can be used to turn off the watchdog sets bytes 7 10 to 0 Power up the U3 with a short from FIO6 to SPC FIO2 to SCL on U3 1 20 1 21 then remove the jumper and power cycle the device again This also affects the parameters in the ConfigU3 function The watchdog settings bytes 7 10 are stored in non volatile flash memory so every call to this function where settings are written causes a flash erase write The flash has a rated endurance of at least 20000 writes which is plenty for reasonable operation but if this function is called in a high speed loop the flash could be damaged Command Byte 0
62. SWDT DISABLE The following are special channels used with the put config IOType to configure watchdog options These parameters cause settings to be updated in the driver only The settings are not actually sent to the hardware until the ioswpr cowrrc above is used LJ chSWDT RESET DEVICE LJ chSWDT UDPATE DIOA LJ chSWDT DIOA CHANNEL LJ chSWDT DIOA STATE Following is example pseudocode to configure and enable the watchdog Initialize EIO2 to output low which also forces the direction to output It would probably be better to do this by configuring the power up defaults AddRequest lngHandle LJ ioPUT DIGITAL BIT 10 0 0 0 Specify that the device should be reset on timeout AddRequest lngHandle LJ ioPUT CONFIG LJ chSWDT RESET DEVICE 1 0 0 Specify that the state of the digital line should be updated on timeout AddRequest lngHandle LJ ioPUT CONFIG LJ chSWDT UDPATE DIOA 1 0 0 Specify that EIO2 is the desired digital line AddRequest lngHandle LJ ioPUT CONFIG LJ chSWDT DIOA CHANNEL 10 0 0 Specify that the digital line should be set high AddRequest lngHandle LJ ioPUT CONFIG LJ chSWDT DIOA STATE 1 0 0 Enable the watchdog with a 60 second timeout AddRequest lngHandle LJ ioSWDT CONFIG LJ chSWDT ENABLE 60 0 0 Execute the requests GoOne 1ngHandle Following is pseudocode to disable the watchdog Disable the watchdog ePut lngHandle LJ ioSWDT CON
63. TYPE SYNCH ERROR 50 LJE INVALID OFFSET 51 LJE FEEDBACK IOTYPE NOT VALID 52 LJE SHT CRC 53 LJE SHT MEASREADY 54 LJE SHT ACK 55 LJE SHT SERIAL RESET 56 LJE SHT COMMUNICATION 57 LJE AIN WHILE STREAMING 58 LJE STREAM TIMEOUT 60 LJE STREAM SCAN OVERLAP 61 LJE FIRMWARE VERSION IOTYPE 62 LJE FIRMWARE VERSION CHANNEL 63 LJE FIRMWARE VERSION VALUE 64 LJE HARDWARE VERSION IOTYPE 65 LJE HARDWARE VERSION CHANNEL 66 LJE HARDWARE VERSION VALUE 67 LJE CANT CONFIGURE PIN FOR ANALOG 68 LJE CANT CONFIGURE PIN FOR DIGITAL 70 LJE TC PIN OFFSET MUST BE 4 TO 8 Table 4 2 Request Level Errorcodes Part 2 Description AIN not available to command response functions while the 9 is streaming New scan started before the previous scan completed Scan rate is too high IOType not supported with this firmware Channel not supported with this firmware Value not supported with this firmware IOType not supported with this hardware Channel not supported with this hardware Value not supported with this hardware 87 Errorcode 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 LJE MIN GROUP ERROR LJE UNKNOWN ERROR LJE INVALID DEVICE TYPE LJE INVALID HANDLE LJE DEVICE NOT OPEN LJE NO DATA AVAILABLE LJE NO MORE DATA AVAILABLE LJE LABJACK NOT FOUND LJE COMM FAILURE LJE CHECKSUM ERROR LJE DEVICE ALREADY OPEN LJE COMM TIMEOUT LJE USB DRIVER FOUND LJE
64. To Loading Source Impedance Short Circuit Current 2 Slew Rate Digital I O Timers Counters Low Level Input Voltage High Level Input Voltage Maximum Input Voltage 3 Output Low Voltage 4 FIO EIO CIO EIO CIO Output High Voltage 4 FIO EIO CIO EIO CIO Short Circuit Current 4 Output Impedance 4 No Load 2 5 mA 5 to 9596 FS 100 pA imA Max to GND FIO EIO CIO No Load Sinking 1 mA Sinking 1 mA Sinking 5 mA No Load Sourcing 1 mA Sourcing 1 mA Sourcing 5 mA FIO EIO CIO FIO volts volts bits 96 FS counts counts 96 96 Q mA EIO CIO Counter Input Frequency 5 Hardware V1 21 Input Timer Total Edge Rate 6 No Stream V1 21 edges s While Streaming edges s 1 Maximum and minimum analog output voltage is limited by the supply voltages Vs and GND The specifications assume Vs is 5 0 volts Also the ability of the DAC output buffer to drive voltages close to the power rails decreases with increasing output current but in most applications the output is not sinking sourcing much current as the output voltage approaches GND 2 Continuous short circuit will not cause damage 3 Maximum voltage to avoid damage to the device Protection works whether the device is powered or not but continuous voltages over 5 8 volts or less than 0 3 volts are not recommened when the U3 is unpowered as the voltage will attempt to supply operating power to the U3 possibly causing poor start
65. U3 defaults These are the values that will be loaded by the U3 at power up or reset The factory defaults as shown above are all lines configured as digital input Figure 1 3 shows the U3 test window This window continuously once per second writes to and reads from the selected LabJack AN U3 Test Panel Flexible 1 0 res AIN DI DO Neg Channel AIN 2 State Neg Channel Channels Channels AINO AIN2 AINS FIO4 105 FIO 0 410 00 0 299 EIO1 0 281 EI02 0 283 03 Iv EIO4 v EIO5 Iv EIOS Iv v e JE MEE JEN 9 2 2 EC 2 ie 1 d d 9 4 4 un oi 3 ia ua Oi Timers and Counters Voltage Degrees C yas Wreg Stored 3 427 Temp 26 410 Vreg Measured 3 467 Timer 1 Lines Direction Counter 0 Analog Outputs rrrr DACO Counter 1 0 000 oo 01 02 03 Checked Output fess VRRP d 00 01 02 03 Last Error Checked High Figure 1 3 LJControlPanel U3 Test Window Timer 0 Selecting Options gt Settings from the main LJControlPanel menu brings up the window shown in Figure 1 4 This window allows some features to of the LJControlPanel application to be customized Al Settings Search LabJack IP Search for USB devices Addresses Search for Ethernet devices using UDP broadcast packet Search for Ethernet devices using specified IP
66. UTempk double pTCTempk Parameter Description Returns LabJack errorcodes or for no error Inputs e TCType A constant that specifies the thermocouple type such as LJ ttK e TCVolts The thermocouple voltage e CJTempK The temperature of the cold junction in degrees Outputs e pTCTempkK Returns the calculated thermocouple temperature 4 2 16 ResetLabJack Sends a reset command to the LabJack hardware Resetting the LabJack does not invalidate the handle thus the device does not have to be opened again after a reset but a Go call is likely to fail for a couple seconds after until the LabJack is ready In a future driver release this function might be given an additional parameter that determines the type of reset Declaration LJ ERROR stdcall ResetLabJack LJ HANDLE Handle Parameter Description Returns LabJack errorcodes or for no error Inputs e Handle Handle returned by OpenLabJack 63 Outputs e None 4 2 17 eAIN An easy function that returns a reading from one analog input This is a simple alternative to the very flexible IOType based method normally used by this driver When needed this function automatically configures the specified channel s for analog input Declaration LJ ERROR _stdcall eAIN LJ HANDLE Handle long ChannelP long ChannelN double Voltage long Range long Resolution long Settling long Binary long Reserved long Reserved2 Paramet
67. Wire 4 20 mA Sensor 24 Figure 2 6 Current Measurement With 3 Wire 4 20 mA Sourcing Sensor 25 Figure 2 7 10 Volt DAC Output Circuit Lu oi sitat agere svi ue eds 28 Figure 2 8 Driven Signal Connection To Digital 30 Figure 2 9 Open Collector NPN Connection To Digital 30 Figure 2 10 Basic Mechanical Switch Connection To Digital 31 Figure 2 11 Passive Hardware Debounce 32 Figure 2 12 Relay Connections Sinking Control High Side Load Switching 32 Table 3 1 Typical Feedback Function Execution Times QuickSample 0 LongSettling 0 44 Table 3 2 Typical Feedback Function Execution Times QuickSample 1 LongSettling 0 44 Table 3 3 Typical Feedback Function Execution Times QuickSample 0 LongSettling 1 44 Table 3 4 Stream Performance cccccccssssssssccccccecceseeeseceeeeseseseeeeceeeeeeeseesaaeaceeeeseesaeaeaseeeseeees 46 Table 3 5 Special Stream Channels ccccccccccceccceeesesecceeeceeceeeeeseceeeeeseseeseaeseeeeessesaeaeeseeeeees 47 Table 4 1 Request Level Errorcodes Part 1 86 Table 4 2 Request Level Errorcodes Part 2
68. addresses ps Bes us IP Figure 1 4 LJControlPanel Settings Window 10 e Search for USB devices If selected LJControlPanel will include USB when searching for devices e Search for Ethernet devices using UDP broadcast packet Does not apply to the U3 Search for Ethernet devices using specified IP addresses Does not apply to the U3 1 2 Self Upgrade Application LJSelfUpgrade The processor in the U3 has field upgradeable flash memory The self upgrade application shown in Figure 1 5 programs the latest firmware onto the processor USB is the only interface on the U3 and first found is the only option for self upgrading the U3 so no changes are needed in the Connect by box There must only be one U3 connected to the PC when running LJSelfUpgrade Click on Get Version Numbers to find out the current firmware versions on the device Then use the provided Internet link to go to labjack com and check for more recent firmware Download firmware files to the LabJack LJUSelfUpgrade upgradefiles directory Click the Browse button and select the upgrade file to program Click the Program button to begin the self upgrade process JA LJSelfUpgrade v1 13 c File Browse Status Driver Version 2 690 Check for the latest firmware upgrade files at www labjack com files firmware Download any desired upgrades and save them in LJSelfUpgrade upgradefiles Target processor C
69. al not analog return valid readings O Number 0 7 FIO 8 15 EIO or 16 19 1 e State 1 High O Low 5 2 5 6 BitStateWrite 11 BitStateWrite 2 Command Bytes 0 11 1 Bits 0 4 Number Bit 7 State 0 Response Bytes This IOType writes the state of a single bit of digital The direction of the specified line is forced to output O Number 0 7 FIO 8 15 EIO or 16 19 ClO e State 1 High O Low 102 5 2 5 7 BitDirRead lOType 12 BitDirRead 2 Command Bytes 0 12 1 Bits 0 4 IO Number 1 Response Byte 0 Bit 0 Direction This IOType reads the direction of a single bit of digital I O This is the digital direction only and does not provide any information as to whether the line is configured as digital or analog e O Number O 7 FIO 8 15 EIO or 16 19 ClO e Direction 1 Output O Input 5 2 5 8 BitDirWrite IOTypez13 BitDirWrite 2 Command Bytes 0 lOType 13 1 Bits 0 4 IO Number Bit 7 Direction 0 Response Bytes This IOType writes the direction of a single bit of digital I O e lO Number O 7 FIO 8 15 EIO or 16 19 ClO e Direction 1 Output O Input 5 2 5 9 PortStateRead lOType 26 PortStateRead 1 Command Byte 0 IOType 26 3 Response Bytes 0 2 State This IOType reads the state of all digital I O where 0 7 FIO 8 15 EIO and 16 19 CIO Only lines configured as digital not analog return valid readings e State Each bit of th
70. all functionality related to timers and counters and will usually be as efficient as any other method These easy functions are recommended for most timer counter applications Following is example pseudocode Take a singl nded measurement from AIN3 eAIN Handle ChannelP ChannelN Voltage Range Resolution Settling Binary Reservedl Reserved2 eAIN lngHandle 3 31 amp dblVoltage 0 0 0 0 0 0 printf AIN3 value 3f n dblVoltage Set DACO to 3 1 volts eDAC Handle Channel Voltage Binary Reservedl Reserved2 eDAC lngHandle 0 3 1 0 0 0 Read state of FIO2 eDI Handle Channel State eDI lngHandle 2 amp lngState printf FIO2 state 0f n IngState Set FIO3 to output high eDO Handle Channel State eDO lngHandle 3 1 Enable and configure 1 output timer and 1 input timer and enable Counter Fill the arrays with the desired values then make the call alngEnableTimers 1 1 Enable Timer0 Timerl alngTimerModes LJ tmPWM8 LJ tmRISINGEDGES32 Set timer modes adblTimerValues 16384 0 Set PWM8 duty cycle to 75 alngEnableCounters 1 0 Enable CounterO0 eTCConfig Handle aEnableTimers aEnableCounters TCPinOffset A TimerClockBaseIndex TimerClockDivisor aTimerModes aTimerValues Reservedl Reserved2 Z eTCConfig lngHandle alngEnableTimers alngEnableCounters 4 LJ tc48MHZ 0
71. an analog input ePut lngHandle LJ ioPUT ANALOG ENABLE BIT 3 1 0 Configure FIO3 as digital I O ePut lngHandle LJ ioPUT ANALOG ENABLE BIT 3 0 0 Configure FIO0 FIO2 and 7 as analog all others as digital That means a starting channel of 0 a value of b1111111100000111 d65287 and 68 all 16 bits will be updated ePut lngHandle LJ ioPUT ANALOG ENABLE PORT 0 65287 16 Configure FIO2 FIO4 as analog and FIO5 FIO6 as digital without configuring any other bits That means a starting channel of 2 a value of b00111 d7 and 5 bits will be updated ePut lngHandle LJ ioPUT ANALOG ENABLE PORT 2 7 5 Because of the pin configuration interaction between digital I O analog inputs and timers counters many software applications will need to initialize the flexible I O to a known pin configuration One way to do this is with the following pseudocode ePut lngHandle LJ ioPUT CONFIG LJ chNUMBER TIMERS ENABLED 0 0 ePut lngHandle LJ CONFIG LJ chTIMER COUNTER PIN OFFSET 4 0 ePut lngHandle LJ CONFIG LJ chTIMER CLOCK BASE LJ tc48MHZ 0 ePut lngHandle LJ ioPUT CONFIG LJ chTIMER CLOCK DIVISOR 0 0 ePut lngHandle LJ ioPUT COUNTER ENABLE 0 0 0 ePut lngHandle LJ ioPUT COUNTER ENABLE 1 0 0 ePut lngHandle LJ ioPUT DAC ENABLE 1 0 0 Ignored on hardware rev 1 304 ePut lngHandle LJ ioPUT ANALOG ENABLE PORT 0 0 16
72. arameter types very basic Also many functions have multiple prototypes The declarations that follow are written in C To help those unfamiliar with strings in C these functions expect null terminated 8 bit ASCII strings How this translates to a particular development environment is beyond the scope of this documentation A const char is a pointer to a string that won t be changed by the driver Usually this means it can simply be a constant such as this is a string A char is a pointer to a string that will be changed Enough bytes must be preallocated to hold the possible strings that will be returned Functions with char in their declaration will have the required length of the buffer documented below Pointers must be initialized in general although null 0 can be passed for unused or unneeded values The pointers for GetStreamData and Rawln RawOut requests not optional Arrays and char type strings must be initialized to the proper size before passing to the DLL 4 2 1 ListAIl Returns all the devices found of a given DeviceType and ConnectionType Currently only USB is supported ListAllS is a special version where DeviceType and ConnectionType are strings rather than longs This is useful for passing string constants in languages that cannot include the header file The strings should contain the constant name as indicated in the header file such as LJ dtU3 and LJ ctUSB The declaration for the S version of
73. ask bit 2 is set the values passed become the default values meaning they are written to flash and used at reset Regardless of the mask bit this function has no effect on the current settings The return values of these parameters are a read of the power up defaults TimerClockConfig amp TimerClockDivisor If the WriteMask bit 4 is set the values passed become the default values meaning they are written to flash and used at reset The return values of these parameters are a read of the power up defaults See Section 5 2 4 CompatibilityOptions If the WriteMask bit 5 is set the value passed becomes the default value meaning it is written to flash and used at reset The return value of this parameter is a read of the power up default If bit O is set Timer Counter Pin Offset errors are ignored If bit 1 is set all DAC operations will use 8 bit mode rather than 10 bit mode FirmwareVersion Fixed parameter specifies the version number of the main firmware A firmware upgrade will generally cause this parameter to change The lower byte is the integer portion of the version and the higher byte is the fractional portion of the version BootloaderVersion Fixed parameter specifies the version number of the bootloader The lower byte is the integer portion of the version and the higher byte is the fractional portion of the version HardwareVersion Fixed parameter specifies the version number of the hardware The lower byte is the integer portio
74. ated to the power provided by the host hub Self and bus powered describes the host hub not the U3 Self powered would apply to USB hubs with a power supply all known desktop computer USB hosts and some notebook computer USB hosts An example of bus powered would be a hub with no power supply or many PDA ports The current rating is the maximum current that should be sourced through the U3 and out of the Vs terminals 128 Parameter Conditions Min Typical Max Units Analog Inputs Typical Input Range 1 Single Ended LV Differential LV Special LV Single Ended HV Special HV Max AIN Voltage to GND 2 Valid Readings LV Max AIN Voltage to GND 3 No Damage FIO No Damage EIO No Damage HV Input Impedance 4 LV HV Source Impedance 4 LongSettling Off LV LongSettling On LV LongSettling Off HV LongSettling On HV Resolution bits Integral Linearity Error FS Differential Linearity Error counts Absolute Accuracy Single Ended FS Differential FS Special 0 3 6 FS Temperature Drift Noise Peak To Peak 5 QuickSample Off counts QuickSample On counts Effective Resolution RMS 6 QuickSample Off bits Noise Free Resolution 5 QuickSample Off bits Single Ended LV mV Diff Special LV mV Single Ended HV mV Special HV Command Response Speed See Section 3 1 Stream Performance See Section 3 2 1 With DAC1 disabled on hardware versions lt 1 30 2 This is the maximum volta
75. avior for a normally high signal where the switch closure causes a brief low signal Figure 2 9 The debounce period can be set long enough so that bouncing on both the switch closure and switch open is ignored Writing a value of zero to the timer performs a reset After reset a read of the timer value will return zero until a new edge is detected If a timer is reset and read in the same function call the read returns the value just before the reset 2 9 1 7 Frequency Output Mode 7 Outputs a square wave at a frequency determined by TimerClockBase TimerClockDivisor divided by 2 Timer Value The Value passed should be between 0 255 where 0 is a divisor of 256 By changing the clock configuration and timer value a wide range of frequencies can be output as shown in the following table Mode 7 Frequency Ranges Divisor 1 Divisor 1 TimerBaseClock Value 1 Value 256 0 4 MHz 2000000 0 7812 50 1 12 MHz 6000000 0 23437 50 2 48 MHz Default 24000000 0 93750 00 Divisor 1 Divisor 256 Value 1 Value 256 3 1 MHz Divisor 500000 0 7 629 4 4 MHz Divisor 2000000 0 30 518 5 12 MHz Divisor 6000000 0 91 553 6 48 MHz Divisor 24000000 0 366 211 Note that the clocks above apply to the U3 hardware revision 1 21 With hardware revision 1 20 all clocks are half of those values 38 The frequency output has a 3 dB frequency of about 10 MHz on the FIO lines Accordingly at high frequencies the output waveform will get less square and the a
76. before any other timer counter channel For example a scan list of 200 224 201 224 would get the LSW of TimerO the MSW of TimerO the LSW of Timer1 and the MSW of Timer1 A scan list of 200 201 224 would get the LSW of TimerO the LSW of Timer1 and the MSW of Timer1 MSW of TimerO is lost Adding these special channels to the stream scan list does not configure those inputs If any of the FIO or EIO lines have been configured as outputs timers counter or analog inputs a channel 193 read will still be performed without error but the values from those bits should be ignored The timers counters 200 224 must be configured before streaming using normal timer counter configuration commands The timing for these special channels is the same as for normal analog channels For instance a stream of the scan list 0 1 200 224 201 224 counts as 6 channels and the maximum scan rate is determined by taking the maximum sample rate at the specified resolution and dividing by 6 Special care must be taken when streaming timers configured in mode 2 or 3 32 bit period measurement It is possible for the LSW to roll but the MSW be captured before it is incremented That means the resulting value will be low by 65536 clock ticks which is easy to detect in many applications but if this is an unacceptable situation then only the LSW or MSW should be used and not both 47 Mode 11 the upper 32 bits of the system timer is not available for stream
77. but if the computer or communication link is too slow for some reason the driver might not be able to read the data as fast as the U3 is acquiring it and thus there will be data left over in the U3 buffer To obtain the maximum stream rates documented in Section 3 2 the data must be transferred between host and U3 in large chunks The amount of data transferred per low level packet is controlled by 27 cnsrREAM sAMPLES PER PACKET The driver will use the parameter LJ chSTREAM READS PER SECOND to determine how many low level packets to retrieve per read The size of the UD stream buffer on the host is controlled by 27 cnsrREAM BUFFER 512 The application software on the host must read data out of the UD stream buffer fast enough to prevent overflow After each read use 27 cnsrREAM determine how many samples are left in the buffer Since the data buffer on the U3 is very small a feature called auto recovery is used If the buffer overflows the U3 will continue streaming but discard data until the buffer is emptied and then data will be stored in the buffer again The U3 keeps track of how many packets are discarded and reports that value Based on the number of packets discarded the UD driver adds the proper number of dummy samples 9999 0 such that the correct timing is maintained Auto recovery will generally occur when the U3 buffer is 90 95 full 75 In stream mode the LabJack acquires inputs at a fi
78. ced topic A good knowledge of the protocol is recommended and a logic analyzer or oscilloscope might be needed for troubleshooting There is one used to write read data over the SPI bus LJ ioSPI COMMUNICATION Value number of bytes 1 50 1 array The following are special channels used with the get put config IOTypes to configure various parameters related to the SPI bus See the low level function description in Section 5 3 15 for more information about these parameters LJ chSPI AUTO CS LJ chSPI DISABLE DIR CONFIG LJ chSPI MODE LJ chSPI CLOCK FACTOR LJ chSPI MOSI PIN NUM LJ chSPI MISO PIN NUM LJ PIN NUM LJ chSPI CS PIN NUM Following is example pseudocode to configure SPI communication First configure the SPI communication Enable automatic chip select control AddRequest lngHandle LJ ioPUT CONFIG LJ chSPI AUTO CS 1 0 0 Do not disable automatic digital i o direction configuration AddRequest lngHandle LJ ioPUT CONFIG LJ chSPI DISABLE DIR CONFIG 0 0 0 Mode A 1 CPOL 1 AddRequest lngHandle LJ ioPUT CONFIG LJ chSPI MODE 0 0 0 Maximum clock rate 100kHz AddRequest lngHandle LJ ioPUT CONFIG LJ chSPI CLOCK FACTOR 0 0 0 Set MOSI to FIO2 AddRequest lngHandle LJ ioPUT CONFIG LJ chSPI MOSI PIN NUM 2 0 0 Set MISO to FIO3 AddRequest lngHandle LJ ioPUT CONFIG LJ chSPI MISO PIN NUM 3 0 0 80 Set CLK to FI
79. ckS replaces both DeviceType and ConnectionType with strings since both take constants For example 51 In where the LabJackUD h file can be included and the constants used directly AddRequest Handle LJ ioGET CONFIG LJ ioHARDWARE VERSION 0 0 0 The bad way hard to read when LabJackUD h cannot be included AddRequest Handle 1001 10 0 0 0 The better way when LabJackUD h cannot be included is to pass strings AddRequestSS Handle LJ ioGET CONFIG LJ ioHARDWARE VERSION 0 0 0 Continuing on this vein the function StringToConstant is useful for error handling routines or with the GetFirst Next functions which do not take strings The StringToConstant function takes a string and returns the numeric constant So for example LJ ERROR err rr AddRequestSS Handle LJ ioGETCONFIG LJ ioHARDWARE VERSION 0 0 0 if err StringToConstant LJE INVALID DEVICE do some error handling Once again this is much clearer than if err 2 4 1 2 Multi Threaded Operation This driver is completely thread safe With some very minor exceptions all these functions can be called from multiple threads at the same time and the driver will keep everything straight Because of this Add Go and Get must be called from the same thread for a particular set of requests results Internally the list of requests and results are split by thread This allows multiple threads to be used to make requests w
80. coco dette 107 5 2 7 WriteMem WriteCal ec de ERR Ue HE REP 108 24 9 EraseMBti EraseGal S intet niit e RESI OD E Meta 109 9 2 MS II RSEN RR ERE 110 9 2 TO SUSAN ss scito ei tbe ee atat ah a ie Dai UE UN Ut ts 111 5i2 11 i oerte ree Prnt eter engen ee D vx dece bite tly dative 113 5 212 StreambData etc ient tete Ho RE viento ev seule dese vie 114 5 2 13 gt StreamsStop c cat eL e Y e Let eR EU deca DER EH E e P e PE ERR IURE 115 SOME bi e EE 116 DSi Ont m cL EIE 118 5 316 aeq ero Lar T 120 DAT TX e PN 121 5 3 18 ASYMCMRA ue 122 OMENPOT deers teres 123 IAM CERTE LEEREN 125 9 3 i herr meet tee domi bet ta esa deat ide 126 A Specifications 128 Enclosure S PCB Drawings oed ee ae eee a he candy der ucc RE eect 131 Table Of Figures Figure 1 1 LJControlPanel Main Window eec nennen nnn nnne nnn 8 Figure 1 2 LJControlPanel U3 Configure Defaults 9 Figure 1 3 LJControlPanel U3 Test nennen 10 Figure 1 4 LJControlPanel Settings Window sssseeeennnn 10 Figure 1
81. ction analog input channel can be tough to predict and is likely to vary with sample timing and adjacent sampled channels Keep in mind that a floating channel is not at O volts but rather is at an undefined voltage In order to see 0 volts a volt signal such as GND should be connected to the input Some data acquisition devices use a resistor from the input to ground to bias an unconnected input to read 0 This is often just for cosmetic reasons so that the input reads close to 0 with floating inputs and a reason not to do that is that this resistor can degrade the input impedance of the analog input 25 In a situation where it is desired that a floating channel read a particular voltage say to detect broken wire a resistor can be placed from the AINx screw terminal to the desired voltage GND VS DACx A 100 resistor should pull the analog input readings to within 50 mV of any desired voltage but obviously degrades the input impedance to 100 kO For the specific case of pulling a floating channel to 0 volts a 1 MQ resistor to GND can typically be used to provide analog input readings of less than 50 mV Note that the four high voltage channels on the U3 HV do sit at a predictable 1 4 volts 2 6 4 Internal Temperature Sensor The U3 has an internal temperature sensor Although this sensor measures the temperature inside the U3 which is warmer than ambient it has been calibrated to read actual ambient temperature
82. ctor16 2 16 48000000 2 Desired Baud For example a BaudFactor16 63036 provides a baud rate of 9600 bps With hardware revision 1 21 the value is only 8 bit and the formula is BaudFactor8 2 8 TimerClockBase Desired Baud Following is example pseudocode for asynchronous communication Set data rate for 9600 bps communication ePut lngHandle LJ ioPUT CONFIG LJ chASYNCH BAUDFACTOR 63036 0 Enable UART ePut lngHandle LJ ioASYNCH COMMUNICATION LJ chASYNCH ENABLE 1 0 Write data eGet lngHandle LJ ioASYNCH COMMUNICATION LJ chASYNCH TX amp numBytes array Read data Always initialize array to 32 bytes eGet lngHandle LJ ioASYNCH COMMUNICATION LJ chASYNCH RX amp numBytes array 4 3 13 Watchdog Timer The U3 hardware version 1 21 only has firmware based watchdog capability Unattended systems requiring maximum up time might use this capability to reset the U3 or the entire system When any of the options are enabled an internal timer is enabled which resets on any incoming USB communication If this timer reaches the defined TimeoutPeriod before being reset the specified actions will occur Note that while streaming data is only going out so some other command will have to be called periodically to reset the watchdog timer Timeout of the watchdog on the U3 can be specified to cause a device reset update the state of 1 digital I O must be configured as output by user or both Typical usa
83. dictates the timing of the application The time per loop iteration will vary but the number of samples read per loop will be the same every time A Get command should be called to determine whether all the data was retrieved or a timeout condition occurred and none of the data was retrieved e LJ swALL OR NONE If available the Go call will retrieve the amount of data requested otherwise it will retrieve no data A Get command should be called to determine whether all the data was returned or none This could be a good mode if hardware timed execution is desirable but without the application continuously waiting in SLEEP mode The following pseudocode reads data continuously in SLEEP mode as configured above Read data until done while done Must set the number of scans to read each iteration as the read returns the actual number read numScans 1000 Read the data Note that the array passed must be sized to hold enough SAMPLES and the Value passed specifies the number of SCANS to read eGet lngHandle LJ ioGET STREAM DATA LJ chALL CHANNELS amp numScans array actualNumberRead numScans When all channels are retrieved in a single read the data is interleaved in a 1 dimensional array The following lines get the first sample from each channel channelA array 0 channelB 1 Retrieve the current U3 backlog The UD driver retrieves stream data from th
84. e U3 If LIControlPanel does not find the check Windows Device Manager to see if the U3 installed correctly One way to get to the Device Manager is Start gt Control Panel gt System gt Hardware gt Device Manager The entry for the U3 should appear as in the following figure If it has a yellow caution symbol or exclamation point symbol right click and select Uninstall or Remove Then disconnect and reconnect the U3 and repeat the Found New Hardware Wizard as described above Device BEE File Action View Help ye Disk drives 2 Display adapters DVD CD ROM drives Floppy disk controllers 3 Floppy disk drives IDE ATA ATAPI controllers lt gt Keyboards amp LabJack USB Devices amp LabJack U3 lt Mice and other pointing devices L Modems Monitors ma Network adapters Sfi Processors Sound video and game controllers Ports COM amp LPT System devices E Universal Serial Bus controllers 1 1 Control Panel Application LJControlPanel The LabJack Control Panel application handles configuration and testing of the Click on the Find Devices button to search for connected devices FA LJ Control Panel 2 10 File Options Help Devices Serial Number 320014232 UES 272260863 USB 1 TCP 192 168 1 163 U3 320014232 Local ID Firmware Version Not Found 1 Bootloader Version
85. e U3 in the background but if the computer is too slow for some reason the driver might not be able to read the data as fast as the U3 is acquiring it and thus there will be data left over in the U3 buffer eGet lngHandle LJ ioGET CONFIG LJ chSTREAM BACKLOG COMM amp dblCommBacklog 0 Retrieve the current UD driver backlog If this is growing then the application software is not pulling data from the UD driver fast enough eGet lngHandle LJ ioGET CONFIG LJ chSTREAM BACKLOG UD amp dblUDBacklog 0 Finally stop the stream Stop the stream errorcode ePut Handle LJ ioSTOP STREAM 0 0 0 4 3 8 Raw Output Input There are two IOTypes used to write or read raw data These can be used to make low level function calls Section 5 through the UD driver The only time these generally might be used is to access some low level device functionality not available in the UD driver LJ ioRAW OUT LJ ioRAW IN When using these channel specifies the desired communication pipe For the 0 is the normal pipe while 1 is the streaming pipe The number of bytes to write read is specified in value 1 16384 and x1 is a pointer to a byte array for the data When retrieving the result the value returned is the number of bytes actually read written Following is example pseudocode to write and read the low level command ConfigTimerClock Section 5 2 4 writeArray 2 0x05 0xF8 0x02 0x0A 0
86. e Windows TerminateThread function As is warned in the MSDN documentation using TerminateThread will kill the thread without releasing any resources and more importantly releasing any synchronization objects If TerminateThread is used on a thread that is currently in the middle of a call to this driver more than likely a synchronization object will be left open on the particular device and access to the device will be impossible until the application is restarted On some devices it can be worse On devices that have interprocess 52 synchronization such as the U12 calling TerminateThread may kill all access to the device through this driver no matter which process is using it and even if the application is restarted Avoid using TerminateThread All device calls have a timeout which defaults to 1 second but can be changed Make sure to wait at least as long as the timeout for the driver to finish 53 4 2 Function Reference The LabJack driver file is named LabJackUD dll and contains the functions described in this section Some parameters are common to many functions e LJ ERROR LabJack specific numeric errorcode 0 means no error long signed 32 bit integer e LJ HANDLE This value is returned by OpenLabJack and then passed on to other functions to identify the opened LabJack long signed 32 bit integer To maintain compatibility with as many languages as possible every attempt has been made to keep the p
87. e enabled the timers are initialized to mode 10 so the desired timer mode must always be specified after every 96 call to this function Note that CounterO is not available when using a timer clock base that supports a timer clock divisor TimerClockBase 3 6 DAC1Enable On hardware revisions 1 20 1 21 only bit 0 enables DAC1 When DAC1 is disabled it outputs a constant voltage of 1 5 times the internal Vref 2 44 volts When 1 is enabled the internal Vref is not available for the analog inputs and Vreg 3 3 volts is used as the AIN reference Starting with hardware revision 1 30 DAC1 is always enabled FlOAnalog Each bit determines whether that bit of FIO is analog input 71 or digital I O 70 ElOAnalog Each bit determines whether that bit of EIO is analog input 71 or digital I O 70 97 5 2 4 ConfigTimerClock Writes and read the timer clock configuration Command UJ eVoakenaof Checksum8 OxF8 0x02 Checksum16 LSB Checksum16 MSB Reserved Reserved TimerClockConfig Bit 7 Configure the clock Bits 2 0 TimerClockBase b000 4 MHz b001 12 MHz b010 48 MHz Default b011 1 MHz Divisor b100 4 MHz Divisor b101 12 MHz Divisor b110 48 MHz Divisor 9 TimerClockDivisor 0 256 Response Byte 0 Checksum8 1 OxF8 2 0x02 3 4 Checksum16 LSB 5 Checksum16 MSB 6 Errorcode 7 Reserved 8 TimerClockConfig 9 TimerClockDivisor 0 256 e TimerClockConfig Bi
88. e screw terminal labeled FIO5 and AIN5 if enabled is always on that same screw terminal The first 8 flexible I O lines FIOO FIO7 appear on built in screw terminals The other 8 flexible I O lines EIOO EIO7 are available on the DB15 connector Many software applications will need to initialize the flexible I O to a known pin configuration That requires calls to the low level functions ConfiglO and ConfigTimerClock Following are the values to set the pin configuration to the factory default state Byte 6 WriteMask 15 Write all parameters 8 TimerCounterConfig 0 No timers counters Offset 4 9 DAC1Enable 0 DAC1 disabled Ignored on HW 1 30 10 FlOAnalog 0 FIO all digital 11 ElOAnalog 0 EIO all digital Table 2 2 ConfiglO Factory Default Values Byte 8 TimerClockConfig 130 Set clock to 48 MHz 9 TimerClockDivisor 0 Divisor 0 Table 2 3 ConfigTimerClock Factory Default Values When using the high level LabJackUD driver this could be done with the following requests ePut lngHandle LJ ioPUT CONFIG LJ chNUMBER TIMERS ENABLED 0 0 ePut lngHandle LJ ioPUT CONFIG LJ chTIMER COUNTER PIN OFFSET 4 0 ePut lngHandle LJ ioPUT CONFIG LJ chTIMER CLOCK BASE LJ tc48MHZ 0 ePut lngHandle LJ ioPUT CONFIG LJ chTIMER CLOCK DIVISOR 0 0 ePut lngHandle LJ ioPUT COUNTER ENABLE 0 0 0 ePut lngHandle LJ ioPUT COUNTER ENABLE 1 0 0 ePut lngHandle LJ ioPUT DAC ENABLE 1 0 0 Ignored on hardware
89. e short circuit protection These series resistors also limit the ability of these lines to sink or source current Refer to the specifications in Appendix A All digital on the U3 have possible states input output high or output low Each bit of I O can be configured individually When configured as an input a bit has a 100 kQ pull up resistor to 3 3 volts When configured as output high a bit is connected to the internal 3 3 volt supply through a series resistor When configured as output low a bit is connected to GND through a series resistor DB15 Pinouts 1 Vs 9 2 CIO1 10 2 3 11 GND 4 EIOO 12 EIO1 5 EIO2 13 EIO3 6 ElO4 14 5 7 ElO6 15 EIO7 8 GND 2 11 1 CB15 Terminal Board The CB15 terminal board connects to the LabJack U3 s DB15 connector It provides convenient screw terminal access to the 12 digital I O available on the DB15 connector The CB15 is designed to connect directly to the LabJack or can connect via a standard 15 line 1 1 male female DB15 cable 2 11 2 RB12 Relay Board The RB12 provides a convenient interface for the to industry standard digital I O modules allowing electricians engineers and other qualified individuals to interface a LabJack with high voltages currents The RB12 relay board connects to the DB15 connector on the LabJack using the 12 EIO CIO lines to control up to 12 I O modules Output or input types of digital I O modules can be used The RB12 i
90. e that a duty cycle of 0 or 100 does not have any edges To select a clock frequency consider the longest expected high or low time and set the clock frequency such that the 16 bit registers will not overflow Note that the minimum measurable high low time is limited by the edge rate limit discussed in Section 2 9 2 When using the LabJackUD driver the value returned is the entire 32 bit value To determine the high and low time this value should be split into a high and low word One way to do this is to do a modulus divide by 2 to determine the LSW and a normal divide by 2 keep the quotient and discard the remainder to determine the MSW Writing a value of zero to the timer performs a reset After reset a read of the timer value will return zero until new edge is detected If a timer is reset and read in the same function call the read returns the value just before the reset The duty cycle reset is special in that if the signal is low at the time of reset the high time low time registers are set to 0 65535 but if the signal is high at the time of reset the high time low time registers are set to 65535 0 Thus if no edges occur before the next read it is possible to tell if the duty cycle is 0 or 100 2 9 1 5 Firmware Counter Input Mode 5 On every rising edge seen by the external pin this mode increments a 32 bit register Unlike the pure hardware counters these timer counters require that the firmware jump to an inter
91. er Description Returns LabJack errorcodes or for no error Inputs e Handle Handle returned by OpenLabJack e ChannelP The positive AIN channel to acquire e ChannelN The negative AIN channel to acquire For the UES this parameter is ignored For single ended channels on the U3 this parameter should be 31 see Section 2 6 1 Range Ignored on the U3 Resolution Pass a nonzero value to enable QuickSample Settling Pass a nonzero value to enable LongSettling Binary If this is nonzero True the Voltage parameter will return the raw binary value e Reserved 1 amp 2 Pass 0 Outputs e Voltage Returns the analog input reading which is generally a voltage 4 2 18 eDAC An easy function that writes a value to one analog output This is a simple alternative to the very flexible IOType based method normally used by this driver When needed on hardware revisions 1 30 perhaps this function automatically enables the specified analog output Declaration LJ ERROR stdcall eDAC LJ HANDLE Handle 64 long Channel double Voltage long Binary long Reserved1 long Reserved2 Parameter Description Returns LabJack errorcodes or 0 for no error Inputs Handle Handle returned by OpenLabJack Channel The analog output channel to write to Voltage The voltage to write to the analog output Binary If this is nonzero True the value passed for Voltage should be binary Reser
92. es with some other device using the serial protocol Using this serial protocol is considered an advanced topic A good knowledge of the protocol is recommended and a logic analyzer or oscilloscope might be needed for troubleshooting There is one lOType used to write read asynchronous data LJ ioASYNCH COMMUNICATION The following are special channels used with the asynch IOType above LJ chASYNCH ENABLE Enables UART to begin buffering rx data LJ chASYNCH RX Value returns pre read buffer size 1 array LJ chASYNCH TX Value number to send 0 56 number in rx buffer x1 array 82 LJ chASYNCH FLUSH Flushes the rx buffer All data discarded Value ignored When using rJ chAasvwcH nx the Value parameter returns the size of the Asynch buffer before the read If the size is 32 bytes or less that is how many bytes were read If the size is more than 32 bytes then the call read 32 this time and there are still bytes left in the buffer When using 27 specify the number of bytes to send in the Value parameter The Value parameter returns the size of the Asynch read buffer The following is a special channel used with the get put config IOTypes to specify the baud rate for the asynchronous communication LJ chASYNCH BAUDFACTOR 16 bit value for hardware V1 30 8 bit for V1 21 With hardware revision 1 30 this is a 16 bit value that sets the baud rate according the following formula BaudFa
93. eserved 12 Numl2CBytesToSend 13 NumlI2CBytesToReceive 14 I2CByteO Response Byte 0 Checksum8 1 OxF8 2 3 Numl2CWordsReceive 3 Ox3B 4 Checksum16 LSB 5 Checksum16 MSB 6 Errorcode 7 Reserved 8 AckArrayO 9 AckArray1 10 AckArray2 11 AckArray3 12 I2CByteO e Numl2CWordsSend This is the number of I2C bytes to send divided by 2 If the number of bytes is odd round up and add an extra zero to the packet This parameter is actually just to specify the size of this packet as the Numl2CbytesToSend parameter below actually specifies how many bytes will be sent e 2COptions If ResetAtStart is true an I2C bus reset will be done before communicating e SpeedAdjust Allows the communication frequency to be reduced 0 is the maximum speed of about 150 kHz 20 is a speed of about 70 kHz 255 is the minimum speed of about 10 kHz 123 SDAP SCLP PinNum Assigns which digital I O line is used for each 12 line Value passed is 0 19 corresponding to the normal digital numbers as specified in Section 2 9 Note that the screw terminals labeled SDA and SCL on hardware revision 1 20 or 1 21 are not used for I2C Note that the I2C bus generally requires pull up resistors of perhaps 4 7 kQ from SDA to Vs and SCL to Vs AddressByte This is the first byte of data sent on the I2C bus The upper 7 bits are the address of the slave chip and bit 0 is the read write bit Note that the read write bit is controlled automatically b
94. etrieve the results errorcodes and values that were stored by the driver during the Go call This does not involve any low level communication with the device and thus the execution time is relatively instantaneous Get the result of the DACO request just to check for an errorcode The general form of the GetResult function is GetResult Handle IOType Channel Value ingErrorcode GetResult lngHandle LJ ioPUT DAC 0 0 Get the AIN3 voltage We pass the address to dblValue and the voltage will be returned in that variable ingErrorcode GetResult lngHandle LJ ioGET AIN 3 amp dblValue The AddRequest Go GetResult method is often the most efficient As shown above multiple requests can be executed with a single Go or GoOne call and the driver might be able to optimize the requests into fewer low level calls The other option is to use the eGet or ePut functions which combine the AddRequest Go GetResult into one call The above code would then look like assuming the U3 is already open Set DACO to 2 5 volts The general form of the ePut function is ePut Handle IOType Channel Value x1 ingErrorcode ePut lngHandle LJ ioPUT DAC 0 2 50 0 Read AIN3 The general form of the eGet function is eGet Handle IOType Channel Value 1 50 ingErrorcode eGet lngHandle LJ ioGET AIN amp dblValue 0 In the case of the U3 the first example using add go get handles both the
95. evice such a configuration does often provide improved performance Stream data rates over USB can also be limited by other factors such as speed of the PC and program design One general technique for robust continuous streaming would be increasing the priority of the stream process A sample is defined as a single conversion of a single channel while a scan is defined as a single conversion of all channels being acquired That means the maximum scan rate for a stream of five channels is 50k 5 10 kscans second Low Level UD Max Stream ENOB ENOB Noise Interchannel Res Index Res Index Samples s RMS Noise Free Counts Delay us 0 100 2500 12 8 10 0 2 320 1 101 10000 11 9 9 0 4 82 2 102 20000 11 3 8 4 6 42 3 103 50000 10 5 7 5 11 12 5 Table 3 4 Stream Performance Full resolution streaming is limited to 2500 samples s but higher speeds are possible at the expense of reduced effective resolution increased noise The first column above is the index passed in the Resolution parameter to the low level StreamConfig function while the second column is the corresponding index for the Resolution parameter in the UD driver In the UD driver the default Resolution index is 0 which corresponds to automatic selection In this case the driver will use the highest resolution for the specified sample rate ENOB stands for effective number of bits The first ENOB column is the commonly used effective resolution and can be thought o
96. f as the resolution obtained by most readings This 46 data is calculated by collecting 128 samples and evaluating the standard deviation RMS noise The second ENOB column is the noise free resolution and is the resolution obtained by all readings This data is calculated by collecting 128 samples and evaluating the maximum value minus the minimum value peak to peak noise Similarly the Noise Counts column is the peak to peak noise based on counts from a 12 bit reading Interchannel delay is the time between successive channels within a stream scan 3 2 1 Streaming Digital Inputs Timers and Counters There are special channel numbers that allow digital inputs timers and counters to be streamed in with analog input data Channel 193 EIO FIO 200 TimerO 201 Timer1 210 CounterO 211 Counter1 224 TC Capture Table 3 5 Special Stream Channels Channel number 193 returns the input states of 16 bits of digital I O FIO is the lower 8 bits and EIO is the upper 8 bits Channels 200 201 and 210 211 retrieve the least significant word LSW lower 2 bytes of the specified timer counter At the same time that any one of these is sampled the most significant word MSW upper 2 bytes of that particular timer counter is stored in an internal capture register Capture so that the proper value can be sampled later in the scan For any timer counter where the MSW is wanted channel number 224 must be sampled after that channel and
97. falling edges LJ tmDUTYCYCLE Duty cycle input LJ tmFIRMCOUNTER Firmware counter input LJ tmFIRMCOUNTERDEBOUNCE Firmware counter input with debounce LJ tmFREQOUT Frequency output LJ tmQUAD Quadrature input LJ tmTIMERSTOP Timer stop input odd timers only LJ tmSYSTIMERLOW System timer low read no FIO LJ tmSYSTIMERHIGH System timer high read no FIO 72 LJ tmRISINGEDGES16 Period input 16 bit rising edges LJ tmFALLINGEDGES16 Period input 16 bit falling edges The following are special channels used with the get put config IOTypes to configure a parameter that applies to all timers counters LJ chNUMBER TIMERS ENABLED 0 2 LJ chTIMER CLOCK BASE Value constants below LJ chTIMER CLOCK DIVISOR 0 255 where 0 256 LJ chTIMER COUNTER PIN OFFSET 4 8 only starting with hardware rev 1 30 With the clock base special channel above the following constants are passed in the value parameter to select the frequency LJ tc4MHZ 4 MHz clock base LJ tcl12MHZ 12 MHz clock base LJ tc48MHZ 48 MHz clock base LJ tcl1MHZ DIV 1 MHz clock base w divisor no Counter0 LJ tc4MHZ DIV 4 MHz clock base divisor no Counter0 LJ tcl2MHZ DIV 12 MHz clock base w divisor no Counter0 LJ tc48MHZ DIV 48 MHz clock base w divisor no Counter0 LJ tcSYS Equivalent to LJ tc48MHZ Following is example pseudocode for configuring various timers and a hardware counter Execute the pin configuration
98. ge of the watchdog is to configure the reset defaults as desired and then use the watchdog simply to reset the device on timeout Note that some USB hubs do not like to have any USB device repeatedly reset With such hubs the operating system will quit reenumerating the device on reset and the computer will have to be rebooted so avoid excessive resets with hubs that seem to have this problem If the watchdog is accidentally configured to reset the processor with a very low timeout period such as 1 second it could be difficult to establish any communication with the device In such a case the reset to default jumper can be used to turn off the watchdog Power up the U3 with 83 a short from FIO6 to SPC FIO2 to SCL U3 1 20 1 21 then remove the jumper and power cycle the device again This resets all power up settings to factory default values There is one IOType used to configure and control the watchdog LJ ioSWDT CONFIG Channel is enable or disable constant The watchdog settings are stored in non volatile flash memory and reloaded at reset so every request with this IOType causes a flash erase write The flash has a rated endurance of at least 20000 writes which is plenty for reasonable operation but if this IOType is called in a high speed loop the flash could be damaged The following are special channels used with the watchdog config IOType above LJ chSWDT ENABLE Value is timeout in seconds 1 65535 LJ ch
99. ge on any AIN pin compared to ground for valid measurements Note that a differential channel has a minimum voltage of 2 44 volts meaning that the positive channel can be 2 44 volts less than the negative channel but no AIN pin can go more than 0 3 volts below ground 3 Maximum voltage compared to ground to avoid damage to the device Protection level is the same whether the device is powered or not 4 The low voltage analog inputs essentially connect directly to a SAR ADC on the U3 presenting a capacitive load to the signal source The high voltage inputs connect first to a resistive level shifter divider The key specification in both cases is the maximum source impedance As long as the source impedance is not over this value there will be no substantial errors due to impedance problems 5 Measurements taken with AIN connected to a 2 048 reference REF191 from Analog Devices or GND All counts data are aligned as 12 bit values Noise free data is determined by taking 128 readings and subtracting the minimum value from the maximum value 6 Effective RMS data is determined from the standard deviation of 128 readings In other words this data represents most readings whereas noise free data represents readings 129 Parameter Conditions Min Typical Units Analog Outputs DAC Nominal Output Range 1 Resolution Absolute Accuracy Integral Linearity Error Differential Linearity Error Error Due
100. gnal The main consideration is whether the currents going into or out of the U3 analog input will cause noticeable voltage errors due to the impedance of the source To maintain consistent 12 bit results it is recommended to keep the source impedance within the limits specified in Appendix A Resolution and Accuracy Based on the measurement type and resolution of the U3 the resolution can be determined in terms of voltage or engineering units For example assume some temperature sensor provides a 0 10 mV signal corresponding to 0 100 degrees C Samples are then acquired with the U3 using the 0 2 44 volt single ended input range resulting in a voltage resolution of about 2 44 4096 596 uV That means there will be about 17 discrete 20 steps across the 10 mV span of the signal and the temperature resolution is about 6 degrees If this experiment required a resolution of 1 degrees C this configuration would not be sufficient Accuracy will also need to be considered Appendix A places some boundaries on expected accuracy but an in system calibration can generally be done to provide absolute accuracy down to the linearity INL limits of the U3 Speed How fast does the signal need to be sampled For instance if the signal is a waveform what information is needed peak average RMS shape frequency Answers to these questions will help decide how many points are needed per waveform cycle and thus what sampling rate is required
101. here are eight IOTypes used to write or read digital I O information LJ ioGET DIGITAL BIT Also sets direction to input LJ ioGET DIGITAL BIT DIR LJ ioGET DIGITAL BIT STATE LJ ioGET DIGITAL PORI Also sets directions to input 1 is number of bits LJ ioGET DIGITAL PORT DIR xl is number of bits LJ ioGET DIGITAL PORT STATE xl is number of bits LJ ioPUT DIGITAL BIT Also sets direction to output LJ ioPUT DIGITAL PORT Also sets directions to output x1 is number of bits When a request is done with one of the port IOTypes the Channel parameter is used to specify the starting bit number and the x1 parameter is used to specify the number of applicable bits The bit numbers corresponding to different I O are 0 7 FIOO FIO7 8 15 EIOO EIO7 16 19 Note that the GetResult function does not have an x1 parameter That means that if two or more port requests are added with the same IOType and Channel but different x1 the result retrieved by GetResult would be undefined The GetFirstResult GetNextResult commands do have the x1 parameter and thus can handle retrieving responses from multiple port requests with the same IOType and Channel 71 Following is example pseudocode for various digital operations Execute the pin configuration reset IOType so that all pin assignments are in the factory default condition The ePut function is used which combines the add go get ePut lngHandle L
102. hown in the figure is simply a resistor Load or 2 wire 4 20 mA Sensor AINX Ex Shunt Supply Current Flow 0 100 SGND Figure 2 5 Current Measurement With Arbitrary Load or 2 Wire 4 20 mA Sensor When measuring a 4 20 mA signal a typical value for the shunt would be 120 O This results in a 0 48 to 2 40 volt signal corresponding to 4 20 mA The external supply must provide enough voltage for the sensor and the shunt so if the sensor requires 5 volts the supply must provide at least 7 4 volts 24 For applications besides 4 20 mA the shunt is chosen based the maximum current and how much voltage drop can be tolerated across the shunt For instance if the maximum current is 1 0 amp and 1 0 volts of drop is the most that can be tolerated without affecting the load a 1 0 Q resistor could be used That equates to 1 0 watts though which would require a special high wattage resistor A better solution would be to use a 0 1 shunt and then use an amplifier to increase the small voltage produced by that shunt If the maximum current to measure is too high e g 100 amps it will be difficult to find a small enough resistor and a hall effect sensor should be considered instead of a shunt The following figure shows typical connections for a 3 wire 4 20 mA sensor A typical value for the shunt would be 120 Q which results in 0 48 to 2 40 volts 3 wire 4 20 mA Sensor Vs Signal Supply Common 420m A
103. ial signal to single ended and generally has a simple method to set gain 2 6 3 6 Signal voltages beyond 0 2 44 volts and resistance measurement The normal input range for a low voltage channel on the U3 is about 0 2 44 volts The easiest way to handle larger voltages is often by using the LJTick Divider which is a two channel buffered divider module that plugs into the U3 screw terminals More information is available at labjack com The basic way to handle higher unipolar voltages is with a resistive voltage divider The following figure shows the resistive voltage divider assuming that the source voltage Vin is referred to the same ground as the U3 GND R1 Vin e AINX R2 GND Figure 2 3 Voltage Divider Circuit The attenuation of this circuit is determined by the equation Vout Vin R2 R1 R2 This divider is easily implemented by putting a resistor R1 in series with the signal wire and placing a second resistor R2 from the AIN terminal to a GND terminal To maintain specified analog input performance R1 should not exceed the values specified in Appendix A so R1 can generally be fixed at the max recommended value and R2 can be adjusted for the desired attenuation 23 The divide by 2 configuration where R1 R2 10 max source impedance limit for low voltage channels presents a 20 kQ load to the source meaning that a 5 volt signal will have to be able to source sink up to 250 uA Some
104. ion ElOState ClODirection ClOState DAC1Enable DACO DAC1 TimerClockConfig TimerClockDivisor 0 256 CompatibilityOptions VersionInfo WriteMask Has bits that determine which if any of the parameters will be written to flash as the reset defaults If a bit is 1 that parameter will be updated with the new passed value If a bit is 0 the parameter is not changed and only a read is performed Note that reads return reset defaults not necessarily current values except for LocallD For instance the value returned by FlODirection is the directions at reset not necessarily the current directions LocallD If the WriteMask bit 3 is set the value passed become the default value meaning it is written to flash and used at reset This is a user configurable ID that can be used to identify a specific LabJack The return value of this parameter is the current value and the power up default value TimerCounterConfig If the WriteMask bit 1 is set the value passed becomes the default value meaning it is written to flash and used at reset The return value of this parameter is a read of the power up default See Section 5 2 3 FIO EIO CIO If the WriteMask bit 1 is set the values passed become the default values meaning they are written to flash and used at reset Regardless of the mask bit this function has no effect on the current settings The return value of these parameters are a read of the power up defaults 94 DAC If the WriteM
105. ir applications using LabJack products To minimize the risks associated with customer applications customers should provide adequate design and operating safeguards Reproduction of products or written or electronic information from LabJack Corporation is prohibited without permission Reproduction of any of these with alteration is an unfair and deceptive business practice Copyright 2009 LabJack Corporation Declaration of Conformity Manufacturers Name LabJack Corporation Manufacturers Address 3232 S Vance St STE 100 Lakewood CO 80227 USA Declares that the product Product Name LabJack U3 LV HV Model Number LJU3 LV HV conforms to the following Product Specifications EMC Directive 89 336 EEC EN 55011 Class A EN 61326 1 General Requirements and is marked with CE Warranty The LabJack U3 comes with a 1 year limited warranty from LabJack Corporation covering this product and parts against defects in material or workmanship The LabJack can be damaged by misconnection such as connecting 120 VAC to any of the screw terminals and this warranty does not cover damage obviously caused by the customer If you have a problem contact support labjack com for return authorization In the case of warranty repairs the customer is responsible for shipping to LabJack Corporation and LabJack Corporation will pay for the return shipping LabJack U3 User s Guide Revision History V1 05 released March 13 2008 Firs
106. is too small it can be amplified before connecting to the LabJack One good way to handle low level signals such as thermocouples is the LJTick InAmp which is a 2 channel instrumentation amplifier module that plugs into the U3 screw terminals Go to labjack com for more information For a do it yourself solution the following figure shows an operational amplifier op amp configured as non inverting V e Vin e Op Ami AINX e R2 R1 GND Figure 2 2 Non Inverting Op Amp Configuration 22 The gain of this configuration is Vout Vin 1 R2 R1 100 kQ is a typical value for R2 Note that if R2 0 short circuit and R1 inf not installed a simple buffer with a gain equal to 1 is the result There are numerous criteria used to choose an op amp from the thousands that are available One of the main criteria is that the op amp can handle the input and output signal range Often a single supply rail to rail input and output RIRO is used as it can be powered from Vs and GND and pass signals within the range 0 Vs The OPA344 from Texas Instruments ti com is good for many 5 volt applications The op amp is used to amplify and buffer a signal that is referred to the same ground as the LabJack single ended If instead the signal is differential i e there is a positive and negative signal both of which are different than ground an instrumentation amplifier in amp should be used An in amp converts a different
107. is value corresponds to the specified bit of I O such that 1 High and O Low If all are low State d0 If all 20 standard digital I O are high State d1048575 If FIOO FIO2 are high EIOO EIO2 are high CIOO are high and all other I O are low b00000001000001 1100000111 State d67335 103 5 2 5 10 PortStateWrite 27 PortStateWrite 7 Command Bytes 0 IOType 27 1 3 WriteMask 4 6 State 0 Response Bytes This IOType writes the state of all digital I O where 0 7 FIO 8 15 ElO and 16 19 CIO The direction of the selected lines is forced to output e WriteMask Each bit specifies whether to update the corresponding bit of I O e State Each bit of this value corresponds to the specified bit of I O such that 1 High and O Low To set all low State d0 To set all 20 standard digital I O high State d1048575 To set FIOO FIO2 high EIOO EIO2 high CIOO high and all other I O low b00000001000001 11000001 11 State d67335 5 2 5 11 PortDirRead 28 PortDirRead 1 Command Byte 0 28 3 Response Bytes 0 2 Direction This IOType reads the directions of all digital I O where 0 7 FIO 8 15 EIO and 16 19 These are the digital directions only and do not provide any information as to whether the lines are configured as digital or analog e Direction Each bit of this value corresponds to the specified bit of I O such that 1 Output and 0 Input If all are input Direction d0 If all 20 standard
108. ithout accidentally getting data from one thread into another If requests are added and then results return LJE NO DATA AVAILABLE or a similar error chances are the requests and results are in different threads The driver tracks which thread a request is made in by the thread ID If a thread is killed and then a new one is created it is possible for the new thread to have the same ID Its not really a problem if Add is called first but if Get is called on a new thread results could be returned from the thread that already ended As mentioned the list of requests and results is kept on a thread by thread basis Since the driver cannot tell when a thread has ended the results are kept in memory for that thread regardless This is not a problem in general as the driver will clean it all up when unloaded When it can be a problem is in situations where threads are created and destroyed continuously This will result in the slow consumption of memory as requests on old threads are left behind Since each request only uses 44 bytes and as mentioned the ID s will eventually get recycled it will not be a huge memory loss In general even without this issue it is strongly recommended to not create and destroy a lot of threads It is terribly slow and inefficient Use thread pools and other techniques to keep new thread creation to a minimum That is what is done internally The one big exception to the thread safety of this driver is in the use of th
109. ksum16 LSB Checksum16 MSB 0x00 BlockNum 32 Bytes of Data Checksum8 OxF8 0x01 0x28 0x2B Checksum16 LSB Checksum16 MSB Errorcode 0x00 108 5 2 8 EraseMem EraseCal The U3 uses flash memory that must be erased before writing Command number 0x29 erases the entire user memory area Command number 2 erases the entire calibration memory area The EraseCal command has two extra constant bytes to make it more difficult to call the function accidentally Do not call this function while streaming Command Byte Ya a Response UJ gt ol Checksum8 OxF8 0x00 0x01 0x29 0x2C Checksum16 LSB Checksum16 MSB 0x4C 0x6C Checksum8 OxF8 0x01 0x29 0 2 Checksum16 LSB Checksum16 MSB Errorcode 0x00 109 5 2 9 Reset Causes a soft or hard reset A soft reset consists of re initializing most variables without re enumeration A hard reset is a reboot of the processor and does cause re enumeration Command Byte 0 Checksum8 1 0x99 2 ResetOptions Bit 1 Hard Reset Bit 0 Soft Reset 3 0x00 Response Byte 0 Checksum8 1 0x99 2 0x00 3 Errorcode 110 5 2 10 StreamConfig Stream mode operates on a table of channels that are scanned at the specified scan rate Before starting a stream you need to call this function to configure the table and scan clock Requires U3 hardware version 1 21 Command Byte Checksum8
110. l 8 bit DAC commands supported on all hardware versions To take advantage of the 10 bit resolution on hardware revision 1 30 new commands have been added Section 5 2 5 where the binary values are aligned to 16 bits The cal constants are still aligned to 8 bits however so the slope and offset should each be multiplied by 256 before using in the above formula The analog outputs can withstand a continuous short circuit to ground even when set at maximum output Voltage should never be applied to the analog outputs as they are voltage sources themselves In the event that a voltage is accidentally applied to either analog output they do have protection against transient events such as ESD electrostatic discharge and continuous overvoltage or undervoltage of a few volts There is an accessory available from LabJack called the LJTick DAC that provides a pair of 14 bit analog outputs with a range of 10 volts The LJTick DAC plugs into any digital I O block and thus up to 10 of these can be used per U3 to add 20 analog outputs The LUTick DAC improves on the various shortcomings of the built in DACs on the U3 Range of 10 0 to 10 0 volts Resolution of 14 bits Slew rate of 0 1 V us Based on a reference rather than regulator so more accurate and stable Does not affect analog inputs in any configuration 2 7 1 Typical Analog Output Connections 2 7 1 1 High Current Output The DACs on the U3 can output quite a bit of current
111. lO6 TimerO FlO7 2Counter1 2 Timers enabled CounterO enabled Counter1 enabled and TimerCounterPinOffset 8 EIOO TimerO 33 ElO1 Timer 1 ElO2 2CounterO ElO3 Counter1 Starting with hardware revision 1 30 timers counters cannot appear on FIOO 3 and thus TimerCounterPinOffset must be 4 8 A value of 0 3 will result in an error This error can be suppressed by a power up default setting in LJControlPanel If suppressed a 0 3 will result in an offset of 4 Timers and counters can appear on various pins but other I O lines never move For example Timer1 can appear anywhere from FIO4 to EIO1 depending on TimerCounterPinOffset and whether TimerO is enabled On the other hand FIO5 for example is always the screw terminal labeled FIO5 and AIN5 if enabled is always on that same screw terminal Note that CounterO is not available with certain timer clock base frequencies In such a case it does not use an external FIO EIO pin An error will result if an attempt is made to enable CounterO when one of these frequencies is configured Similarly an error will result if an attempt is made to configure one of these frequencies when Counter is enabled Applicable digital I O are automatically configured as input or output as needed when timers and counters are enabled and stay that way when the timers counters are disabled See Section 2 8 1 for information about signal connections Each counter CounterO or Counter1 consists
112. le AddRequest l1ngHandle LJ ioPUT TIMER VALUE 0 32768 0 0 Configure Timerl as duty cycle input AddRequest l1ngHandle LJ ioPUT TIMER MODE 1 LJ tmDUTYCYCLE 0 0 73 Execute the requests GoOne lngHandle The following pseudocode demonstrates reading input timers counters and updating the values of output timers The e functions are used in the following pseudocode but some applications might combine the following calls into a single add go get block so that a single low level call is used Change Timer0 PWM duty cycle to 25 ePut lngHandle LJ ioPUT TIMER VALUE 0 49152 0 Read duty cycle from Timerl eGet lngHandle LJ ioGET TIMER 1 amp dbiValue 0 The duty cycle read returns a 32 bit value where the least significant word LSW represents the high time and the most significant word MSW represents the low time The times returned are the number of cycles of the timer clock In this case the timer clock was set to 1 MHz so each cycle is 1 microsecond dblHighCycles double unsigned long dblValue 65536 dblLowCycles double unsigned long dblValue 65536 dblDutyCycle 100 dblHighCycles dblHighCycles dblLowCycles dblHighTime 0 000001 dblHighCycles dblLowTime 0 000001 dblLowCycles Read the count from Counterl This is an unsigned 32 bit value eGet lngHandle LJ ioGET COUNTER 1 amp dblValue 0 Following is pseudocode to rese
113. ling Relays All the digital I O lines have series resistance that restricts the amount of current they can sink or source but solid state relays SSRs can usually be controlled directly by the digital I O The SSR is connected as shown in the following diagram where VS 5 volts connects to the positive control input and the digital I O line connects to the negative control input sinking configuration Solid State Relay VS Ext Load Control Supply Load 3 e Digital I O Figure 2 12 Relay Connections Sinking Control High Side Load Switching When the digital line is set to output low control current flows and the relay turns on When the digital line is set to input control current does not flow and the relay turns off When the digital line is set to output high some current flows but whether the relay is on or off depends on the specifications of a particular relay It is recommended to only use output low and input For example the Series 1 D12 D24 or Series T TD12 TD24 relays from Crydom specify a max turn on of 3 0 volts a min turn off of 1 0 volts and a nominal input impedance of 1500 Q e When the digital line is set to output low it is the equivalent of a ground connection with 180 EIO CIO or 550 FIO in series When using an EIO CIO line the resulting voltage across the control inputs of the relay will be about 5 1500 1500 180 4 5 volts the other 0 5 volts is dropped across the internal re
114. ll eAddGoGet LJ HANDLE Handle long NumRequests long alOTypes long aChannels double aValues long ax1s long aRequestErrors long GoError long aResultErrors Parameter Description Returns LabJack errorcodes or for no error Inputs e Handle Handle returned by OpenLabJack e NumRequests This is the number of requests that will be made and thus the number of results that will be returned All the arrays must be initialized with at least this many elements alOTypes An array which is the list of IOTypes aChannels An array which is the list of Channels aValues An array which is the list of Values to write ax1s An array which is the list of x1s Outputs aValues An array which is the list of Values read e aRequestErrors An array which is the list of errorcodes from each AddRequest e GoError The errorcode returned by the GoOne call e aResultErrors An array which is the list of errorcodes from each GetResult 4 2 5 AddRequest Adds an item to the list of requests to be performed on the next call to Go or GoOne When AddRequest is called on a particular Handle all previous data is erased and cannot be retrieved by any of the Get functions until a Go function is called again This is on a device by device basis so you can call AddRequest with a different handle while a device is busy performing its I O AddRequest only clears the request and result lists
115. log input readings Mechanical relays require more control current than SSRs and cannot be controlled directly by the digital I O on the To control higher currents with the digital I O some sort of buffer is used Some options are a discrete transistor e g 2N2222 a specific chip e g ULN2003 or an op amp Note that the U3 DACs can source enough current to control almost any SSR and even some mechanical relays and thus can be a convenient way to control 1 or 2 relays The RB12 relay board is a useful accessory available from LabJack This board connects to the DB15 connector on the U3 and accepts up to 12 industry standard I O modules designed for Opto22 G4 modules and similar Another accessory available from LabJack is the LJTick RelayDriver This is a two channel module that plugs into the U3 screw terminals and allows two digital lines to each hold off up to 50 volts and sink up to 200 mA This allows control of virtually any solid state or mechanical relay 2 9 Timers Counters The U3 has 2 timers TimerO Timer1 and 2 counters CounterO Counter1 When any of these timers or counters are enabled they take over an FIO EIO line in sequence TimerO Timer1 Counter0 then Counter1 starting with FIO0 TimerCounterPinOffset Some examples 1 Timer enabled CounterO disabled Counter1 disabled and TimerCounterPinOffset 4 FlOA TimerO 1 Timer enabled CounterO disabled Counter1 enabled and TimerCounterPinOffset 6 F
116. lue Differential readings are signed while single ended readings are unsigned e Backlog When streaming the processor acquires data at precise intervals and transfers it to a FIFO buffer until it can be sent to the host This value represents how much data is left in the buffer after this read The value ranges from 0 255 where 256 would equal 100 full Stream mode on the U3 uses a feature called auto recovery If the stream buffer gets too full the U3 will go into auto recovery mode In this mode the U3 no longer stores new scans in the buffer but rather new scans are discarded Data already in the buffer will be sent until the buffer contains less samples than SamplesPerPacket and every StreamData packet will have errorcode 59 Once the stream buffer contains less samples than SamplesPerPacket the U3 will start to buffer new scans again The next packet returned will have errorcode 60 This packet will have 1 dummy scan where each sample is OxFFFF and this scan separates new data from any pre auto recovery data Note that the dummy scan could be at the beginning middle or end of this packet and can even extend to following packets Also the TimeStamp parameter in this packet contains the number of scans that were discarded allowing correct time to be calculated The dummy scan counts as one of the missing scans included in the TimeStamp value 114 5 2 13 StreamStop Requires U3 hardware version 1 21 Command Byte 0 OxBO 1
117. lue MSB 4 Response Bytes 0 Timer LSB 1 Timer 2 Timer 3 Timer MSB This IOType provides the ability to update reset a given timer and read the timer value e Value These values are only updated if the UpdateReset bit is 1 The meaning of this parameter varies with the timer mode e Timer Returns the value from the timer module This is the value before reset if reset was done 105 5 2 5 16 Timer Config lOType 43 45 Timer Config 4 Command Bytes 0 lOType 43 45 1 TimerMode 2 Value LSB 3 Value MSB 0 Response Bytes This IOType configures a particular timer e TimerMode See Section 2 9 for more information about the available modes e Value The meaning of this parameter varies with the timer mode 5 2 5 17 Counter lOType 54 55 Counter 2 Command Bytes 0 lOType 54 55 1 Bit Reset 4 Response Bytes 0 Counter LSB 1 Counter 2 Counter 3 Counter MSB This IOType reads a hardware counter and optionally can do a reset e Reset Setting this bit resets the counter to 0 after reading e Counter Returns the current count from the counter if enabled This is the value before reset if reset was done 5 2 5 18 Buzzer 63 Buzzer 6 Command Bytes IOType 63 Bit 0 Continuous Period LSB Period MSB Toggles LSB Toggles MSB 0 Response Bytes This IOType is used to make the buzzer buzz The buzzer is only available on hardware revisions 1 20 and 1 21 not on 1 30 e C
118. lue parameter from the start stream command actualScanRate dblValue actualSampleRate 2 dblValue Once a stream is started the data must be retrieved periodically to prevent the buffer from overflowing To retrieve data add a request with 27 iocgT srREAM DATA The Channel parameter should be rz cHANNELS or a specific channel number ignored for a single channel stream The Value parameter should be the number of scans all channels or samples single channel to retrieve The x1 parameter should be a pointer to an array that has been initialized to a sufficient size Keep in mind that the required number of elements if retrieving all channels is number of scans number of channels Data is stored interleaved across all streaming channels In other words if two channels are streaming 0 and 1 and 27 cnarn cHawwELs is the channel number for the read request the data 76 will be returned as ChannelO Channel1 ChannelO Channel1 etc Once the data is read it is removed from the internal buffer and the next read will give new data If multiple channels are being streamed data can be retrieved one channel at a time by passing a specific channel number in the request In this case the data is not removed from the internal buffer until the last channel in the scan is requested Reading the data from the last channel not necessarily all channels is the trigger that causes the block of data to be re
119. ly with the same parameters thus requesting the same type of connection to the same LabJack the driver will simply return the same LJ HANDLE every time Internally nothing else happens This includes when the device is reset or disconnected Once the device is reconnected the driver will maintain the same handle If an open call is made for USB and then Ethernet a different handle will be returned for each connection type and both connections will be open OpenLabJackS is a special version of open where DeviceType and ConnectionType strings rather than longs This is useful for passing string constants in languages that cannot include the header file The strings should contain the constant name as indicated in the header file such as LJ dtU3 and LJ ctUSB The declaration for the S version of open is the same as below except for const char pDeviceType const char pConnectionType Declaration LJ ERROR stdcall OpenLabJack long DeviceType long ConnectionType const char pAddress long FirstFound LJ HANDLE pHandle Parameter Description Returns LabJack errorcodes or 0 for no error Inputs e DeviceType The type of LabJack to open Constants are in the labjackud h file e ConnectionType Enter the constant for the type of connection USB or Ethernet e pAddress Pass the local ID or serial number of the desired LabJack If FirstFound is true Address is ignored e FirstFound If true then the
120. mal digital numbers as specified in Section 2 8 e NumSPIBytesToTransfer Specifies how many SPI bytes will be transferred 1 50 The initial state of SCK is set properly CPOL by this function before CS chip select is brought low final state is also set properly before CS is brought high again If CS is being handled manually outside of this function care must be taken to make sure SCK is initially set to CPOL before asserting CS All standard SPI modes supported A B C and D Mode A CPHA 1 CPOL 1 Mode B CPHA 1 CPOL 0 Mode C CPHA 0 CPOL 1 Mode D CPHA 0 CPOL 0 If Clock Phase CPHA is 1 data is valid on the edge going to CPOL If CPHA is O data is valid on the edge going away from CPOL Clock Polarity CPOL determines the idle state of SCK Up to 50 bytes can be written read Communication is full duplex so 1 byte is read at the same time each byte is written 119 5 3 16 AsynchConfig Requires U3 hardware version 1 21 Configures the U3 UART for asynchronous communication On hardware version 1 30 the TX transmit and RX receive lines appear on FIO EIO after any timers and counters so with no timers counters enabled and pin offset set to 4 TX FlO4 RX FIO5 On hardware version 1 21 the UART uses SDA for TX and SCL for RX Communication is in the common 8 n 1 format Similar to RS232 except that the logic is normal CMOS TTL Connection to an RS232 device will require a converter chip such as the
121. ment specifies to read that counter For the U3 this array must always have at least 2 elements e aResetCounters An array where each element specifies whether to reset that counter A nonzero value for an array element specifies to reset that counter For the U3 this array must always have at least 2 elements aTimerValues An array where each element is the new value for that timer Each value is only updated if the appropriate element is set in the aUpdateResetTimers array For the U3 this array must always have at least 2 elements e Reserved 1 amp 2 Pass 0 Outputs aTimerValues An array where each element is the value read from that timer if the appropriate element is set in the aReadTimers array e aCounterValues An array where each element is the value read from that counter if the appropriate element is set in the aReadCounters array 67 4 3 Example Pseudocode The following pseudocode examples are simplified for clarity and in particular no error checking is shown The language used for the pseudocode is C 4 3 1 Open The initial step is to open the LabJack and get a handle that the driver uses for further interaction The DeviceType for the U3 is LJ_dtu3 There is only one valid ConnectionType for the U3 LJ ctUSB Following is example pseudocode to open a U3 over USB Open the first found LabJack U3 over USB OpenLabJack LJ dtU3 LJ ctUSB 1 TRUE amp lngHandle The reason for the quo
122. mory area We need a single I2C transmission that writes the address and then reads the data That is there needs to be an ack after writing the address not a stop condition To accomplish this we use Add Go Get to combine the write and read into a single low level call numWrite 1 array 0 0 Memory address User area is 0 63 AddRequest lngHandle LJ ioI2C COMMUNICATION LJ_chI2C_WRITE numWrite array 0 numRead 4 AddRequest lngHandle LJ ioI2C COMMUNICATION LJ chl2C READ numRead array 0 Execute the requests GoOne 1ngHandle For more example code see the I2C cpp example in the VC6 LJUD archive 4 3 12 Asynchronous Serial Communication The U3 hardware version 1 21 only has a UART available that supports asynchronous serial communication On hardware version 1 30 the TX transmit and RX receive lines appear on FIO EIO after any timers and counters so with no timers counters enabled and pin offset set to 4 TX FlO4 and RX FIO5 On hardware version 1 21 the UART uses SDA for TX and SCL for RX Communication is in the common 8 n 1 format Similar to RS232 except that the logic is normal CMOS TTL Connection to an RS232 device will require a converter chip such as the MAX233 which inverts the logic and shifts the voltage levels This serial link is not an alternative to the USB connection Rather the host application will write read data to from the U3 over USB and the USB communicat
123. moved from the buffer This means that if three channels are streaming 0 1 and 2 in that order in the scan list and data is requested from channel 0 then channel 1 then channel 0 again the request for channel 0 the second time will return the same data as the first request New data will not be retrieved until after channel 2 is read since channel 2 is last in the scan list If the first get stream data request is for 10 samples from channel 1 the reads from channels 0 and 2 also must be for 10 samples Note that when reading stream data one channel at a time not using LJ chALL CHANNELS the scan list cannot have duplicate channel numbers There are three basic wait modes for retrieving the data e LJ swNONE The Go call will retrieve whatever data is available at the time of the call up to the requested amount of data A Get command should be called to determine how many scans were retrieved This is generally used with a software timed read interval The number of samples read per loop iteration will vary but the time per loop iteration will be pretty consistent Since the LabJack clock could be faster than the PC clock it is recommended to request more scans than are expected each time so that the application does not get behind e LJ swSLEEP This makes the Go command a blocking call The Go command will loop until the requested amount of is retrieved or no new data arrives from the device before timeout In this mode the hardware
124. mplitude will decrease The output does not necessarily start instantly but rather waits for the internal clock to roll For example if the output frequency is 100 Hz that means the period is 10 milliseconds and thus after the command is received by the device it could be anywhere from 0 to 10 milliseconds before the start of the frequency output 2 9 1 8 Quadrature Input Mode 8 Requires both timers where TimerO will be quadrature channel A and Timer will be quadrature channel B Timer Value passed has no effect The does 4x quadrature counting and returns the current count as a signed 32 bit integer 2 s complement The same current count is returned on both timer value parameters Writing a value of zero to either or both timers performs a reset of both After reset a read of either timer value will return zero until a new quadrature count is detected If a timer is reset and read in the same function call the read returns the value just before the reset 2 9 1 9 Timer Stop Input Mode 9 This mode should only be assigned to Timer1 On every rising edge seen by the external pin this mode increments a 16 bit register When that register matches the specified timer value stop count value TimerO is stopped The range for the stop count value is 1 65535 Generally the signal applied to Timer1 is from TimerO which is configured as output One place where this might be useful is for stepper motors allowing control over a ce
125. n of the version and the higher byte is the fractional portion of the version SerialNumber Fixed parameter that is unique for every LabJack ProductlD 3 Fixed parameter identifies this LabJack as a U3 VersionInfo Bit 0 specifies U3B Bit 1 specifies and if set then bit 4 specifies HV version 95 5 2 3 ConfiglO Writes and reads the current IO configuration Command Byte 0 Checksum8 1 OxF8 2 0x03 3 0x0B 4 Checksum16 LSB 5 Checksum16 MSB 6 WriteMask Bit 4 Reserved Pass 0 Bit 3 ElOAnalog Bit 2 FlOAnalog Bit 1 DAC1Enable Bit 0 TimerCounterConfig 7 Reserved 8 TimerCounterConfig Bits 4 7 TimerCounterPinOffset Bit 3 Enable Counter1 Bit 2 Enable CounterO Bits 0 1 Number of timers enabled 9 DAC1Enable ignored on hardware rev 1 307 Bit 1 Reserved Pass 0 Bit 0 Enable DAC1 10 FlOAnalog 11 ElOAnalog Response Byte 0 Checksum8 1 OxF8 2 0x03 3 OxOB 4 Checksum16 LSB 5 Checksum16 MSB 6 Errorcode 7 Reserved 8 TimerCounterConfig 9 DAC1Enable 10 FlOAnalog 11 ElOAnalog WriteMask Has bits that determine which if any of the parameters will be written TimerCounterConfig Used to enable disable timers and counters Timers counters will be assigned to IO pins starting with FIOO plus TimerCounterPinOffset 4 8 only starting with hardware revision 1 30 Timer takes the first IO pin then Timer1 CounterO and Counter1 Whenever this function is called and timers ar
126. n type of digital signal Rather than providing 5 volts and ground like the push pull signal an open collector signal provides ground and high impedance This type of signal can be thought of as a switch connected to ground Since the U3 digital inputs have a 100 kQ internal pull up resistor an open collector signal can generally be connected directly to the input When the signal is inactive it is not driving any voltage and the pull up resistor pulls the digital input to logic high When the signal is active it drives O volts which overpowers the pull up and pulls the digital input to logic low Sometimes an external pull up e g 4 7 from Vs to digital input will be installed to increase the strength and speed of the logic high condition VS Open Collector Pis i Digital Signal Input Rground Signal Ground is oe SGND Figure 2 9 Open Collector NPN Connection To Digital Input Figure 2 9 shows typical connections Rground is typically 0 100 Rseries is typically 0 and the external pull up resistor is generally not required If there is some uncertainty about whether the signal is really open collector or could drive a voltage beyond 5 8 volts use an Rseries of 22 kQ as discussed in Section 2 8 1 1 and the input should be compatible with an open collector signal or a driven signal up to at least 48 volts Note that an individual ground connection is often not needed for every signal Any signals powe
127. nally by the S functions but could be useful to the end user when using the GetFirst Next functions without the ability to include the header file In this case a comparison could be done on the return values such as if IOType StringToConstant LJ_ioANALOG_INPUT This function returns LJ INVALID CONSTANT if the string is not recognized Declaration long _stdcall StringToConstant const char pString Parameter Description Returns Constant number of the passed string Inputs e pString A pointer to the string representation of the constant Outputs e None 4 2 13 ErrorToString Outputs a string describing the given errorcode or an empty string if not found Declaration void stdcall ErrorToString LJ ERROR ErrorCode char pString Parameter Description Returns LabJack errorcodes or for no error Inputs e ErrorCode LabJack errorcode e pString Must pass a buffer for the string of at least 256 bytes Outputs e pString A pointer to the string representation of the errorcode 62 4 2 14 GetDriverVersion Returns the version number of this Windows LabJack driver Declaration double stdcall GetDriverVersion Parameter Description Returns Driver version Inputs e None Outputs e None 4 2 15 TCVoltsToTemp A utility function to convert thermocouple voltage readings to temperature Declaration LJ ERROR _stdcall TCVoltsToTemp long TCType double TCVolts double C
128. nalog input readings to voltages The high level Windows DLL LabJackUD does this automatically 18 Starting Block Byte Nominal Value 0 0 LV AIN SE Slope 3 7231E 05 volts bit 0 8 LV AIN SE Offset 0 0000E 00 volts 0 16 LV AIN Diff Slope 7 4463E 05 volts bit 0 24 LV AIN Diff Offset 2 4400E 00 volts 1 0 DACO Slope 5 1717 01 bits volt 1 8 DACO Offset 0 0000E 00 bits 1 16 DAC1 Slope 5 1717E 01 bits volt 1 24 DAC1 Offset 0 0000E 00 bits 2 0 Temp Slope 1 3021E 02 degk bit 2 8 Vref Cal 2 4400E 00 volts 2 16 Vref 1 5 Cal 3 6600E 00 volts 2 24 Vreg Cal 3 3000E 00 volts Table 2 8 Normal Calibration Constant Memory Locations Starting Block Byte Nominal Value 3 0 HV AINO Slope 0 000314 volts bit 3 8 HV AIN1 Slope 0 000314 volts bit 3 16 HV AIN2 Slope 0 000314 volts bit 3 24 HV AIN3 Slope 0 000314 volts bit 4 0 HV AINO Offset 10 3 volts 4 8 HV AIN1 Offset 10 3 volts 4 16 HV AIN2 Offset 10 3 volts 4 24 HV AIN3 Offset 10 3 volts Table 2 9 Additional High Voltage Calibration Constant Memory Locations Each value in Table 2 7 is stored in 64 bit fixed point format signed 32 32 little endian 2 s complement Following are some examples of fixed point byte arrays and the associated floating point double values Fixed Point Byte Array LSB MSB Floating Point Double 0 0 0 0 0 0 0 0 0 0000000000 0 0 0 0 1 0 0 0 1 0000000000 0 0 0 0 255 255 255 255 1 0000000000 51 51 51 51 0 0 0 0 0 2000000000 205 2
129. nchBytesInRXBuffer 0x00 U oonoas on gt ok e NumAsynchWords This is the number of asynch data bytes divided by 2 If the number of bytes is odd round up and add an extra zero to the packet e NumAsynchBytesToSend Specifies how many bytes will be sent 0 56 e NumAsynchBytesInRXBuffer Returns how many bytes are currently in the RX buffer 121 5 3 18 AsynchRX Requires U3 hardware version 1 21 Reads the oldest 32 bytes from the U3 UART RX buffer received on receive terminal The buffer holds 256 bytes Command NOOR WN Response U eVOGRON og Ce e Flush Empties the entire 256 byte RX buffer If there are than 32 bytes the Checksum8 OxF8 0x01 0x16 Checksum16 LSB Checksum16 MSB 0x00 Flush Checksum8 OxF8 0x11 0x16 Checksum16 LSB Checksum16 MSB Errorcode NumAsynchBytesInRXBuffer AsynchByteO AsynchByte31 buffer that data is lost e NumAsynchBytesInRXBuffer Returns the number of bytes in the buffer before this read e AsynchByte Returns the 32 oldest bytes from the RX buffer 122 5 3 19 12C Requires hardware version 1 21 Sends and receives serial data using C 12C synchronous communication Command Byte 0 Checksum8 1 OxF8 2 4 Num I2CWordsSend 3 Ox3B 4 Checksum16 LSB 5 Checksum16 MSB 6 I2COptions Bit 1 ResetAtStart Bit 0 Reserved 7 SpeedAdjust 8 SDAPinNum 9 SCLPinNum 10 AddressByte 11 R
130. nfiguration and all other digital operations on these pins are ignored FIO4 EIO7 are still available as flexible I O same as the U3 LV Because the scaling on the high voltage inputs on the U3 HV AINO AIN3 is inherently single ended a factory calibration is not possible for differential readings If a differential reading is requested where either channel is a high voltage channel the driver will return the raw binary reading and the user must handle calibration conversion The analog inputs have a QuickSample option where each conversion is done faster at the expense of increased noise This is enabled by passing a nonzero value for put config special channel charN RESOLUTION There is also a LongSettling option where additional settling time is added between the internal multiplexer configuration and the analog to digital conversion This allows signals with more source impedance and is enabled by passing a nonzero value for put config special channel 27 cnarw sETTLING TIME Both of these options are disabled by default Note that sinking excessive current into digital outputs can cause substantial errors in analog input readings See Section 2 8 1 4 for more info 2 6 1 Channel Numbers The LabJack U3 has up to 16 external analog inputs plus a few internal channels The low level functions specify a positive and negative channel for each analog input conversion With the LabJackUD driver the zs Aarwis used fo
131. number of bytes 0 52 x1 array LJ chlI2C WRITE Value number of bytes 0 50 1 array LJ chI2C GET ACKS The following are special channels used with the get put config IOTypes to configure various parameters related to the I C bus See the low level function description in Section 5 3 19 for more information about these parameters LJ chlI2C ADDRESS BYTE LJ chl2C SCL PIN NUM 0 19 Pull up resistor usually required LJ chlI2C SDA PIN NUM 0 19 Pull up resistor usually required LJ chl1I2C OPTIONS LJ chI2C SPEED ADJUST The LJTick DAC is an accessory from LabJack with an I C 24C01C EEPROM chip Following is example pseudocode to configure l C to talk to that chip The AddressByte of the EEPROM on the LJTick DAC is or decimal 160 AddRequest lngHandle LJ ioPUT CONFIG LJ chl2C ADDRESS BYTE 160 0 0 SCL is FIOO AddRequest lngHandle LJ ioPUT CONFIG LJ chl2C SCL PIN NUM 0 0 0 81 SDA is 1 AddRequest lngHandle LJ ioPUT CONFIG LJ chl12C SDA PIN NUM 1 0 0 See description of low level I2C function AddRequest lngHandle LJ ioPUT CONFIG LJ chI2C OPTIONS 0 0 0 See description of low level I2C function 0 is max speed of about 150 kHz AddRequest lngHandle LJ ioPUT CONFIG LJ chl12C SPEED ADJUST 0 0 0 Execute the configuration requests GoOne lngHandle Following is pseudocode to read 4 bytes from the EEPROM Initial read of EEPROM bytes 0 3 in the user me
132. o i rt e M Dota Ub 57 4 20 GO C 58 BDU SSO OMG Er 59 42 9 edet bean arene titan che 59 4 2 9 GetFirstResult and 5 60 4 2 10 DoubleToStringAddress teda o etn cate toc e eee cete dne 61 4 2 11 StringToDoubleAddress ER RR 61 4 2 12 StringToGonstant u ii e e bete totos ERE HR EAEE AAEN tuse bre iie erui a 62 4 2 13 EIOrFaStting PAEA aE ende teet teer a 62 42 714 GelDnverversiori sssscadiotina tions wet Ot a pc ett Cs Dru amd ep scum IUE 63 4 2 15 LOT uuo euch bte uterus tegen tN Ree rna uc e P Unde 63 42 15 TIResalbabJack ete nee oit ere i bodie eed ocu Are uis 63 D neta etti uina unam dd S 64 4 248 ODAC is ces eet ge are eere GR ae rate es RP E A ee ig ales ER ERR ud ce ees 64 4 2 19 65 4 2 20 6DO iiia RT edi 65 42 21 eT GGonflg M E ee tei SSR A n e Ee cay 66 4222 SIS INITIO 67 4 3 Example Pseudocode teret tede rte go yo EVER Re RETE Pena 68 4 34 ODOM aac iic ptt t Uo t e he dritten deren bib 68 432 COMIQUIAUOM c 68 4 3 3
133. of 256 aTimerModes An array where each element is a constant specifying the mode for that timer For the U3 this array must always have at least 2 elements aTimerValues An array where each element is specifies the initial value for that timer For the U3 this array must always have at least 2 elements Reserved 1 amp 2 Pass 0 66 4 2 22 eTCValues An easy function that updates and reads all the timers and counters This is a simple alternative to the very flexible IOType based method normally used by this driver Declaration LJ ERROR stdcall eTCValues LJ HANDLE Handle long aReadTimers long aUpdateResetTimers long aReadCounters long aResetCounters double aTimerValues double aCounterValues long Reserved1 long Reserved2 Parameter Description Returns LabJack errorcodes or 0 for no error Inputs e Handle Handle returned by OpenLabJack e aReadTimers An array where each element specifies whether to read that timer A nonzero value for an array element specifies to read that timer For the U3 this array must always have at least 2 elements e aUpdateResetTimers An array where each element specifies whether to update reset that timer A nonzero value for an array element specifies to update reset that timer For the U3 this array must always have at least 2 elements e aReadCounters An array where each element specifies whether to read that counter A nonzero value for an array ele
134. of a 32 bit register that accumulates the number of falling edges detected on the external pin If a counter is reset and read in the same function call the read returns the value just before the reset The timers TimerO Timer1 have various modes available Timer Modes 16 bit PWM output 8 bit PWM output Period input 32 bit rising edges Period input 32 bit falling edges Duty cycle input Firmware counter input Firmware counter input with debounce Frequency output Quadrature input Timer stop input odd timers only System timer low read default mode System timer high read Period input 16 bit rising edges Period input 16 bit falling edges SOMNADAWNAO _ WN Both timers use the same timer clock There are 7 choices for the timer base clock 34 TimerBaseClock 4 MHz 12 MHz 48 MHz Default 1 MHz Divisor 4 MHz Divisor 12 MHz Divisor 48 MHz Divisor Note that these clocks apply to the U3 hardware revision 1 21 With hardware revision 1 20 all clocks are half of the values above The first 3 clocks have a fixed frequency and are not affected by TimerClockDivisor The frequency of the last 4 clocks can be further adjusted by TimerClockDivisor but when using these clocks Counter0 is not available When Counter0 is not available it does not use an external FIO EIO pin The divisor has a range of 0 255 where 0 corresponds to a division of 256 Note that the DACs Sec
135. on Execution Times QuickSample 0 LongSettling 1 44 A USB high high configuration means the U3 is connected to a high speed USB2 hub which is then connected to a high speed USB2 host Even though the U3 is not a high speed USB device such a configuration does provide improved performance The analog inputs have a QuickSample option where each conversion is done faster at the expense of increased noise This is enabled by passing a nonzero value for put config special channel charN nEsOLUTION There is also a LongSettling option where additional settling time is added between the internal multiplexer configuration and the analog to digital conversion This allows signals with more source impedance and is enabled by passing a nonzero value for put config special channel 27 serTLING TriME Both of these options are disabled by default so the first table above shows the default conditions The first row in each of the above tables AIN 0 includes a write and read to all I O on the U3 besides analog inputs digital DACs timers and counters The tables above were measured with U3 hardware version 1 21 which started shipping in late August of 2006 The times could be up to twice as long with hardware version 1 20 or less 45 3 2 Stream Mode The highest input data rates are obtained in stream mode which is supported with U3 hardware version 1 21 or higher Hardware version 1 21 started shipping in late August of
136. on the device handle passed and only for the current thread For example if a request is added to each of two different devices and then a new request is added to the first device but not the second a call to Go will cause the first device to execute the new request and the second device to execute the original request 57 In general the execution order of a list of requests in a single Go call is unpredictable except that all configuration type requests are executed before acquisition and output type requests AddRequestS is a special version of the Add function where IOType is a string rather than a long This is useful for passing string constants in languages that cannot include the header file and is generally used with all IOTypes except put get config The string should contain the constant name as indicated in the header file such as LJ ioANALOG The declaration for the S version of Add is the same as below except for const char plOType i AddRequestSS is a special version of the Add function where IOType and Channel are strings rather than longs This is useful for passing string constants in languages that cannot include the header file and is generally only used with the put get config The strings should contain the constant name as indicated in the header file such as LJ ioPUT CONFIG and LJ chLOCALID The declaration for the SS version of Add is the same as below except for
137. on with the request to allow a generic parser to determine what should be done when the results are received 4 1 1 Function Flexibility The driver is designed to be flexible so that it can work with various different LabJacks with different capabilities It is also designed to work with different development platforms with different capabilities For this reason many of the functions are repeated with different forms of parameters although their internal functionality remains mostly the same In this documentation a group of functions will often be referred to by their shortest name For example a reference to Add or AddRequest most likely refers to any of the three variations AddRequest AddRequestS AddRequestSS In the sample code alternate functions S or SS versions can generally be substituted as desired changing the parameter types accordingly All samples here are written in pseudo C Functions with an S or SS appended are provided for programming languages that can t include the LabJackUD h file and therefore can t use the constants included It is generally poor programming form to hardcode numbers into function calls if for no other reason than it is hard to read Functions with a single S replace the IOType parameter with a const char which is a string A string can then be passed with the name of the desired constant Functions with a double SS replace both the IOType and Channel with strings OpenLabJa
138. ontinuous If this bit is set the buzzer will toggle continuously e Period This value determines how many main firmware loops the processor will execute before toggling the buzzer voltage e Toggles If Continuous is false this value specifies how many times the buzzer will toggle 106 5 2 6 ReadMem ReadCal Reads 1 block 32 bytes from the non volatile user or calibration memory Command number 2 accesses the user memory area which consists of 256 bytes block numbers 0 7 Command number Ox2D accesses the calibration memory area which consists of 96 bytes block numbers 0 2 Do not call this function while streaming Command Response C2 U UJ Checksum8 OxF8 0x01 Ox2A 0x2D Checksum16 LSB Checksum16 MSB 0x00 BlockNum Checksum8 OxF8 0x11 Ox2A 0x2D Checksum16 LSB Checksum16 MSB Errorcode 0x00 32 Bytes of Data 107 5 2 7 WriteMem WriteCal Writes 1 block 32 bytes to the non volatile user or calibration memory Command number 0x28 accesses the user memory area which consists of 256 bytes block numbers 0 7 Command number 0x2B accesses the calibration memory area which consists of 96 bytes block numbers 0 2 Memory must be erased before writing Do not call this function while streaming Command Byte NOOR WN O S do 9 Response UJ Checksum8 OxF8 0x11 0x28 0x2B Chec
139. ooo oood 131 0 50 l 1 60 4 PLCS PCB MOUNTING HOLES PCB AND CONNECTORS DIMENSIONS IN INCHES DIMENSIONS IN INCHES 0 18 ponds D 1 80 OOOO OOOO PIN HEADER DIMENSIONS IN INCHES SQ TYP O 132 JP3 JP2 JP1 1 385 x 2 5 2 29 x 2 5 3 2 x 2 5 J4 0 9 x 2 1 2 2 X 2 1 2 7 x 2 1 J2 3 4 x 1 65 USB1 0 3 x 687 J3 2 0 x 59 0 9 x 5 27 x 0 5 0 0 JP6 JP5 JP4 0 1 x 0 8 0 1 x 1 7 0 1 x 2 6 U3 PCB drawing showing the coordinates in Inches for pin 1 of each connector 133
140. ort 5 WaitShort 2 Command Bytes 0 lOType 5 1 Time 128 us Response Bytes This IOType provides a way to add a delay during execution of the Feedback function The typical use would be putting this IOType in between IOTypes that set a digital output line high and low thus providing a simple way to create a pulse Note that this IOType uses the same internal timer as stream mode so cannot be used while streaming e Time This value 0 255 is multiplied by 128 microseconds to determine the delay 5 2 5 3 WaitLong lOType 6 WaitLong 2 Command Bytes 0 lOType 6 1 Time 32 ms 0 Response Bytes This IOType provides a way to add a delay during execution of the Feedback function The typical use would be putting this IOType in between IOTypes that set a digital output line high 101 and low thus providing a simple way to create a pulse Note that this IOType uses the same internal timer as stream mode so cannot be used while streaming e Time This value 0 255 is multiplied by 32 milliseconds to determine the delay 5 2 5 4 LED lOType 9 LED 2 Command Bytes 0 lOType 9 1 State 0 Response Bytes This IOType simply turns the status LED on or off e State 1 On 0 Off 5 2 5 5 BitStateRead lOType 10 BitStateRead 2 Command Bytes 0 10 1 Bits 0 4 IO Number 1 Response Byte 0 Bit 0 State This IOType reads the state of a single bit of digital I O Only lines configured as digit
141. provided for tracking information or whatever else the user might need None of the Get functions clear results from the list The first AddRequest call subsequent to a Go call will clear the internal lists of requests and results for a particular device When processing raw in out or stream data requests the call to a Get function does not actually cause the data arrays to be filled The arrays are filled during the Go call if data is available and the Get call is used to find out many elements were placed in the array 60 It is acceptable to pass NULL or 0 for any pointer that is not required The parameter lists are the same for the GetFirstResult and GetNextResult declarations Declaration LJ ERROR stdcall GetFirstResult LJ HANDLE Handle long plOType long pChannel double pValue long px1 double pUserData Parameter Description Returns LabJack errorcodes or for no error Inputs e Handle Handle returned by OpenLabJack Outputs plOType A pointer to the IOType of this item in the list pChannel A pointer to the channel number of this item in the list pValue A pointer to the result value px1 A pointer to the x1 parameter of this item in the list pUserData A pointer to data that is simply passed along with the request and returned unmodified Can be used to store any sort of information with the request to allow a generic parser to determine what should be done when the res
142. r const char plOType GetResultSS is a special version of the Get function where IOType and Channel are strings rather than longs This is useful for passing string constants in languages that cannot include the header file and is generally only used with the put get config OTypes The strings should contain the constant name as indicated in the header file such as LJ ioPUT CONFIG and LJ chLOCALID The declaration for the SS version of Get is the same as below except for const char plOType const char pChannel It is acceptable to pass NULL or 0 for any pointer that is not required Declaration LJ ERROR stdcall GetResult LJ HANDLE Handle long IOType long Channel double pValue Parameter Description Returns LabJack errorcodes or 0 for no error Inputs e Handle Handle returned by OpenLabJack e lOType The type of request See Section 4 3 e Channel The channel number of the particular IOType Outputs e pValue A pointer to the result value 4 2 9 GetFirstResult and GetNextResult Calling either Go function creates a list of results that matches the list of requests Use GetFirstResult and GetNextResult to step through the list of results in order When either function returns LJE NO MORE DATA AVAILABLE there are no more items in the list of results Items can be read more than once by calling GetFirstResult to move back to the beginning of the list UserData is
143. r single ended channels only and thus the negative channel is internally set to 31 There is an additional called LJ ioGET AIN that allows the user to specify the positive and negative channel 16 Positive Channel 0 7 AINO AIN7 FIOO FIO7 8 15 AIN8 AIN15 EIOO EIO7 30 Temp Sensor 31 Vreg Table 2 4 Positive Channel Numbers Channel 31 puts the internal Vreg 3 3 volts on the positive input of the ADC See Section 2 6 4 for information about the internal temperature sensor Negative Channel 0 7 AINO AIN7 FIOO FIO7 8 15 AIN8 AIN15 EIOO EIO7 30 Vref 31 Single Ended 32 Special 0 3 6 or 10 20 UD Only Table 2 5 Negative Channel Numbers If the negative channel is set to anything besides 31 the U3 does a differential conversion and returns a pseudobipolar value If the negative channel is set to 31 the U3 does a single ended conversion and returns a unipolar value Channel 30 puts the internal voltage reference Vref 72 44 volts on the negative input of the ADC Channel 32 is a special negative channel supported by the LabJack UD driver When used the driver will actually pass 30 as the negative channel to the U3 and when the result is returned the driver adds Vref to the value This results in a full span on the positive channel of about to 4 88 volts versus ground but since the voltage on any analog input cannot exceed 3 6 volts only 75 of the converters range is used and the span is
144. reads Note that when streaming on the U3 the timing is known anyway elapsed time scan rate scan number and it does not make sense to stream the system timer modes 10 or 11 48 4 LabJackUD High Level Driver The low level U3 functions are described in Section 5 but most Windows applications will use the LabJackUD driver instead The driver requires a PC running Windows 98 ME 2000 or XP It is recommended to install the software before making a USB connection to a LabJack The download version of the installer consists of a single executable This installer places the driver LabJackUD dll in the Windows System directory along with a support DLL LabJackUSB dll Generally this is c Windows System on Windows 98 ME and c Windows System32 on Windows 2000 XP Other files including the header and Visual C library file are installed to the LabJack drivers directory which defaults to c Program Files LabJack drivers 4 1 Overview The general operation of the LabJackUD functions is as follows Open a LabJack Build a list of requests to perform Execute the list Go Read the result of each request Get At the core the UD driver only has 4 basic functions Open AddRequest Go and GetResult Then with these few functions there are many constants used to specify the desired actions When programming in any language it is recommended to have the header file handy so that constants can be copied and pasted
145. red by the same external 30 supply or otherwise referred to the same external ground should share a single ground connection to the U3 if possible 2 8 1 3 Input Mechanical Switch Closure To detect whether a mechanical switch is open or closed connect one side of the switch to U3 ground and the other side to a digital input The behavior is very similar to the open collector described above P Digital Input GND Figure 2 10 Basic Mechanical Switch Connection To Digital Input When the switch is open the internal 100 pull up resistor will pull the digital input to about 3 3 volts logic high When the switch is closed the ground connection will overpower the pull up resistor and pull the digital input to O volts logic low Since the mechanical switch does not have any electrical connections besides to the LabJack it can safely be connected directly to GND without using a series resistor or SGND When the mechanical switch is closed and even perhaps when opened it will bounce briefly and produce multiple electrical edges rather than a single high low transition For many basic digital input applications this is not a problem as the software can simply poll the input a few times in succession to make sure the measured state is the steady state and not a bounce For applications using timers or counters however this usually is a problem The hardware counters for instance are very fast and will increment on all the
146. reset IOType so that all pin assignments are in the factory default condition The ePut function is used which combines the add go get ePut lngHandle LJ ioPIN CONFIGURATION RESET 0 0 0 First an add go get block to configure the timers and counters Set the pin offset to 4 which causes the timers to start on FIO4 AddRequest l1ngHandle LJ ioPUT CONFIG LJ chTIMER COUNTER PIN OFFSET 4 0 0 Enable both timers They will use FIO4 FIO5 AddRequest l1ngHandle LJ ioPUT CONFIG LJ chNUMBER TIMERS ENABLED 2 0 0 Make sure Counter0 is disabled AddRequest lngHandle LJ ioPUT COUNTER ENABLE 0 0 0 0 Enable Counterl will use the next available line FIO6 AddRequest l1ngHandle LJ ioPUT COUNTER ENABLE 1 1 0 0 All output timers use the same timer clock configured here The base clock is set to 48MHZ DIV meaning that the clock divisor is supported and Counter0 is not available Note that this timer clock base is not valid with U3 hardware version 1 20 AddRequest lngHandle LJ ioPUT CONFIG LJ chTIMER CLOCK BASE LJ tc48MHZ DIV 0 0 Set the timer clock divisor to 48 creating a 1 MHz timer clock AddRequest lngHandle LJ ioPUT CONFIG LJ chTIMER CLOCK DIVISOR 48 0 0 Configure Timer0 as 8 bit It will have a frequency of 1M 256 3906 25 Hz AddRequest lngHandle LJ ioPUT TIMER MODE 0 LJ tmPWM8 0 0 Initialize the 8 bit PWM with a 50 duty cyc
147. rtain number of steps Once this timer reaches the specified stop count value and stops the adjacent timer the timers must be reconfigured to restart the output When Timer is stopped it is still enabled but just not outputting anything Thus rather than returning to whatever previous digital I O state it had it goes to input which has a 100 kQ pull up That means the best results are obtained if TimerO was initially configured as input factory default rather than output high or output low The MSW of the read from this timer mode returns the number of edges counted but does not increment past the stop count value The LSW of the read returns edges waiting for 2 9 1 10 System Timer Low High Read Modes 10 amp 11 The LabJack U3 has a free running internal 64 bit system timer with a frequency of 4 MHz Timer modes 10 amp 11 return the lower or upper 32 bits of this timer An FIO line is allocated for these modes like normal even though they are internal readings and do not require any external connections This system timer cannot be reset and is not affected by the timer clock If using both modes 10 amp 11 read both in the same low level command and read 10 before 11 Mode 11 the upper 32 bits of the system timer is not available for stream reads Note that when streaming on the U3 the timing is known anyway elapsed time scan rate scan number and it does not make sense to stream the system timer modes 10 or 11
148. rupt service routine on each edge 37 Writing a value of zero to the timer performs a reset After reset a read of the timer value will return zero until a new edge is detected If a timer is reset and read in the same function call the read returns the value just before the reset 2 9 1 6 Firmware Counter Input With Debounce Mode 6 Intended for frequencies less than 10 Hz this mode adds a debounce feature to the firmware counter which is particularly useful for signals from mechanical switches On every applicable edge seen by the external pin this mode increments a 32 bit register Unlike the pure hardware counters these timer counters require that the firmware jump to an interrupt service routine on each edge The debounce period is set by writing the timer value The low byte of the timer value is a number from 0 255 that specifies a debounce period in 16 ms increments plus an extra 0 16 ms of variability Debounce Period 0 16 ms TimerValue 16 ms In the high byte bits 8 16 of the timer value bit O determines whether negative edges bit 0 clear or positive edges bit O set are counted Assume this mode is enabled with a value of 1 meaning that the debounce period is 16 32 ms and negative edges will be counted When the input detects a negative edge it increments the count by 1 and then waits 16 32 ms before re arming the edge detector Any negative edges within the debounce period are ignored This is good beh
149. s so all 8 bit PWM channels will have the same frequency and will have their falling edges at the same time PWM output starts by setting the digital line to output low for the specified amount of time The output does not necessarily start instantly but rather waits for the internal clock to roll For example if the PWM frequency is 100 Hz that means the period is 10 milliseconds and thus after the command is received by the device it could be anywhere from 0 to 10 milliseconds before the start of the PWM output 2 9 1 3 Period Measurement 32 Bit Modes 2 amp 3 Mode 2 On every rising edge seen by the external pin this mode records the number of clock cycles clock frequency determined by TimerClockBase TimerClockDivisor between this rising edge and the previous rising edge The value is updated on every rising edge so a read returns the time between the most recent pair of rising edges In this 32 bit mode the processor must jump to an interrupt service routine to record the time so small errors can occur if another interrupt is already in progress The possible error sources are e Other edge interrupt timer modes 2 3 4 5 8 9 12 13 If an interrupt is already being handled due to an edge on the other timer delays of a few microseconds are possible e Ifa stream is in progress every sample is acquired in a high priority interrupt These interrupts could cause delays on the order of 10 microseconds 36 e The always active U3 s
150. s case the signal voltage is the difference between the positive and negative signal and the negative signal cannot be shorted to ground Such a signal could be measured using a differential input on the U3 2 6 3 4 Signal powered externally An example is a box with a wire coming out that is defined as a 0 2 volt analog signal and a second wire labeled as ground The signal is known to have 0 2 volts compared to the ground wire but the complication is what is the voltage of the box ground compared to the LabJack ground If the box is known to be electrically isolated from the LabJack the box ground can simply be connected to LabJack GND An example would be if the box was plastic powered by an internal battery and does not have any wires besides the signal and ground which are connected to AINx and GND on the LabJack If the box ground is known to be the same as the LabJack GND then perhaps only the one signal wire needs to be connected to the LabJack but it generally does not hurt to go ahead 21 and connect the ground wire to LabJack GND with 100 resistor You definitely do not want to connect the grounds without a resistor If little is Known about the box ground a DMM can be used to measure the voltage of box ground compared to LabJack GND As long as an extreme voltage is not measured it is generally OK to connect the box ground to LabJack GND but it is a good idea to put in a 100 O series resistor to prevent large currents
151. s designed to accept series digital modules from Opto22 and compatible modules from other manufacturers such as the G5 series from Grayhill Output modules are available with voltage ratings up to 200 VDC or 280 VAC and current ratings up to 3 5 amps 41 2 12 U3 OEM There is an OEM version of the U3 available LV and HV It is a board only no enclosure no screwdriver no cable no DAQFactory Express and does not have most of the through hole components installed The picture below shows how the U3 OEN through hole parts off makes the OE ships by default Leaving the M board very flexible Many applications do not need the through hole parts but if needed they are much easier to install than uninstall In the picture note the holes available for 0 1 pin header connectors Connectors J3 amp J4 provide pin header access to the connections that would normally appear on the left and right screw terminals Connector J2 provides a pin header alternative to the DB15 connector The OEM can connect ribbon cables to the pin headers or even plug the U3 directly to the customers main board designed with mating pin header receptacles See Appendix B for connector coordinates on the PCB J2 1 GND 3 5 CIO2 7 GND 9 EIO1 11 EIO3 13 EIO5 15 EIO7 J3 1 FlO4 3 FIO6 5 VS 7 GND SDA on 1 30 9 VS J4 1 FIOO 3 FIO2 5 VS 7 DACO 9 VS 12 14 16
152. sed value for direction and state are updated if a bit 1 If a bit of the mask is 0 only a read is performed on that bit of I O 90 Binary Encoded Parameters Many parameters in the following functions use specific bits within a single integer parameter to write read specific information In particular most digital parameters contain the information for each bit of I O in one integer where each bit of I O corresponds to the same bit in the parameter e g the direction of FIOO is set in bit O of parameter FlODir For instance in the function ControlConfig the parameter FlODir is a single byte 8 bits that writes reads the direction of each of the 8 FIO lines if FlODir is 0 all FIO lines are input if FlODir is 1 29 FIOO is output FIO1 FIO7 are input if FlODir is 5 2 22 FIOO and FIO2 are output all other FIO lines are input if FIODir is 255 2 2 FIOO FIO7 are output 91 5 2 Low Level Functions 5 2 1 BadChecksum If the processor detects a bad checksum in any command the following 2 byte normal response will be sent and nothing further will be done Response Byte 0 OxB8 1 OxB8 92 5 2 2 ConfigU3 Writes and reads various configuration settings Although this function has many of the same parameters as other functions most parameters in this case are affecting the power up values not the current values There is a hardware method to restore bytes 9 20 to the factory default value of 0x0
153. sion 1 21 Sends and receives serial data using SPI synchronous communication Command Byte 0 Checksum8 1 OxF8 2 4 NumSPIWords 3 Ox3A 4 Checksum16 LSB 5 Checksum16 MSB 6 SPlOptions Bit 7 AutoCS Bit 6 DisableDirConfig Bits 1 0 SPIMode 0 1 B 2 C 3 D 7 SPIClockFactor 8 Reserved 9 CSPinNum 10 CLKPinNum 11 MISOPinNum 12 MOSIPinNum 13 NumSPIBytesToTransfer 14 SPIByteO Response Byte 0 Checksum8 1 OxF8 2 1 NumSPIWords 3 Ox3A 4 Checksum16 LSB 5 Checksum16 MSB 6 Errorcode 7 NumSPIBytes Transferred 8 SPIByteO NumSPlWords This is the number of SPI bytes divided by 2 If the number of SPI bytes is odd round up and add an extra zero to the packet SPlOptions If AutoCS is true the CS line is automatically driven low during the SPI communication and brought back high when done If DisableDirConfig is true this function does not set the direction of the lines whereas if it is false the lines are configured as CS output CLK output MISO input and MOSI output SPIMode specifies the standard SPI mode as discussed below SPIClockFactor Sets the frequency of the SPI clock according the following approximate formula Frequency 1000000 10 10 256 SPIClockFactor where 118 passing a value of 0 corresponds to a factor of 256 and thus a maximum frequency of about 100 kHz e CS CLK MISO MOSI PinNum Assigns which digital I O line is used for each SPI line Value passed is 0 19 corresponding to the nor
154. sions of these functions where IOType and Channel are strings rather than longs This is useful for passing string constants in languages that cannot include the header file and is generally only used with the put get config The strings should contain the constant name as indicated in the header file such as LJ ioPUT CONFIG and LJ chLOCALID The declaration for the SS versions are the same as the normal versions except for const char plOType const char pChannel The declaration for ePut is the same as eGet except that Value is not a pointer double Value and thus is an input only Declaration LJ ERROR _stdcall eGet LJ HANDLE Handle long IOType long Channel double pValue long x1 Parameter Description Returns LabJack errorcodes or 0 for no error Inputs e Handle Handle returned by OpenLabJack e lOType The type of request See Section 4 3 e Channel The channel number of the particular IOType e pValue Pointer to Value sends and receives data e X1 Optional parameter used by some lOTypes Outputs e pValue Pointer to Value sends and receives data 56 4 2 4 eAddGoGet This function passes multiple requests via arrays then executes a GoOne and returns all the results via the same arrays The parameters that start with are arrays and all must be initialized with at least a number of elements equal to NumRequests Declaration LJ ERROR _stdca
155. sistance of the EIO CIO line With 32 an FIO line the voltage across the inputs of the relay will be about 5 1500 1500 550 3 7 volts the other 1 3 volts are dropped across the internal resistance of the FIO line Both of these are well above the 3 0 volt threshold for the relay so it will turn on e When the digital line is set to input it is the equivalent of a 3 3 volt connection with 100 kQ in series The resulting voltage across the control inputs of the relay will be close to zero as virtually all of the 1 7 volt difference between VS and 3 3 is dropped across the internal 100 kQ resistance This is well below the 1 0 volt threshold for the relay so it will turn off e When the digital line is set to output high it is the equivalent of a 3 3 volt connection with 180 EIO CIO or 550 FIO in series When using an EIO CIO line the resulting voltage across the control inputs of the relay will be about 1 7 1500 1500 180 1 5 volts With an FIO line the voltage across the inputs of the relay will be about 1 7 1500 1500 550 1 2 volts Both of these in the 1 0 3 0 volt region that is not defined for these example relays so the resulting state is unknown Note that sinking excessive current into digital outputs can cause noticeable shifts in analog input readings For example the FIO sinking configuration above sinks about 2 4 mA into the digital output to turn the SSR on which could cause a shift of roughly 1 mV to ana
156. sponding to FIOO FIO7 State and direction are controlled automatically for the specified lines StatusReg Returns a read of the SHT1X status register Temperature Returns the raw binary temperature reading Humidity Returns the raw binary humidity reading CRC Returns the CRC values from the sensor Checksum8 OxF8 0x02 0x39 Checksum16 LSB Checksum16 MSB DataPinNum 0 19 ClockPinNum 0 19 Reserved Reserved Checksum8 OxF8 0x05 0x39 Checksum16 LSB Checksum16 MSB Errorcode 0x00 StatusReg StatusRegCRC Temperature TemperatureCRC Humidity HumidityCRC 125 5 3 Errorcodes Following is a list of the low level function errorcodes Code SCRATCH_WRT_FAIL SCRATCH ERASE FAIL DATA OVERFLOW ADCO BUFFER OVERFLOW FUNCTION INVALID SWDT TIME INVALID CONFIG ERROR FLASH WRITE FAIL FLASH ERASE FAIL FLASH JMP FAIL FLASH PSP TIMEOUT FLASH ABORT RECEIVED FLASH PAGE MISMATCH FLASH BLOCK MISMATCH FLASH PAGE NOT IN CODE AREA MEM ILLEGAL ADDRESS FLASH LOCKED INVALID BLOCK FLASH ILLEGAL PAGE FLASH TOO MANY BYTES FLASH INVALID STRING NUM SHT1x COMM TIME OUT SHT1x NO ACK SHT1x CRC FAILED SHT1X TOO MANY W BYTES SHT1X TOO MANY R BYTES SHT1X INVALID MODE SHT1X INVALID LINE STREAM IS ACTIVE STREAM TABLE INVALID STREAM CONFIG INVALID STREAM BAD TRIGGER SOURCE STREAM NOT RUNNING STREAM INVALID TRIGGER STREAM ADCO BUFFER OVERFLOW STREAM SCAN OVERLAP STREAM SAMPLE NU
157. t 7 determines whether the new TimerClockBase and TimerClockDivisor are written or if just a read is performed Bits 0 2 specify the TimerClockBase If TimerClockBase is 3 6 then Counter is not available e TimerClockDivisor The base timer clock is divided by this value or divided by 256 if this value is 0 Only applies if TimerClockBase is 3 6 98 5 2 5 Feedback A flexible function that handles all command response functionality One or more IOTypes used to perform a single write read or multiple writes reads Note that the general protocol described in Section 4 1 defines byte 2 of an extended command as the number of data words which is the number of words in a packet beyond the first 3 a word is 2 bytes Also note that the overall size of a packet must be an even number of bytes so in this case an extra 0x00 is added to the end of the command and or response if needed to accomplish this Since this command has a flexible size byte 2 will vary For instance if a single IOType of PortStateRead d26 is passed byte 2 would be equal to 1 for the command and 3 for the response If a single IOType of LED 99 is passed an extra 0 must be added to the command to make the packet have an even number of bytes and byte 2 would be equal to 2 The response would also need an extra to be even and byte 2 would be equal to 2 Command Byte 0 Checksum8 1 OxF8 2 0 5 Number of Data Words IOTypes and Data 3 0x00 4 Checksum16
158. t revision covering hardware revision 1 30 LV amp HV V1 06 released April 9 2008 Updated all references to power up jumpers to now use FIO4 FIO6 Section 2 8 Updated to reflect unavailability of FIOO FIO3 on U3 HV Section 5 2 2 Updated with new parameters added for hardware rev 1 30 V1 07 released September 18 2008 Section 2 7 2 13 5 2 2 Discussed increased DAC noise with decreased timer clock Section 2 8 1 4 Noted that excessive current sinking can cause AIN shift Section 3 1 Updated Tables for current firmware Section 4 3 7 More detail about stream buffers Section 4 3 11 More information about pin numbers and pull up resistors Section 4 3 12 5 3 16 New baud rate formula for hardware 1 30 V1 08 released March 9 2009 Section 2 1 Corrected endpoint description in last paragraph Sections 2 6 2 amp 5 2 5 1 Clarified that binary AIN values are always unsigned Section 2 9 1 9 Corrected description of stop timer value read Section 2 12 Updated J3 table for hardware version 1 30 Section 4 3 14 Added wait IOType Section 5 2 2 Added bits 4 amp 5 to WriteMask0 in command listing Appendix A Added last missing HV specs Table Of Contents 1 Installation on Windows ccccccccccceccceec cece cece cee eceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeneeseeeniess 7 1 1 Control Panel Application
159. t the input timer and the counter Reset the duty cycle measurement Timerl to zero by writing a value of zero The duty cycle measurement is continuously updated so a reset is normally not needed but one reason to reset to zero is to detect whether there has been a new measurement or not ePut lngHandle LJ ioPUT TIMER VALUE 1 0 0 Reset Counterl to zero ePut lngHandle LJ ioPUT COUNTER RESET 1 1 0 Note that if a timer counter is read and reset at the same time in the same Add Go Get block the read will return the value just before reset 4 3 7 Stream Mode The highest input data rates are obtained in stream mode which is supported with U3 hardware version 1 21 or higher See Section 3 2 for more information about stream mode There are five IOTypes used to control streaming LJ ioCLEAR STREAM CHANNELS LJ ioADD STREAM CHANNEL LJ ioADD STREAM CHANNEL DIFF Put n gative channel in xl LJ ioSTART STREAM Value returns actual scan rate LJ ioSTOP STREAM LJ ioGET STREAM DATA 74 The following constant is passed in the Channel parameter with the get stream data IOType to specify a read returning all scanned channels rather than retrieving each scanned channel separately LJ chALL CHANNELS The following are special channels used with the get put config IOTypes to write or read various stream values LJ chSTREAM SCAN FREQUENCY LJ chSTREAM BUFFER SIZE UD driver s
160. tes around the address 1 is because the address parameter is a string in the OpenLabJack function The ampersand amp in front of IngHandle is a C notation that means we are passing the address of that variable rather than the value of that variable In the definition of the OpenLabJack function the handle parameter is defined with an asterisk in front meaning that the function expects a pointer i e an address In general a function parameter is passed as a pointer address rather than a value when the parameter might need to output something The parameter value passed to a function in C cannot be modified in the function but the parameter can be an address that points to a value that can be changed Pointers are also used when passing arrays as rather than actually passing the array an address to the first element in the array is passed 4 3 2 Configuration One of the most important operations on the is configuring the flexible I O as digital or analog The following 4 IOTypes are used for that LJ ioPUT ANALOG ENABLE BIT LJ ioGET ANALOG ENABLE BIT LJ ioPUT ANALOG ENABLE PORT Xl is number of bits LJ ioGET ANALOG ENABLE PORT xl is number of bits When a request is done with one of the port IOTypes the Channel parameter is used to specify the starting bit number and the x1 parameter is used to specify the number of applicable bits Following are some pseudocode examples Configure FIO3 as
161. tion 2 x are derived from PWM signals that are affected by the timer clock frequency The default timer clock frequency of the U3 is set to 48 MHz as this results in the minimum DAC output noise If the frequency is lowered the DACs will have more noise where the frequency of the noise is the timer clock frequency divided by 2 6 2 9 1 Timer Mode Descriptions 2 9 1 1 PWM Output 16 Bit Mode 0 Outputs a pulse width modulated rectangular wave output Value passed should be 0 65535 and determines what portion of the total time is spent low out of 65536 total increments That means the duty cycle can be varied from 100 0 out of 65536 are low to 0 001596 65535 out of 65536 are low The overall frequency of the PWM output is the clock frequency specified by TimerClockBase TimerClockDivisor divided by 2 6 The following table shows the range of available PWM frequencies based on timer clock settings PWM16 Frequency Ranges TimerBaseClock Divisor 1 Divisor 256 0 4 MHz 61 04 N A 1 12 MHz 183 11 N A 2 48 MHz Default 732 42 N A 3 1 MHz Divisor 15 26 0 060 4 4 MHz Divisor 61 04 0 238 5 12 MHz Divisor 183 11 0 715 6 48 MHz Divisor 732 42 2 861 Note that the clocks above apply to the U3 hardware revision 1 21 With hardware revision 1 20 all clocks are half of those values The same clock applies to all timers so all 16 bit PWM channels will have the same frequency and will have their falling edges at the same time 35 PW
162. tream buffer size in samples LJ chSTREAM WAIT MODE LJ chSTREAM DISABLE AUTORECOVERY LJ chSTREAM BACKLOG COMM Read only 0 0 and 256 100 LJ chSTREAM BACKLOG UD Read only Number of samples LJ chSTREAM SAMPLES PER PACKET Default 25 Range 1 25 LJ chSTREAM READS PER SECOND Default 25 With the wait mode special channel above the following constants are passed in the value parameter to select the behavior when reading data LJ SwNONE No wait Immediately return available data LJ SWALL OR NONE No wait Immediately return requested amount or none LJ swPUMP Advanced message pump wait mode LJ SwSLEEP Wait until requested amount available The backlog special channels return information about how much data is left in the stream buffer on the U3 or in the UD driver These parameters are updated whenever a stream packet is read by the driver and thus might not exactly reflect the current state of the buffers but can be useful to detect problems When streaming the processor acquires data at precise intervals and transfers it to a buffer on the U3 itself The U3 has a small buffer 512 984 samples for data waiting to be transferred to the host The cnsrREAM BAcKLOG COMM Special channel specifies how much data is left in the buffer comm or conrroz are the same thing on the where 0 means 0 full and 256 would mean 100 full The UD driver retrieves stream data from the U3 in the background
163. tting of outputs Declaration LJ ERROR stdcall GoOne LJ HANDLE Handle Parameter Description Returns LabJack errorcodes or for no error Inputs e Handle Handle returned by OpenLabJack Outputs e None 4 2 8 GetResult Calling either Go function creates a list of results that matches the list of requests Use GetResult to read the result and errorcode for a particular IOType and Channel Normally this function is called for each associated AddRequest item Even if the request was an output the errorcode should be evaluated 59 None of the Get functions will clear results from the list The first AddRequest call subsequent to a Go call will clear the internal lists of requests and results for a particular device When processing raw in out or stream data requests the call to a Get function does not actually cause the data arrays to be filled The arrays are filled during the Go call if data is available and the Get call is used to find out many elements were placed in the array GetResultS is a special version of the Get function where is a string rather than a long This is useful for passing string constants in languages that cannot include the header file and is generally used with all IOTypes except put get config The string should contain the constant name as indicated the header file such as LJ ioANALOG INPUT The declaration for the S version of Get is the same as below except fo
164. uired to provide the offset In the following circuit DAC1 is used to provide a reference voltage The actual value of DAC1 can be adjusted such that the circuit output is 0 volts at the DACO mid scale voltage and the value of R1 can be adjusted to get the desired gain A fixed reference such as 2 5 volts could also be used instead of DAC1 V gt 10V DACO H og Amp 10 Volt Output e V lt 10V R2 100k R1 30k DAC1 3 1V Figure 2 7 10 Volt DAC Output Circuit A two point calibration should be done to determine the exact input output relationship of this circuit Refer to application note SLOAO097 from ti com for further information about gain and offset design with op amps 2 8 Digital O The LabJack U3 has up to 20 digital I O channels 16 are available from the flexible I O lines and 4 dedicated digital I O are available on the DB15 connector The first 4 lines FIOO FIO3 are unavailable on the U3 HV Each digital line can be individually configured as input output high or output low The digital I O use 3 3 volt logic and are 5 volt tolerant The LabJackUD driver uses the following bit numbers to specify all the digital lines 0 7 FIOO FIO7 0 3 unavailable on U3 HV 8 15 EIOO EIO7 16 19 The 8 FIO lines appear on the built in screw terminals while the 8 EIO and 4 CIO lines appear only on the DB15 connector See the DB15 Section of this User s Guide for more
165. ults are received 4 2 10 DoubleToStringAddress Some special channels of the config OType pass IP address and others in a double This function is used to convert the double into a string in normal decimal dot or hex dot notation Declaration LJ ERROR stdcall DoubleToStringAddress double Number char pString long HexDot Parameter Description Returns LabJack errorcodes or for no error Inputs e Number Double precision number to be converted e pString Must pass a buffer for the string of at least 24 bytes e HexDot If not equal to zero the string will be in hex dot notation rather than decimal dot Outputs e pString A pointer to the string representation 4 2 11 StringToDoubleAddress Some special channels of the config pass IP address and others in a double This function is used to convert a string in normal decimal dot or hex dot notation into a double 61 Declaration LJ ERROR stdcall StringToDoubleAddress const char pString double pNumber long HexDot Parameter Description Returns LabJack errorcodes or for no error Inputs e pString A pointer to the string representation e HexDot If not equal to zero the passed string should be in hex dot notation rather than decimal dot Outputs e pNumber pointer to the double precision representation 4 2 12 StringToConstant Converts the given string to the appropriate constant number Used inter
166. up behavior 4 These specifications provide the answer to the question How much current can the digital I O sink or source For instance if EIOO is configured as output high and shorted to ground the current sourced by EIOO into ground will be about 18 mA 3 3 180 If connected to a load that draws 5 mA EIOO can provide that current but the voltage will droop to about 2 4 volts instead of the nominal 3 3 volts If connected to a 180 ohm load to ground the resulting voltage and current will be about 1 65 volts 9 mA 5 Hardware counters 0 to 3 3 volt square wave Limit about 2 MHz with older hardware versions 6 To avoid missing edges keep the total number of applicable edges on all applicable timers below this limit See Section 2 9 for more information Limit about 10000 with older hardware versions 130 Enclosure amp PCB Drawings The square holes shown below are for a DIN rail mounting adapter Tyco part TKAD Units are inches e TEN o OSDA 2 9 O SCL Soo OI OIS REF DAQH O 8107 171109 F106 QUIVS FIO3 Ol Fios Q 16104 1 QUIVs FION IO USB T 3 29 SCREW MOUNT 8 SCREWS 1 83 DIN RAIL MOUNT TYCO P N TKAD p
167. ved 1 amp 2 Pass 0 4 2 19 eDI An easy function that reads the state of one digital input This is a simple alternative to the very flexible IOType based method normally used by this driver When needed this function automatically configures the specified channel as a digital input Declaration LJ ERROR _stdcalleDI LJ HANDLE Handle long Channel long State Parameter Description Returns LabJack errorcodes or 0 for no error Inputs e Handle Handle returned by OpenLabJack e Channel The channel to read 0 19 corresponds to FIOO CIO3 Outputs e State Returns the state of the digital input O False Low and 1 True High 4 2 20 eDO An easy function that writes the state of one digital output This is a simple alternative to the very flexible IOType based method normally used by this driver When needed this function automatically configures the specified channel as a digital output Declaration LJ ERROR stdcall eDO LJ HANDLE Handle long Channel long State 65 Parameter Description Returns Inputs LabJack errorcodes or for no error Handle Handle returned by OpenLabJack Channel The channel to write to 0 19 corresponds to FIOO CIO3 State The state to write to the digital output O False Low and 1 True High 4 2 21 eTCConfig An easy function that configures and initializes all the timers and counters This is a simple alternative to the very fle
168. vel Feedback function is the primary function used as it writes and reads virtually all I O on the U3 The Windows UD driver uses the Feedback function under the hood to handle most requests besides configuration and streaming The following tables show typical measured execution times for command response mode The time varies primarily with the number of analog inputs requested and is not noticeably affected by the number of digital I O DAC timer and counter operations These times were measured using the example program allio c VC6_LJUD The program executes a loop 1000 times and divides the total time by 1000 and thus include everything Windows latency UD driver overhead communication time U3 processing time etc USB high high USB other milliseconds milliseconds 0 0 6 4 0 lt Write Read all DIO DACs Timers amp Counters 1 1 0 4 0 4 2 4 4 0 8 4 7 9 2 16 8 3 12 2 Table 3 1 Typical Feedback Function Execution Times QuickSample 0 LongSeitling 0 USB high high USB other milliseconds milliseconds 0 0 6 4 0 lt Write Read all DIO DACs Timers amp Counters 1 0 7 4 0 4 1 0 4 0 8 2 1 8 0 16 3 0 8 0 Table 3 2 Typical Feedback Function Execution Times QuickSamplez1 LongSeitling 0 USB high high USB other milliseconds milliseconds 0 0 6 4 0 lt Write Read all DIO DACs Timers amp Counters 1 4 2 5 2 4 16 17 8 31 36 16 60 62 Table 3 3 Typical Feedback Functi
169. x00 0x00 0x00 0x00 0x00 0x00 numBytesToWrite 10 numBytesToRead 10 Raw Out This command writes the bytes to the device eGet lngHandle LJ ioRAW OUT 0 amp numBytesToWrite pwriteArray Raw In This command reads the bytes from the device eGet lngHandle LJ ioRAW IN 0 amp numBytesToRead preadArray 4 3 9 Easy Functions The easy functions are simple alternatives to the very flexible IOType based method normally used by this driver There are 6 functions available eAIN Read 1 analog input eDAC Write to 1 analog output eDI Read 1 digital input Write to 1 digital output eTCConfig Configure all timers and counters eTCValues Update reset and read all timers and counters 78 In addition to the basic operations these functions also automatically handle configuration as needed For example eDO sets the specified line to digital output if previously configured as analog and or input and eAIN sets the line to analog if previously configured as digital The first 4 functions should not be used when speed is critical with multi channel reads These functions use one low level function per operation whereas using the normal Add Go Get method with IOTypes many operations can be combined into a single low level call With single channel operations however there will be little difference between using an easy function or Add Go Get The last two functions handle almost
170. xed interval controlled by the hardware clock on the device itself and stores the data in a buffer The LabJackUD driver automatically reads data from the hardware buffer and stores it in a PC RAM buffer until requested The general procedure for streaming is Update configuration parameters Build the scan list Start the stream Periodically retrieve stream data in a loop Stop the stream Following is example pseudocode to configure a 2 channel stream Set the scan rate AddRequest lngHandle LJ ioPUT CONFIG LJ chSTREAM SCAN FREQUENCY scanRate 0 0 Give the UD driver a 5 second buffer scanRate 2 channels 5 seconds AddRequest lngHandle LJ ioPUT CONFIG LJ chSTREAM BUFFER SIZE scanRate 2 5 0 0 Configure reads to wait and retrieve the desired amount of data AddRequest lngHandle LJ ioPUT CONFIG LJ chSTREAM WAIT MODE LJ SWwSLEEP 0 0 Define the scan list as singled ended AIN2 then differential AIN3 AIN9 AddRequest lngHandle LJ ioCLEAR STREAM CHANNELS 0 0 0 0 AddRequest l1ngHandle LJ ioADD STREAM CHANNEL 2 0 0 0 AddRequest lngHandle LJ ioADD STREAM CHANNEL DIFF 3 0 9 0 Execute the requests GoOne l1ngHandle Next start the stream Start the stream eGet lngHandle LJ ioSTART STREAM 0 amp dblValue 0 The actual scan rate is dependent on how the desired scan rate divides into the LabJack clock The actual scan rate is returned in the va
171. xible IOType based method normally used by this driver When needed this function automatically configures the needed lines as digital Declaration LJ ERROR stdcall eTCConfig LJ HANDLE Handle long aEnableTimers long aEnableCounters long TCPinOffset long TimerClockBaselndex long TimerClockDivisor long aTimerModes double aTimerValues long Reserved1 long Reserved2 Parameter Description Returns Inputs LabJack errorcodes or for no error Handle Handle returned by OpenLabJack aEnableTimers An array where each element specifies whether that timer is enabled Timers must be enabled in order starting from 0 so for instance Timer1 cannot be enabled without enabling TimerO also A nonzero value for an array element specifies to enable that timer For the U3 this array must always have at least 2 elements aEnableCounters An array where each element specifies whether that counter is enabled Counters do not have to be enabled in order starting from 0 so Counter1 be enabled when Counter is disabled A nonzero value for array element specifies to enable that counter For the U3 this array must always have at least 2 elements TCPinOffset Value from 4 8 specifies where to start assigning timers and counters TimerClockBaselndex Pass a constant to set the timer base clock The default is LJ tc48MHZ TimerClockDivisor Pass a divisor from 0 255 where 0 is a divisor
172. y the LabJack and thus bit 0 is ignored Numl2CBytesToSend Specifies how many I2C bytes will be sent 0 50 Numl2CBytesToReceive Specifies how many I2C bytes will be read 0 52 I2Cbyte In the command these are the bytes to send In the response these are the bytes read Numl2CWordsReceive This is the number of I2C bytes to receive divided by 2 If the number of bytes is odd the value is rounded up and an extra zero is added to the packet This parameter is actually just to specify the size of this packet as the Numl2CbytesToReceive parameter above actually specifies how many bytes to read AckArray Represents a 32 bit value where bits are set if the corresponding I2C write byte was ack ed Useful for debugging up to the first 32 write bytes of communication Bit O corresponds to the last data byte bit 1 corresponds to the second to last data byte and so on up to the address byte So if n is the number of data bytes the ACKs value should be 2 1 1 124 5 3 20 5 1 Requires U3 hardware version 1 21 Reads temperature and humidity from a Sensirion SHT1X sensor which is used by the El 1050 For more information see the El 1050 datasheet from labjack com and the SHT1X datasheet from sensirion com Command Byte Response UJ 10 11 13 14 15 Data Clock PinNum Assigns which digital I O line is used for each SPI line Value passed is 0 7 corre
173. ystem timer causes an interrupt 61 times per second If this interrupt happens to be in progress when the edge occurs a delay of about 1 microsecond is possible If the software watchdog is enabled the system timer interrupt takes longer to execute and a delay of a few microseconds is possible Note that the minimum measurable period is limited by the edge rate limit discussed in Section 2 9 2 See Section 3 2 1 for a special condition if stream mode is used to acquire timer data in this mode Writing a value of zero to the timer performs a reset After reset a read of the timer value will return zero until new edge is detected If a timer is reset and read in the same function call the read returns the value just before the reset Mode 3 is the same except that falling edges are used instead of rising edges 2 9 1 4 Duty Cycle Measurement Mode 4 Records the high and low time of a signal on the external pin which provides the duty cycle pulse width and period of the signal Returns 4 bytes where the first two bytes least significant word or LSW are a 16 bit value representing the number of clock ticks during the high signal and the second two bytes most significant word or MSW are a 16 bit value representing the number of clock ticks during the low signal The clock frequency is determined by TimerClockBase TimerClockDivisor The appropriate value is updated on every edge so a read returns the most recent high low times Not

Download Pdf Manuals

image

Related Search

Related Contents

Digitus DA-90315 flat panel desk mount    Gebrauchsanweisung KSN 5071/A  GeoRef User's Guide  確定申告書・贈与税申告書・電子申告 ネット更新  Roland Super CUBE-60 User's Manual  

Copyright © All rights reserved.
Failed to retrieve file