- Datasheets
- Accessories
- CB15
- CB25
- CB37 V1.2
- CB37 V2.1
- EB37
- EI-1022
- EI-1034
- EI-1040
- EI-1050
- IDCA-10
- LJTick-CurrentShunt
- LJTick-DAC
- LJTick-DAC Testing Utility
- LJTick-DigitalOut5V
- LJTick-Divider
- LJTick-InAmp
- LJTick-InBuff
- LJTick-LVDigitalIO
- LJTick-OutBuff
- LJTick-Proto
- LJTick-RelayDriver
- LJTick-Resistance
- LJTick-VRef
- Mux80 AIN Expansion Board
- PS12DC
- RB12
- RB16
- T-Series Datasheet
- Preface: Warranty, Liability, Compliance
- 1.0 Device Overview
- 2.0 Installation
- 3.0 Communication
- 4.0 Hardware Overview
- 5.0 USB
- 6.0 Ethernet
- 7.0 WiFi (T7-Pro only)
- 8.0 LEDs
- 9.0 VS, Power Supply
- 10.0 SGND and GND
- 11.0 SPC
- 12.0 200uA and 10uA (T7 Only)
- 13.0 Digital I/O
- 13.1 Flexible I/O (T4 Only)
- 13.2 DIO Extended Features
- 13.2.1 EF Clock Source
- 13.2.2 PWM Out
- 13.2.3 PWM Out with Phase
- 13.2.4 Pulse Out
- 13.2.5 Frequency In
- 13.2.6 Pulse Width In
- 13.2.7 Line-to-Line In
- 13.2.8 High-Speed Counter
- 13.2.9 Interrupt Counter
- 13.2.10 Interrupt Counter with Debounce
- 13.2.11 Quadrature In
- 13.2.12 Interrupt Frequency In
- 13.2.13 Conditional Reset
- 13.3 I2C
- 13.4 SPI
- 13.5 SBUS
- 13.6 1-Wire
- 13.7 Asynchronous Serial
- 14.0 Analog Inputs
- 15.0 DAC
- 16.0 DB37 (T7 Only)
- 17.0 DB15
- 18.0 Internal Temp Sensor
- 19.0 RTC (T7 Only)
- 20.0 Internal Flash
- 21.0 SD Card (T7 Only)
- 22.0 OEM Versions
- 23.0 Watchdog
- 24.0 IO Config, _DEFAULT
- 25.0 Lua Scripting
- Appendix A - Specifications
- Appendix B - Drawings and CAD Models
- Appendix C - Firmware Revision History
- Appendix D - Packaging Information
- Appendix E - Software Options
- U3 Datasheet
- Preface
- 1 - Installation
- 2 - Hardware Description
- 2.1 - USB
- 2.2 - Status LED
- 2.3 - GND and SGND
- 2.4 - VS
- 2.5 - Flexible I/O (FIO/EIO)
- 2.6 - AIN
- 2.6.1 - Channel Numbers
- 2.6.2 - Converting Binary Readings to Voltages
- 2.6.3 - Typical Analog Input Connections
- 2.6.3.1 - Signal from the LabJack
- 2.6.3.2 - Unpowered Isolated Signal
- 2.6.3.3 - Signal Powered By the LabJack
- 2.6.3.4 - Signal Powered Externally
- 2.6.3.5 - Amplifying Small Signal Voltages
- 2.6.3.6 - Signal Voltages Beyond 0-2.44 Volts (and Resistance Measurement)
- 2.6.3.7 - Measuring Current (Including 4-20 mA) with a Resistive Shunt
- 2.6.3.8 - Floating/Unconnected Inputs
- 2.6.3.9 - Signal Voltages Near Ground
- 2.6.4 - Internal Temperature Sensor
- 2.7 - DAC
- 2.8 - Digital I/O
- 2.9 - Timers/Counters
- 2.9.1 - Timer Mode Descriptions
- 2.9.1.1 - PWM Output (16-Bit, Mode 0)
- 2.9.1.2 - PWM Output (8-Bit, Mode 1)
- 2.9.1.3 - Period Measurement (32-Bit, Modes 2 & 3)
- 2.9.1.4 - Duty Cycle Measurement (Mode 4)
- 2.9.1.5 - Firmware Counter Input (Mode 5)
- 2.9.1.6 - Firmware Counter Input With Debounce (Mode 6)
- 2.9.1.7 - Frequency Output (Mode 7)
- 2.9.1.8 - Quadrature Input (Mode 8)
- 2.9.1.9 - Timer Stop Input (Mode 9)
- 2.9.1.10 - System Timer Low/High Read (Modes 10 & 11)
- 2.9.1.11 - Period Measurement (16-Bit, Modes 12 & 13)
- 2.9.1.12 - Line-to-Line Measurement (Mode 14)
- 2.9.2 - Timer Operation/Performance Notes
- 2.9.1 - Timer Mode Descriptions
- 2.10 - SPC (… and SCL/SDA/SCA)
- 2.11 - DB15
- 2.12 - U3-OEM
- 2.13 - Hardware Revision Notes
- 3 - Operation
- 4 - LabJackUD High-Level Driver
- 4.1 - Overview
- 4.2 - Function Reference
- 4.2.1 - ListAll()
- 4.2.2 - OpenLabJack()
- 4.2.3 - eGet() and ePut()
- 4.2.4 - eAddGoGet()
- 4.2.5 - AddRequest()
- 4.2.6 - Go()
- 4.2.7 - GoOne()
- 4.2.8 - GetResult()
- 4.2.9 - GetFirstResult() and GetNextResult()
- 4.2.10 - DoubleToStringAddress()
- 4.2.11 - StringToDoubleAddress()
- 4.2.12 - StringToConstant()
- 4.2.13 - ErrorToString()
- 4.2.14 - GetDriverVersion()
- 4.2.15 - TCVoltsToTemp()
- 4.2.16 - ResetLabJack()
- 4.2.17 - eAIN()
- 4.2.18 - eDAC()
- 4.2.19 - eDI()
- 4.2.20 - eDO()
- 4.2.21 - eTCConfig()
- 4.2.22 - eTCValues()
- 4.3 - Example Pseudocode
- 4.3.1 - Open
- 4.3.2 - Configuration
- 4.3.3 - Analog Inputs
- 4.3.4 - Analog Outputs
- 4.3.5 - Digital I/O
- 4.3.6 - Timers & Counters
- 4.3.7 - Stream Mode
- 4.3.8 - Raw Output/Input
- 4.3.9 - Easy Functions
- 4.3.10 - SPI Serial Communication
- 4.3.11 - I²C Serial Communication
- 4.3.12 - Asynchronous Serial Communication
- 4.3.13 - Watchdog Timer
- 4.3.14 - Miscellaneous
- 4.4 - Errorcodes
- 5 - Low-level Function Reference
- 5.1 - General Protocol
- 5.2 - Low-Level Functions
- 5.2.1 - Bad Checksum
- 5.2.2 - ConfigU3
- 5.2.3 - ConfigIO
- 5.2.4 - ConfigTimerClock
- 5.2.5 - Feedback
- 5.2.5.1 - AIN: IOType = 1
- 5.2.5.2 - WaitShort: IOType=5
- 5.2.5.3 - WaitLong: IOType=6
- 5.2.5.4 - LED: IOType=9
- 5.2.5.5 - BitStateRead: IOType=10
- 5.2.5.6 - BitStateWrite: IOType=11
- 5.2.5.7 - BitDirRead: IOType=12
- 5.2.5.8 - BitDirWrite: IOType=13
- 5.2.5.9 - PortStateRead: IOType=26
- 5.2.5.10 - PortStateWrite: IOType=27
- 5.2.5.11 - PortDirRead: IOType=28
- 5.2.5.12 - PortDirWrite: IOType=29
- 5.2.5.13 - DAC# (8-bit): IOType=34,35
- 5.2.5.14 - DAC# (16-bit): IOType=38,39
- 5.2.5.15 - Timer#: IOType=42,44
- 5.2.5.16 - Timer#Config: IOType=43,45
- 5.2.5.17 - Counter#: IOType=54,55
- 5.2.5.18 - Buzzer: IOType=63
- 5.2.6 - ReadMem (ReadCal)
- 5.2.7 - WriteMem (WriteCal)
- 5.2.8 - EraseMem (EraseCal)
- 5.2.9 - Reset
- 5.2.10 - StreamConfig
- 5.2.11 - StreamStart
- 5.2.12 - StreamData
- 5.2.13 - StreamStop
- 5.2.14 - Watchdog
- 5.2.15 - SPI
- 5.2.16 - AsynchConfig
- 5.2.17 - AsynchTX
- 5.2.18 - AsynchRX
- 5.2.19 - I²C
- 5.2.20 - SHT1X
- 5.2.21 - SetDefaults (SetToFactoryDefaults)
- 5.2.22 - ReadDefaults (ReadCurrent)
- 5.2.23 - 1-Wire
- 5.3 - Errorcodes
- 5.4 - Calibration Constants
- Appendix A - Specifications
- Appendix B - Enclosure and PCB Drawings
- U3 Firmware Revision History
- U6 Datasheet
- Preface: Warranty, Liability, Compliance
- 1 - Installation
- 2 - Hardware Description
- 2.1 - USB
- 2.2 - Power and Status LED
- 2.3 - GND and SGND
- 2.4 - VS
- 2.5 - 10UA and 200UA
- 2.6 - AIN
- 2.6.1 - Channel Numbers
- 2.6.2 - Converting Binary Readings to Voltages
- 2.6.3 - Typical Analog Input Connections
- 2.6.3.1 - Signal from the LabJack
- 2.6.3.2 - Unpowered Isolated Signal
- 2.6.3.3 - Signal Powered By the LabJack
- 2.6.3.4 - Signal Powered Externally
- 2.6.3.5 - Amplifying Small Signal Voltages
- 2.6.3.6 - Signal Voltages Beyond ±10 Volts (and Resistance Measurement)
- 2.6.3.7 - Measuring Current (Including 4-20 mA) with a Resistive Shunt
- 2.6.3.8 - Floating/Unconnected Inputs
- 2.6.4 - Internal Temperature Sensor
- 2.6.5 - Signal Range
- 2.7 - DAC
- 2.8 - Digital I/O
- 2.9 - Timers/Counters
- 2.9.1 - Timer Mode Descriptions
- 2.9.1.1 - PWM Output (16-Bit, Mode 0)
- 2.9.1.2 - PWM Output (8-Bit, Mode 1)
- 2.9.1.3 - Period Measurement (32-Bit, Modes 2 & 3)
- 2.9.1.4 - Duty Cycle Measurement (Mode 4)
- 2.9.1.5 - Firmware Counter Input (Mode 5)
- 2.9.1.6 - Firmware Counter Input With Debounce (Mode 6)
- 2.9.1.7 - Frequency Output (Mode 7)
- 2.9.1.8 - Quadrature Input (Mode 8)
- 2.9.1.9 - Timer Stop Input (Mode 9)
- 2.9.1.10 - System Timer Low/High Read (Modes 10 & 11)
- 2.9.1.11 - Period Measurement (16-Bit, Modes 12 & 13)
- 2.9.1.12 - Line-to-Line Measurement (Mode 14)
- 2.9.2 - Timer Operation/Performance Notes
- 2.9.1 - Timer Mode Descriptions
- 2.10 - SPC (or VSPC)
- 2.11 - DB37
- 2.12 - DB15
- 2.13 - OEM Connector Options
- 3 - Operation
- 4 - LabJackUD High-Level Driver
- 4.1 - Overview
- 4.2 - Function Reference
- 4.2.1 - ListAll()
- 4.2.2 - OpenLabJack()
- 4.2.3 - eGet() and ePut()
- 4.2.4 - eAddGoGet()
- 4.2.5 - AddRequest()
- 4.2.6 - Go()
- 4.2.7 - GoOne()
- 4.2.8 - GetResult()
- 4.2.9 - GetFirstResult() and GetNextResult()
- 4.2.10 - DoubleToStringAddress()
- 4.2.11 - StringToDoubleAddress()
- 4.2.12 - StringToConstant()
- 4.2.13 - ErrorToString()
- 4.2.14 - GetDriverVersion()
- 4.2.15 - TCVoltsToTemp()
- 4.2.16 - ResetLabJack()
- 4.2.17 - eAIN()
- 4.2.18 - eDAC()
- 4.2.19 - eDI()
- 4.2.20 - eDO()
- 4.2.21 - eTCConfig()
- 4.2.22 - eTCValues()
- 4.3 - Example Pseudocode
- 4.3.1 - Open
- 4.3.2 - Configuration
- 4.3.3 - Analog Inputs
- 4.3.4 - Analog Outputs
- 4.3.5 - Digital I/O
- 4.3.6 - Timers & Counters
- 4.3.7 - Stream Mode
- 4.3.8 - Raw Output/Input
- 4.3.9 - Easy Functions
- 4.3.10 - SPI Serial Communication
- 4.3.11 - I²C Serial Communication
- 4.3.12 - Asynchronous Serial Communication
- 4.3.13 - Watchdog Timer
- 4.3.14 - Miscellaneous
- 4.4 - Errorcodes
- 5 - Low-level Function Reference
- 5.1 - General Protocol
- 5.2 - Low-Level Functions
- 5.2.1 - Bad Checksum
- 5.2.2 - ConfigU6
- 5.2.3 - ConfigIO
- 5.2.4 - ConfigTimerClock
- 5.2.5 - Feedback
- 5.2.5.1 - AIN: IOType = 1
- 5.2.5.2 - AIN24: IOType = 2
- 5.2.5.3 - AIN24AR: IOType = 3
- 5.2.5.4 - WaitShort: IOType=5
- 5.2.5.5 - WaitLong: IOType=6
- 5.2.5.6 - LED: IOType=9
- 5.2.5.7 - BitStateRead: IOType=10
- 5.2.5.8 - BitStateWrite: IOType=11
- 5.2.5.9 - BitDirRead: IOType=12
- 5.2.5.10 - BitDirWrite: IOType=13
- 5.2.5.11 - PortStateRead: IOType=26
- 5.2.5.12 - PortStateWrite: IOType=27
- 5.2.5.13 - PortDirRead: IOType=28
- 5.2.5.14 - PortDirWrite: IOType=29
- 5.2.5.15 - DAC# (8-bit): IOType=34,25
- 5.2.5.16 - DAC# (16-bit): IOType=38,39
- 5.2.5.17 - Timer#: IOType=42,44,46,48
- 5.2.5.18 - Timer#Config: IOType = 43, 45, 47, 49
- 5.2.5.19 - Counter#: IOType = 54, 55
- 5.2.6 - ReadMem (ReadCal)
- 5.2.7 - WriteMem (WriteCal)
- 5.2.8 - EraseMem (EraseCal)
- 5.2.9 - SetDefaults (SetToFactoryDefaults)
- 5.2.10 - ReadDefaults (ReadCurrent)
- 5.2.11 - Reset
- 5.2.12 - StreamConfig
- 5.2.13 - StreamStart
- 5.2.14 - StreamData
- 5.2.15 - StreamStop
- 5.2.16 - Watchdog
- 5.2.17 - SPI
- 5.2.18 - AsynchConfig
- 5.2.19 - AsynchTX
- 5.2.20 - AsynchRX
- 5.2.21 - I²C
- 5.2.22 - SHT1X
- 5.2.23 - 1-Wire
- 5.2.24 - StreamAddChannels
- 5.3 - Errorcodes
- 5.4 - Calibration Constants
- Appendix A - Specifications
- Appendix B - Noise and Resolution Tables
- Appendix C - Enclosure and PCB Drawings
- U6 Firmware Revision History
- Digit Datasheet (Discontinued)
- UE9 Datasheet
- Preface
- 1 - Installation
- 2 - Hardware Description
- 2.1 - USB
- 2.2 - Ethernet
- 2.3 - Vext (Screw Terminals and Power Jack)
- 2.4 - Comm and Control LEDs
- 2.5 - GND and SGND
- 2.6 - VS
- 2.7 - AIN
- 2.7.1 - Channel Numbers
- 2.7.2 - Converting Binary Readings to Voltages
- 2.7.3 - Typical Analog Input Connections
- 2.7.3.1 - Signal from the LabJack
- 2.7.3.2 - Unpowered Isolated Signal
- 2.7.3.3 - Signal Powered by the LabJack
- 2.7.3.4 - Signal Powered Externally
- 2.7.3.5 - Amplifying Small Signal Voltages
- 2.7.3.6 - Signal Voltages Beyond ±5 Volts (and Resistance Measurement)
- 2.7.3.7 - Measuring Current (Including 4-20 mA) with a Resistive Shunt
- 2.7.3.8 - Floating/Unconnected Inputs
- 2.7.4 - Internal Temperature Sensor
- 2.8 - DAC
- 2.9 - Digital I/O
- 2.10 - Timers/Counters
- 2.10.1 - Timer Mode Descriptions
- 2.10.1.1 - PWM Output (16-Bit, Mode 0)
- 2.10.1.2 - PWM Output (8-Bit, Mode 1)
- 2.10.1.3 - Period Measurement (32-Bit, Modes 2 & 3)
- 2.10.1.4 - Duty Cycle Measurement (Mode 4)
- 2.10.1.5 - Firmware Counter Input (Mode 5)
- 2.10.1.6 - Firmware Counter Input With Debounce (Mode 6)
- 2.10.1.7 - Frequency Output (Mode 7)
- 2.10.1.8 - Quadrature Input (Mode 8)
- 2.10.1.9 - Timer Stop Input (Mode 9)
- 2.10.1.10 - System Timer Low/High Read (Modes 10 & 11)
- 2.10.1.11 - Period Measurement (16-Bit, Modes 12 & 13)
- 2.10.2 - Timer Operation/Performance Notes
- 2.10.1 - Timer Mode Descriptions
- 2.11 - SCL and SDA (or SCA)
- 2.12 - DB37
- 2.13 - DB15
- 2.14 - OEM Connector Options
- 3 - Operation
- 4 - LabJackUD High-Level Driver
- 4.1 - Overview
- 4.2 - Function Reference
- 4.2.1 - ListAll()
- 4.2.2 - OpenLabJack()
- 4.2.3 - eGet() and ePut()
- 4.2.4 - eAddGoGet()
- 4.2.5 - AddRequest()
- 4.2.6 - Go()
- 4.2.7 - GoOne()
- 4.2.8 - GetResult()
- 4.2.9 - GetFirstResult() and GetNextResult()
- 4.2.10 - DoubleToStringAddress()
- 4.2.11 - StringToDoubleAddress()
- 4.2.12 - StringToConstant()
- 4.2.13 - ErrorToString()
- 4.2.14 - GetDriverVersion()
- 4.2.15 - TCVoltsToTemp()
- 4.2.16 - ResetLabJack()
- 4.2.17 - eAIN()
- 4.2.18 - eDAC()
- 4.2.19 - eDI()
- 4.2.20 - eDO()
- 4.2.21 - eTCConfig()
- 4.2.22 - eTCValues()
- 4.3 - Example Pseudocode
- 4.3.1 - Open
- 4.3.2 - Configuration
- 4.3.3 - Analog Inputs
- 4.3.4 - Analog Outputs
- 4.3.5 - Digital I/O
- 4.3.6 - Timers & Counters
- 4.3.7 - Stream Mode
- 4.3.8 - Raw Output/Input
- 4.3.9 - Easy Functions
- 4.3.10 - SPI Serial Communication
- 4.3.11 - I²C Serial Communication
- 4.3.12 - Asynchronous Serial Communication
- 4.3.13 - Watchdog Timer
- 4.3.14 - Miscellaneous
- 4.4 - Errorcodes
- 5 - Low-level Function Reference
- 5.1 - General Protocol
- 5.2 - Comm Functions
- 5.3 - Control Functions
- 5.3.1 - BadChecksum
- 5.3.2 - ControlConfig
- 5.3.3 - Feedback (and FeedbackAlt)
- 5.3.4 - SingleIO
- 5.3.5 - TimerCounter
- 5.3.6 - StreamConfig
- 5.3.7 - StreamStart
- 5.3.8 - StreamData
- 5.3.9 - StreamStop
- 5.3.10 - ReadMem
- 5.3.11 - WriteMem
- 5.3.12 - EraseMem
- 5.3.13.1 - WatchdogConfig
- 5.3.13.2 - WatchdogRead
- 5.3.13.3 - Extended WatchdogConfig
- 5.3.13.4 - WatchdogClear
- 5.3.15 - Reset
- 5.3.16 - SPI
- 5.3.17 - AsynchConfig
- 5.3.18 - AsynchTX
- 5.3.19 - AsynchRX
- 5.3.20 - I²C
- 5.3.21 - SHT1X
- 5.3.22 - StreamDAC
- 5.3.23 - SetDefaults (SetToFactoryDefaults)
- 5.3.24 - ReadDefaults (ReadCurrent)
- 5.3.25 - 1-Wire
- 5.4 - Low-Level Errorcodes
- 5.5 - Modbus
- 5.6 - Calibration Constants
- 6 - Low-level Native Examples
- Appendix A - Specifications
- Appendix B - Noise and Resolution Tables
- Appendix C - Enclosure and PCB Drawings
- UE9 Firmware Revision History
- U12 Datasheet
- 1 - Installation
- 2 - Hardware Description
- 3 - Example Applications
- 4 - Programming Reference
- 4.1 - EAnalogIn
- 4.2 - EAnalogOut
- 4.3 - ECount
- 4.4 - EDigitalIn
- 4.5 - EDigitalOut
- 4.6 - AISample
- 4.7 - AIBurst
- 4.8 - AIStreamStart
- 4.9 - AIStreamRead
- 4.10 - AIStreamClear
- 4.11 - AOUpdate
- 4.12 - AsynchConfig
- 4.13 - Asynch
- 4.14 - BitsToVolts
- 4.15 - VoltsToBits
- 4.16 - Counter
- 4.17 - DigitalIO
- 4.18 - GetDriverVersion
- 4.19 - GetErrorString
- 4.20 - GetFirmwareVersion
- 4.21 - GetWinVersion
- 4.22 - ListAll
- 4.23 - LocalID
- 4.24 - NoThread
- 4.25 - PulseOut
- 4.26 - PulseOutStart
- 4.27 - PulseOutFinish
- 4.28 - PulseOutCalc
- 4.29 - ReEnum
- 4.30 - Reset (or ResetLJ)
- 4.31 - SHT1X
- 4.32 - SHTComm
- 4.33 - SHTCRC
- 4.34 - Synch
- 4.35 - Watchdog
- 4.36 - ReadMem
- 4.37 - WriteMem
- 4.38 - BuildOptionBits (ActiveX only)
- 4.39 - FourPack (ActiveX only)
- 4.40 - Description of Errorcodes
- 5 - Low-Level Function Reference
- Appendix A - Specifications
- Appendix B - Dimensions
- Appendix C - U12 Hardware Troubleshooting
- Appendix D - Maximum Data Rates for the LabJack U12
- Accessories
29 comments
Programming Efficiency
I noticed in the U3_Simple_Logger.m file that you don't preinitialize the size of the array for Error, AINX, and FIOX. This will dramatically decrease the speed of data acquisition as the array gets larger. Since you are already requesting the 'time' and 'dt' variables, the following lines should be added at the beginning of the program to increase program speed for longer tests.
It may be desirable to initialize values to -100 in case samples are missed (these values could get filtered later).
- A concerned citizen with Matlab expertise
Thank You for Your Comment
Thank you for your suggestion and we will be sure to fix that in the examples as soon as possible.
-- Labjack Support
Hello, Could you please help
Hello,
Could you please help me with Labjack U6 access in Matlab Linux?
I found this tread, which is about Matlab and Mac, which only creates access
through the lower part of the driver (exodriver):
http://forums.labjack.com/index.php?showtopic=5068
It is pretty helpfull, but i also want the higher level functions like in the u6.c.
For this i compiled the u6.c to a library (.so) and loaded that one into Matlab.
Then i am able to e.g. change digital 0 out from low to high with the following Matlab call:
calllib( 'libu6', 'eDO', handle, 0, 1 );
or read the state of digital 1 input with:
calllib( 'libu6', 'eDI', handle, 1, state );
However if i want to use the analog stuf, but then i need to get the calibration values first.
E.g.
calibrationinfo.prodID = 0;
calibrationinfo.hiRes = 0;
calibrationinfo.ccConstants = zeros(1,40);
if( calllib( 'libu6', 'getCalibrationInfo', handle, calibrationinfo ) ~= 0 )
error( 'problem with getting calibrationinfo' );
end
But whatever i try the cells in the calibrationinfo struct stay empty.
So there is something going wrong with passing the calibrationinfo struct
back to the Matlab environment.
Can you help me out?
Regards,
Andre
Try using libstruct to create
Try using libstruct to create the struct and see if that helps. Here's the libstruct and calllib documentation (provides libstruct examples):
http://www.mathworks.com/help/techdoc/ref/libstruct.html
http://www.mathworks.com/help/techdoc/ref/calllib.html
Hi thanks for your answer, I
Hi thanks for your answer,
I could pass an empty array as input, and get the calibration struct
from one of the return values.
See example .m code below:
% Get calibration information, required for the ADC and DAC:
[state, tmp, cali] = calllib( 'libu6', 'getCalibrationInfo', handle, [] );
% Get ADC value from AIN0:
[state, tmp, tmp2, value] = calllib( 'libu6', 'eAIN', handle, cali, 0, 15, 0, LJ_rgBIP10V, 0, 0, 0, 0, 0 );
Except for a bunch of warnings when loading the u6 library in Matlab, everything
works amazingly.
Thanks again,
Andre
Hi all, Here an example
Hi all,
Here an example Matlab script for linux using a compiled version of the u6.c as shared library to get access to the high level functions like eAIN and eDAC.
Have fun
Andre
% Andre, March 27, 2012
% Version 1.2
% Tested on 32 bit Ubuntu 10.10 Linux
% Tested with MatLab 7.10.0.499 (R2010a)
% Use the higher level u6 functions, like eAIN and eDAC, with ONE LabJack U6.
% Loading the u6 library generates quite some warnings, but it looks like
% everything works just fine.
clear all;
ljud_Constants;
my_reload = 0;
if my_reload ~= 0
disp( 'unload libraries' );
unloadlibrary('liblabjackusb');
unloadlibrary('libu6');
end
% Load exodriver, which contains low level functions like read and write
if ~ libisloaded('liblabjackusb')
disp( 'load labjack library' );
header = '/usr/local/include/labjackusb.h';
ljlib = '/usr/local/lib/liblabjackusb.so';
[notfound,warnings]=loadlibrary(ljlib, header);
end
% Load u6 library, which contains high level functions like eAIN and eDAC
if ~ libisloaded('libu6')
disp( 'load u6 library' );
% Created shared libary with the following command:
% gcc -Wall -g -fPIC -shared /usr/local/lib/liblabjackusb.so -Wl,-soname,libu6.so -o libu6.so u6.c
u6header = '/home/andre/matlab/u6.h';
u6ljlib = '/home/andre/matlab/libu6.so';
[notfound,warnings]=loadlibrary(u6ljlib, u6header);
% Andre: this loadlibary gives a lot of WARNINGS!!
% disp( warnings );
end
% Show available functions with arguments of both libraries:
% libfunctionsview liblabjackusb
% libfunctionsview libu6
% Check LabJack library version:
if calllib( 'liblabjackusb', 'LJUSB_GetLibraryVersion' ) ~= 2.0
warning( 'This implementation is only tested with library version 2.0' );
end
% Check if there is exactly ONE LabJack attached:
if calllib( 'liblabjackusb', 'LJUSB_GetDevCount', LJ_dtU6 ) ~= 1
error( 'There should be exactly ONE LabJack U6 device attached' );
end
% Open the device and verify the returned handle:
handle = calllib( 'liblabjackusb', 'LJUSB_OpenDevice', 1, 0, LJ_dtU6 );
[handle_valid, tmp] = calllib( 'liblabjackusb', 'LJUSB_IsHandleValid', handle );
if ~handle_valid error( 'LabJack handle is invalid' ); end
% Get calibration information, required for the ADC and DAC:
[state, tmp, cali] = calllib( 'libu6', 'getCalibrationInfo', handle, [] );
if state ~= 0 error( 'Cannot get calibration info' ); end
% Check if the calibration struct contains appropriate data:
if cali.prodID ~= LJ_dtU6 error( 'Calibration struct is invalid' ); end
% Get ADC value from AIN0 to AIN14 and Labjack temperature:
for chan=1:15,
[state, tmp, tmp2, value(chan)] = calllib( 'libu6', 'eAIN', handle, cali, chan-1, 15, 0, LJ_rgBIP10V, 0, 0, 0, 0, 0 );
if state ~= 0 error( 'Problem getting eAIN' ); end
end
fprintf( 'LabJack temperature: %.2fC\n', value(15)-273.15 );
fprintf( 'ADC val: ' );
for chan=1:14,
fprintf( ' %4.2f', value(chan) );
end
fprintf( '\n' );
% Now determine the mean, maximum and minimum for each channel for a number of samples
measure = zeros( 100, 6 ); % number of samples, number of channels
fprintf( 'Collect %d samples for %d ADC inputs (interleaved)\n', size(measure,1), size(measure,2) );
for ii = 1:size(measure,1),
for chan = 1:size(measure,2),
[state, tmp, tmp2, measure(ii,chan)] = calllib( 'libu6', 'eAIN', handle, cali, chan-1, 15, 0, LJ_rgBIP10V, 0, 0, 0, 0, 0 );
if state ~= 0 error( 'Problem getting eAIN' ); end
end
end
fprintf( 'ADC mean: ' );
for chan = 1:size(measure,2),
fprintf( ' %4.2f', mean(measure( :, chan) ) );
end
fprintf( '\n' );
fprintf( 'ADC max: ' );
for chan = 1:size(measure,2),
fprintf( ' %4.2f', max(measure( :, chan) ) );
end
fprintf( '\n' );
fprintf( 'ADC min: ' );
for chan = 1:size(measure,2),
fprintf( ' %4.2f', min(measure( :, chan) ) );
end
fprintf( '\n' );
plot(measure);
title( '\bf{\it{LabJack U6 ADC Measurement}}' );
legend_str = {};
for chan = 1:size(measure,2),
legend_str( chan ) = {['AIN ', num2str( chan ) ]};
end
legend( legend_str );
xlabel( 'Time [samples]' );
ylabel( 'Amplitude [V]' );
grid on;
% Test the DAC by setting 2.55V on DAC 0 and 1.80V on DAC 1
[state, tmp, tmp2] = calllib( 'libu6', 'eDAC', handle, cali, 0, 2.55, 0, 0, 0 );
if state ~= 0 error( 'Problem setting eDAC' ); end
[state, tmp, tmp2] = calllib( 'libu6', 'eDAC', handle, cali, 1, 1.80, 0, 0, 0 );
if state ~= 0 error( 'Problem setting eDAC' ); end
% Digital out FIO, set FIO 0 to high, set FIO 2 to low
[state, tmp] = calllib( 'libu6', 'eDO', handle, 0, 1 );
if state ~= 0 error( 'Problem getting eD0' ); end
[state, tmp] = calllib( 'libu6', 'eDO', handle, 2, 0 );
if state ~= 0 error( 'Problem getting eD0' ); end
% Digital in FIO, get FIO 1 (should be high) and FIO 3 (should be low)
% Asume FIO 0 is connected to FIO 1 and FIO 2 is connected with FIO 3
[state, tmp, fio1] = calllib( 'libu6', 'eDI', handle, 1, 0 );
if state ~= 0 error( 'Problem getting eDI' ); end
if fio1 ~= 1 warning( 'Should be high if connected to FIO 0' ); end
[state, tmp, fio3] = calllib( 'libu6', 'eDI', handle, 3, 0 );
if state ~= 0 error( 'Problem with getting eDI' ); end
if fio3 ~= 0 warning( 'Should be high if connected to FIO 2' ); end
% All done, close LabJack:
calllib( 'liblabjackusb', 'LJUSB_CloseDevice', handle );
fprintf( 'All done!\n' );
when I wanted to load the
when I wanted to load the standard LabJackUD library into MATLAB using ljud_LoadDriver function it showed error like this.
??? Error using ==> loadlibrary>lFullPath at 550
Could not find file C:\progra~1\LabJack\drivers\labjackud.h.
Error in ==> loadlibrary at 220
header=lFullPath(header);
Error in ==> ljud_LoadDriver at 10
loadlibrary('labjackud',header);
I checked the required path and header file is still there.Can u give a solution for this?
Sometimes this is caused by
Sometimes this is caused by 64-bit systems, since the file will be in C:\program files(x86)\LabJack\drivers instead of C:\Program files\LabJack\Drivers.
Other things you can try are putting the header file into an easier to find spot C:\header\ or something similar then changing the path links. Sometimes it's a problem with folder names being more than 8 characters.
Hi, We have tried this, but
Hi,
We have tried this, but we now get 'Index exeeds matrix dimensions.'
Thanks.
Make sure you have the
Make sure you have the required C compiler installed for loadlibrary and related calls to work in your version of MATLAB:
http://www.mathworks.com/help/matlab/ref/loadlibrary.html
http://www.mathworks.com/support/sysreq/previous_releases.html (supported compilers for different versions of MATLAB)
I've seen that error occur when the C compiler is not installed.
Hi,i'm using a U3HV,when i
Hi,
i'm using a U3HV,
when i try to load drivers:
>> ljud_LoadDriver
Error using loadlibrary (line 419)
Building labjackud_thunk_pcwin64 failed. Compiler output is:
cl -I"C:\Program Files\MATLAB\R2012a\extern\include" /W3 /D_CRT_SECURE_NO_DEPRECATE
/D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo
-I"\\icfs8.cc.ic.ac.uk\mb5912\MATLAB\Cylinder Simulation\MATLAB_LJUD\LJUD_Functions"
-I"C:\" "labjackud_thunk_pcwin64.c" -LD -Fe"labjackud_thunk_pcwin64.dll"
cl : Command line error D8003 : missing source filename
Error in ljud_LoadDriver (line 10)
loadlibrary('labjackud',header);
What can i do?
Many thank's!
That isn't one we have seen
That isn't one we have seen before. Is it a 64-bit version of MATLAB? You might try using the 32-bit version (which tends to have less of these kinds of errors) or install our 64-bit version of the LabJackUD.dll which can be found here: http://labjack.com/support/ud/ud-setup-64-bit/labjackud-dll-64-bit
**Edit - This separate .dll is no longer needed since the current LabJack installer includes everything for both 32-bit and 64-bit versions.
Hi, I'm using the provided
Hi, I'm using the provided .NET Matlab examples on a U6 with the latest driver and firmware. I'm having show show-stopping problems running u6_simplestream.m:
1. I'm getting "Stream scan overlapped" error from Matlab with the same configuration as LJStreamUD. In fact, Matlab could only support ~1/2 the maximum rate LJStreamUD supports.
2. Under 64bit win7 with 64bit Matlab, I'm getting a System.AccessViolationException when at the ljudObj.eGet() that attempts to read the stream data. The full Matlab output is as follows:
UD Driver Version = 3.39
Actual Scan Rate = 100
Actual Sample Rate = 200
.NET Error: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at LabJack.LabJackUD.LJUD.UDeGet(Int32 handle, IO IOType, CHANNEL channel, Double& val, Double[] x1)
at LabJack.LabJackUD.LJUD.eGet(Int32 handle, IO IOType, CHANNEL channel, Double& val, Double[] x1)
Error using u6_simplestream (line 125)
Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source: LJUDDotNet
HelpLink:
Help anybody?
I responded to this question
I responded to this question in your forum topic here:
http://forums.labjack.com/index.php?showtopic=6361
Hi! I am working with a
Hi!
I am working with a LabJack U3 for Matlab on Windows
I had a problem with a command line, the statement of chanType
chanType=LabJack.LabJackUD.CHANNEL.LOCALID.GetType;
The error is "Get Type is not a method, property or field to CHANNEL class"
I need help with this. Any suggestion?
Thanks
It looks like you are using
It looks like you are using the .NET examples with MATLAB 2010 or older. We've seen issues where older MATLAB versions can't handle these type of .NET calls, giving the error you are seeing, but the MATLAB version we tested with (2013a) runs the code fine.
First, make sure you are running the latest version of the Windows software for the U3:
http://labjack.com/support/software
Second, remove the line of code causing the issue and the "System.Enum.ToObject" calls that use the chanType object. That code is used to typecast a value to a LabJack.LabJackUD.CHANNEL object but doesn't work in MATLAB 2010 or older. Since the .NET examples' release, we have updated the UD .NET driver where these typecasts are not necessary and you can pass just the channel value. For example, instead of:
chanObj = System.Enum.ToObject(chanType, 0); %channel = 0
ljudObj.ePut(ljhandle, LabJack.LabJackUD.IO.PIN_CONFIGURATION_RESET, chanObj, 0, 0);
use:
ljudObj.ePut(ljhandle, LabJack.LabJackUD.IO.PIN_CONFIGURATION_RESET, 0, 0, 0);
Sometime we will look into updating the examples to work right away under MATLAB 2009 to 2010 versions, but in the meantime the above code is a workaround for these issues.
To update this issue, the
To update this issue, the examples have been updated. The "Get Type is not a method, property or field to CHANNEL class" and similar errors have been resolved when using MATLAB 2009 to 2010.
Hi, I am using LabJack U3-HV
Hi,
I am using LabJack U3-HV on Mac OS X. I downloaded the exodriver, but unsure how to use it from MATLAB to read trigger signals.
I can load the liblabjackusb into Matlab, but do not know which functions (e.g. there are multiple read functions) and what input arguments to use.
Could you help me? Any example code would be also appreciated.
Thanks.
We do not provide MATLAB
We do not provide MATLAB examples for Mac OS X. To help with Exodriver function usage with a U3, take a look at the C examples included in the Exodriver download:
http://labjack.com/support/linux-and-mac-os-x-drivers
Also, the Exodriver functions' documentation are in the labjackusb.h header file.
The user Iandol on our forum made a U3/U6 MATLAB class for Mac OS X which may be helpful:
https://github.com/iandol/opticka/blob/master/communication/labJack.m
It´s Posible to use the
It´s Posible to use the labJack on Simulink. I try it but I can´t.
We do not provide a Simulink
We do not provide a Simulink specific interface, but you can use MATLAB code to use a LabJack in Simulink. The examples only demonstrate LabJack usage in MATLAB. If you are having MATLAB code issues, please describe the problem you are having and/or provide error messages.
I'm trying to run the
I'm trying to run the u3_simple emample in Matlab, but getting the following error:
UD Driver Version = 3.43
UD Error: Invalid channel number
Error using u3_simple (line 30)
Message: Error in the application.
Source: LJUDDotNet
HelpLink:
I'm using a U3-HV. I have the latest firmware and drivers. I have the 32-bit R2013a Student Version of Matlab on a 64-bit Windows 7 OS.
The u3_simplestream is giving the same error message (line 53), but the u3_timer_counter example is working.
We are currently trying to
We are currently trying to get access to a copy of MATLAB 2013b for testing. Another user has the same issue in 2013b as well. The current examples were tested in MATLAB R2009b and didn't have issues.
Looks like the issue was
Looks like the issue was related to this U3 call:
ljudObj.ePut(ljhandle, LabJack.LabJackUD.IO.PUT_ANALOG_ENABLE_PORT, 0, 3, 16);
We updated the examples so these calls will work in newer versions of MATLAB. Also, we fixed the stream example for 64-bit versions of MATLAB.
Let us know if you run into further problems.
I am using Matlab 2013b 64
I am using Matlab 2013b 64 bit version on a WIndows 8.1 OS. I am trying to get the Labjack U6 examples to run and I keep getting the error
UD Driver Version = 3.37
UD Error: Stream is running
Error using u6_simple (line 70)
Message: Error in the application.
Source: LJUDDotNet
HelpLink:
Can you guide me on this?
Regards
Hi, I'm new whit the U3, I
Hi, I'm new whit the U3, I am using Matlab and I was trying to sample two analog inputs whith a sample frequency of 20000 (Samp/sec) but I am not able.
the error is: Buffer overrun while streaming...
I'm usign LJ_swSLEEP mode. Could some body help me please...?
When streaming both the UD
When streaming both the UD driver and the U3 buffer samples which your program reads from. If your program does not read at a fast enough rate (in your case 20000 samples/sec) these buffers will overflow leading to the error you are seeing.
If using LJ_swSLEEP mode, remove the "pause" from your read stream data loop as it is not needed and the UD driver delays until the amount of scans you specify are available. Also, make sure your stream buffer size is large enough for your scans rate (LJ_chSTREAM_BUFFER_SIZE) which we recommend configuring to 5 seconds worth of scans (scanRate * # channels * 5 seconds). For streaming using the UD driver, refer to here in the User's Guide:
http://labjack.com/support/u3/users-guide/4.3.7
If that doesn't help, please email your code to us at [email protected] so we can see how you configured stream mode and are reading data.
Hi, I am using the U3 with
Hi, I am using the U3 with Matlab 2013a on windows and for some reason I can't get a simple LED linked to the DAC0 to flicker at 10z.
Is it an issue with my line opening the labjack, adding the requests or executing the requests or is it that you cannot use the pause function?
Here is my code, hope you can help me ! :
%Open the first found LabJack U3.
[ljerror, ljhandle] = ljudObj.OpenLabJack(LabJack.LabJackUD.DEVICE.U3, LabJack.LabJackUD.CONNECTION.USB, '0', true, 0);
prompt = 'Length of flicker ? ';
s = input(prompt);
for n = 1:s
%AddRequest (Handle, IOType, Channel, Value, x1, UserData)
%Request that DAC0 be set to 4 volts.
ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_DAC, 0, 4.0, 0, 0);
pause(0.05) % in seconds
% then to 0 volts
ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_DAC, 0, 0.00, 0, 0);
pause(0.05)
end
%Execute the requests.
ljudObj.GoOne(ljhandle);
It looks like you are
It looks like you are building a list of DAC0 requests, and are then sending all those requests to the U3 outside the loop so your pause delay will have no effect. You can use pause for the delays, but you need to use the GoOne call after the AddRequest to set the DAC with your loop timing. Try something like this instead in your loop:
%Request that DAC0 be set to 4 volts.
ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_DAC, 0, 4.0, 0, 0);
ljudObj.GoOne(ljhandle); %Send the request
pause(0.05) %wait 0.05 seconds
% then to 0 volts
ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_DAC, 0, 0.00, 0, 0);
ljudObj.GoOne(ljhandle); %Send the request
pause(0.05) %wait 0.05 seconds
For a general UD driver overview where AddRequest, Go/GoOne, GetResult are discussed, look here:
http://labjack.com/support/u3/users-guide/4.1