MATLAB .NET example scripts for the LJM library.
MATLAB .NET example scripts for the LJM library.
Note: Add example scripts to the MATLAB path before running, and all examples require the functions in showDeviceInfo.m and showErrorMessage.m.
Refer to the download's README.txt file for more details.
With the LJM library, pretty much everything you might want to do with a device is accomplished by writing and/or reading some registers. Look at the device's datasheet (T7 or T4) or the Modbus Map to determine what registers you need to write and read, then use eWriteName (or eWriteNames) to write the desired registers and eReadName (or eReadNames) to read the desired registers. The following examples in the Basic folder are a great place to start:
You will find lots of examples in this archive, but there is not an example for everything the LabJack can do. The reason for this stems from the "Overview" section above. Most operations simply involve writing and reading different registers, so you really just need examples that show you how to write and read any register. If we had examples for every operation, they would just be copies of the example "Write Read Loop with Config" with different registers. The typical workflow to do almost anything beside stream is:
Stream mode and other operations that don't fit in "Write Read Loop with Config" will usually have specific examples, and if something seems to be missing let us know.
%Make the LJM .NET assembly visible in MATLAB ljmAsm = NET.addAssembly('LabJack.LJM'); handle = 0; try %Open first found LabJack [ljmError, handle] = LabJack.LJM.OpenS('ANY', 'ANY', 'ANY', handle); %Call eReadNames to read the serial number from the LabJack. name = 'SERIAL_NUMBER'; [ljmError, value] = LabJack.LJM.eReadName(handle, name, 0); disp('eReadName result:') disp([' ' name ' = ' num2str(value)]) catch e showErrorMessage(e) end
MATLAB_LJM_2017_12_04.zip contains:
LICENSE.txt README.txt Examples\getDeviceType.m Examples\showDeviceInfo.m Examples\showErrorMessage.m Examples\Basic\eAddresses.m Examples\Basic\eNames.m Examples\Basic\eReadAddress.m Examples\Basic\eReadAddresses.m Examples\Basic\eReadName.m Examples\Basic\eReadNames.m Examples\Basic\eWriteAddress.m Examples\Basic\eWriteAddresses.m Examples\Basic\eWriteName.m Examples\Basic\eWriteNames.m Examples\More\AIN\DualAINLoop.m Examples\More\AIN\SingleAIN.m Examples\More\AIN\SingleAINWithConfig.m Examples\More\Config\ReadConfig.m Examples\More\Config\ReadDeviceNameString.m Examples\More\Config\WriteDeviceNameString.m Examples\More\Config\WritePowerConfig.m Examples\More\DIO\SingleDIORead.m Examples\More\DIO\SingleDIOWrite.m Examples\More\Ethernet\ReadEthernetConfig.m Examples\More\Ethernet\ReadEthernetMac.m Examples\More\Ethernet\WriteEthernetConfig.m Examples\More\I2C\I2CEeprom.m Examples\More\ListAll\ListAll.m Examples\More\SPI\SPI.m Examples\More\Stream\StreamBasic.m Examples\More\Stream\StreamBasicWithStreamOut.m Examples\More\Stream\StreamBurst.m Examples\More\Stream\StreamSequentialAIN.m Examples\More\Testing\CRSpeedTest.m Examples\More\Watchdog\ReadWatchdogConfig.m Examples\More\Watchdog\WriteWatchdogConfig.m Examples\More\WiFi\ReadWiFiConfig.m Examples\More\WiFi\ReadWiFiMac.m Examples\More\WiFi\ReadWiFiRssi.m Examples\More\WiFi\WriteWiFiConfig.m