using matlab for serial port - smth's weird
Hi everybody, I would need some help on that one.
A magneto-meter is connected via a serial port to matlab and actually everything works fine, EXCEPT that, if the data is read in continuous mode it shows some unreasonable jumps in between the physical smooth signal.
here's the code:
close all;
s = serial('COM3');
set(s, 'Terminator', 'CR') %is the proper terminator for the device
s.InputBufferSize = 30000;
s.BaudRate = 19200;
fopen(s)
fprintf(s, '*99C') %starting measurement
pause(5)
if(s.BytesAvailable > 0)
s.BytesAvailable
out = fread(s,s.BytesAvailable,'uint8');
fprintf(s,'ESC') %stopping measurement
...out gets processed further to convert the binary data to decimal in way that is of no concern here, but is certainly correct
fclose(s)
delete(s)
clear s
now what the weird part is, is the received data which is attached in the 'testo' file
there seems to be, for what ever reason, a wrong signal at around 0.25 and sometimes at 0.00 for the respective axes that is physically not there.
I guess the sensor basically works fine, and also, physical perturbations of the magnetic field that would correspond to the received data can be ruled out.
If anybody has any hint i really would appreciate it, I spent already too much time on looking at various different reasons for the thing.
thanks in advance. f
A magneto-meter is connected via a serial port to matlab and actually everything works fine, EXCEPT that, if the data is read in continuous mode it shows some unreasonable jumps in between the physical smooth signal.
here's the code:
close all;
s = serial('COM3');
set(s, 'Terminator', 'CR') %is the proper terminator for the device
s.InputBufferSize = 30000;
s.BaudRate = 19200;
fopen(s)
fprintf(s, '*99C') %starting measurement
pause(5)
if(s.BytesAvailable > 0)
s.BytesAvailable
out = fread(s,s.BytesAvailable,'uint8');
fprintf(s,'ESC') %stopping measurement
...out gets processed further to convert the binary data to decimal in way that is of no concern here, but is certainly correct
fclose(s)
delete(s)
clear s
now what the weird part is, is the received data which is attached in the 'testo' file
there seems to be, for what ever reason, a wrong signal at around 0.25 and sometimes at 0.00 for the respective axes that is physically not there.
I guess the sensor basically works fine, and also, physical perturbations of the magnetic field that would correspond to the received data can be ruled out.
If anybody has any hint i really would appreciate it, I spent already too much time on looking at various different reasons for the thing.
thanks in advance. f
0