Here's the starting point for Matlab developers for
interfacing Lawson Labs, Inc. data acquisition systems
Model 201
More information about the Model201 at
our website.
M201_SP.dll Must be in path. The easiest may be to have it in your
user/Documents/MATLAB
folder and then use addpath to add it to your path.
This
DLL&Header.zip
archive contains both the DLL and a header file.
Examples of how to use M201_SP.dll with Matlab
Here is a link to the
default parameters
loaded by the DLL when
uInt8 EX_InitDev (void);
is called prior to sending or recieving.
You should set up the DLL using the
listing of function calls along with their parameters and what they do
HERE.
Note that the prototypes are the same for Matlab as for Labview which is what the information at the link
mentions them being for.
An example of changing a parameter is, after making a call to EX_InitDev, a call to EX_SetCOMport can be made to set
the COM port, as well as many other calls to tailor the functioning of the DLL to your needs. Below is how that call looks:
COM_port = 2
retCode = EX_SetCOMport(COM_port);
It will set the COM_port to COM3. Note that this call uses zero-based port numbers.
Below is an example of Matlab code (and Matlab's responses) to load the DLL and make some calls into the DLL to get a
conversion in Polled mode, using a "Trial" copy of Matlab
Load the DLL
1.) Trial>> loadlibrary ('M201_SP', 'M201_SP')
Initialize device
2.) Trial>> retCode=0
retCode =
0
3.) Trial>> retCode = calllib('M201_SP', 'EX_InitDev')
retCode =
1
Set the polled mode channel and get one conversion
4.) Trial>> bMainChan=1
bMainChan =
1
5.) Trial>> bSubChan = 0
bSubChan =
0
6.) Trial>> retCode = calllib('M201_SP', 'EX_SetPolledModeChan', bMainChan, bSubChan)
retCode =
1
7.) Trial>> bSubChan = 0
bSubChan =
0
8.) Trial>> milliVolts=double([0])
milliVolts =
0
9.) Trial>> [retCode,voltage] = calllib('M201_SP', 'EX_GetOneConversion', milliVolts)
retCode =
1
milliVolts =
1000.07e+02
The entire API can be seen
HERE
Further reference to coding in Matlab can be seen in our
64-bit DLL examples. To make use of the examples there, replace all references to M201_SP_64bit with M201_SP
|