How can I get Data logging through Serial port communication to work?

5 views (last 30 days)
Hi,
I would like to read the data that is coming through the Serial port and the final goal is to build a funtion for data logging. Here is the data I obtained from Hyperterminal. There are 79 data points in each scan and the data is sent out every 5 seconds.
13/09/2012,16:15:56,064.3,065.6,040.0,091.3,094.8,1,1,0000000,063.9,061.1,063.6 ,106.9,042.3,063.1,000.0,077.4,064.2,090.1,025.0,002.0,063.5,000.5,034.0,034.0,0 46.0,103,000.0,091.2,092.4,087.9,0,0,0,0,0,084.3,000.5,0000000,063.8,060.6,063.3 ,109.1,044.7,063.4,000.0,078.2,064.0,086.8,021.9,002.0,063.4,000.4,040.0,040.0,0 46.0,103,000.1,095.8,097.7,092.7,0,0,0,0,0,083.8,000.0,0,0,000.0,065,065,000,000 ,005,103.6,0
13/09/2012,16:16:01,064.3,065.5,040.0,091.3,094.7,1,1,0000000,063.9,061.1,063.8
,107.0,042.2,063.2,000.0,077.3,064.2,090.1,025.0,002.0,063.5,000.5,034.0,034.0,0
46.0,103,000.0,091.2,092.4,087.9,0,0,0,0,0,084.4,000.6,0000000,063.8,060.6,063.2
,109.1,044.8,063.5,000.0,078.1,064.0,086.9,022.0,002.0,063.3,000.4,040.0,040.0,0
46.0,103,000.1,095.8,097.7,092.6,0,0,0,0,0,083.9,000.0,0,0,000.0,065,065,000,000
,005,103.6,0
13/09/2012,16:16:06,064.3,065.5,040.0,091.3,094.8,1,1,0000000,063.9,061.1,063.6
,107.0,042.4,063.1,000.0,077.4,064.2,090.1,025.0,002.0,063.5,000.5,034.0,034.0,0
46.0,103,000.0,091.2,092.4,087.9,0,0,0,0,0,084.3,000.5,0000000,063.8,060.6,063.3
,109.1,044.7,063.5,000.0,078.1,064.0,086.8,021.9,002.0,063.3,000.4,040.0,040.0,0
46.0,103,000.1,095.9,097.7,092.7,0,0,0,0,0,083.9,000.0,0,0,000.0,065,065,000,000
,005,103.5,0
Here is the code that I used in Matlab to see the data.
clear all; close all; delete(instrfindall)
s = serial('COM3'); %assigns the object s to serial port
set(s, 'InputBufferSize', 12800); %number of bytes in input buffer set(s, 'FlowControl', 'none'); set(s, 'BaudRate', 19200); set(s, 'Parity', 'none'); set(s, 'DataBits', 8); set(s, 'StopBit', 1); set(s, 'Timeout',15); set(s, 'Terminator', 'CR/LF'); fopen(s);
These are the commands I use along with the outputs I am getting:
fscanf(s)
Warning: A timeout occurred before the Terminator was reached.
ans =
''
fread(s)
Warning: The specified amount of data was not returned within the Timeout period.
ans =
0
0
0
fgets(s)
Warning: A timeout occurred before the Terminator was reached.
ans =
''
fgetl(s)
Warning: A timeout occurred before the Terminator was reached.
ans =
''
Is there anything I missed here? Why am I not getting any data. Any help is appreciated. Thank you.
  1 Comment
Jonathan
Jonathan on 28 Sep 2012
It sounds like some parameter is not set correctly. The fact that it returns nothing at all means it probably isn't the terminator. . . Perhaps try connecting to a serial device that you know is working correctly to get a feel for how it is set up or change some parameters on the device side.

Sign in to comment.

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!