Matlab DLL access examples
|
Matlab entries
Here's the starting point for Matlab developers for
interfacing Lawson Labs, Inc. data acquisition systems
Model 201
M201_SP_64bit.dll and M201_SP_64bit.h Must be in path. The easiest may be to have in your
user/Documents/MATLAB
folder and then use addpath to add it to your path.
==============================
Load the DLL and set the port:
==============================
1.) >>loadlibrary('M201_SP_64bit', 'M201_SP_64bit')
note: the following is 0 based. If your windows COM port is 5, make this 4
2.) >>result=calllib('M201_SP_64bit', 'EX_SetCOMport', 4)
===========================
To get a single conversion:
===========================
note: set main chan 6 (zero based) and sub-chan (only valid if multiplexer used) to 0
1.) >>result=calllib('M201_SP_64bit', 'EX_SetPolledModeChan', 6, 0)
note: create a variable of type double
3.) >>volts = 0
note: make it a pointer that can be passed in function call
4.) >>volts_pntr=libpointer('doublePtr', volts)
5.) >>result=calllib('M201_SP_64bit', 'EX_GetOneConversion', volts_pntr)
note: read the data from the variable pointer
6.) >>get(volts_pntr)
=====================================
To get scan data for a single channel:
=====================================
1.) >>result=calllib('M201_SP_64bit', 'EX_SetScanType', 0)
note: the following code is hex 60 (see it as main chan 6, sub chan 0)
2.) >>result=calllib('M201_SP_64bit', 'EX_SetSingleChanScanChanCode', 96)
3.) >>result=calllib('M201_SP_64bit', 'EX_Run')
wait for a while as data is written to log file (ScanLog_xxx.txt) in same folder as DLL
4.) >>result=calllib('M201_SP_64bit', 'EX_Stop')
results of scan will be in ScanLog_xxx.txt in same folder as DLL. The "xxx" will be a numeric value of the instance of the scan - for example the
name for the first scan would be ScanLog_0.txt, the second would be ScanLog_1.txt
when finished, call
5.) >>unloadlibrary('M201_SP_64bit')
Get the 64-bit DLL and header file.
click any image to see larger view
Load DLL and get one conversion
|
Load DLL and start scan for continued data to data file
|
Results of scan (channel 6, full-scale) in ScanLog_x.txt
|
|
|