Hi,
Could you please tell me the very first few lines of code that I would need to write in MATLAB, in order to connect to T7, through Ethernet cable or USB cable.
I have tried downloading your MATLAB library and following some instructions that you have on your website, but I was not successful at all in even performing a handshake with a device. Can I just connect Ethernet or USB cable directly to my computer in order to talk to it, or would I need some third device (transceiver) in between.
I was successful in connecting to T7 with Kipling, using both Ethernet and USB, so I now that device is properly functioning.
Thank You!
For USB you can connect straight to your computer. No third device needed. For Ethernet, typically you connect your device to your network. For a direct Ethernet to computer connection we have an app note on that:
https://labjack.com/support/app-notes/networking/direct-connection-ether...
The examples by default try to connect to any device with any connection and identifier. First make sure other applications using the T7 are closed, and try one of the examples again with your T7 connected to your computer over USB or Ethernet. Note that over USB only one process can access a T7 at a time, so having Kipling open with your T7 selected will prevent your MATLAB code from opening a device.
As for the first lines of MATLAB code, opening a T7 with device and connection specified, and any identifier (serial number or IP Address) looks like:
% Make the LJM .NET assembly visible in MATLAB
ljmAsm = NET.addAssembly('LabJack.LJM');
handle = 0;
try
% Open first found LabJack
% T7 device, Any connection, Any identifier
[ljmError, handle] = LabJack.LJM.OpenS('T7', 'USB', 'ANY', handle);
% T7 device, Ethernet connection, Any identifier
% [ljmError, handle] = LabJack.LJM.OpenS('T7', 'ETHERNET', 'ANY', handle);
% And so on ...
General documentation on the OpenS function in the LJM library can be found here in the LJM User's Guide:
https://labjack.com/support/software/api/ljm/function-reference/ljmopens
Thank You for the prompt reply.
I have closed Kipling, power cycled T7 and connected to it through USB first, then through direct Ethernet to computer connection. Below is the error I get in MATLAB when trying to connect through USB as well as through Ethernet after:
>> ljmAsm = NET.addAssembly('LabJack.LJM');
>> handle = 0;
>> [ljmError, handle] = LabJack.LJM.OpenS('T7', 'USB', 'ANY', handle);
Message: LJME_UNKNOWN_ERROR
Source: LabJack.LJM
HelpLink:
I do not understand this error.
Close MATLAB and other applications that could be using the T7 such as Kipling. Then try the latest release Windows installer (currently dated 11/09/2017) and see if that helps with the unknown error:
https://labjack.com/support/software/installers/ljm
If you are still getting that error afterwards, what version of Windows and MATLAB are you using?
Thanks. I installed the latest Windows installer and then I was able to connect to MATLAB. Just for reference, I am using MATLAB R2015b version.