How do I connect a CEM Smart 6 Moisture Analyzer to MATLAB?
4 views (last 30 days)
Show older comments
MathWorks Support Team
on 17 Feb 2021
Answered: MathWorks Support Team
on 23 Feb 2021
I am using a CEM SMART 6 Moisture Analyzer:
I would like to get data from it into MATLAB so that I can plot and analyze it. How can I do this with the Instrument Control Toolbox?
Accepted Answer
MathWorks Support Team
on 17 Feb 2021
Connecting the SMART 6 to MATLAB is possible via a Serial COM connection.
1) Install the Universal FTDI driver if not already installed. To verify, check Device Manger => Ports (COM & LPT). While Device Manager is open, plug the SMART 6 into the PC. If a device shows up with an exclamation point, then it needs the driver.
2) Take note of the COM Port number associated with the device.
3) Connect the instrument to MATLAB via a Serial COM port:
s = serialport("COM1",15200) % Use the COM Port from step 2
4) Prepare to stream data
configureTerminator(s, "CR/LF");
flush(s);
s.UserData = {};
5) Write a callback function to handle the incoming data:
function readSmart6Data(src, ~)
% Read the ASCII data from the serialport object.
data = readline(src);
% Save the ASCII data in the UserData property of the serialport object.
src.UserData{end+1} = data;
end
6) Attach the callback to the serial port object:
configureCallback(s,"terminator",@readSmart6Data);
7) Start a sample run on the instrument to receive the raw ASCII data, one point per second until the test is complete
It is also possible to receive the data using TeraTerm or PuTTY, save it to a CSV, and then import it into MATLAB for analysis and plotting.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!