Gast
#4471101
Guten Tag
Ich habe einige Probleme meine serielle Kommunikation mit MATLAB in den
Griff zu kriegen.
Das bild zeigt, wie ich mittels Docklight mit meinem Controller
kommuniziert habe. Sobald der Controllier initialisiert ist, will ich
die letzten drei Schritte in einer Schleife laufen lassen, damit ich an
die Messdaten gelange (bisher noch nicht im MATLAB code).
Wichtig ist noch, dass ich die Software vom Controller nicht verändern
möchte.
Hat jemand eine Idee, was bei der Kommunikation falsch ist?
Ich kriege nur "ISO15693: [5D0E000000A207E0,5B]" als Antwort, dann kommt
"Warning: Unexpected Warning: A timeout occurred before the Terminator
was reached."
Danke für eure Hilfe.
Hier noch meinen MATLAB code:
startMCU = '0108000304FF0000';
setHighDataRate = '010C00030410002101020000';
agcTtoggle = '0109000304F0000000';
ampmToggle = '0109000304F1FF0000';
setUpAllSensors = '0113000304180221022D2D2C2C000000000000';
sampleAllSensors = '01130003041802210001000F00010100400000';
readingBlock0x09 = '010B000304180220090000';
% reset serial port
instrreset
delete(instrfindall)
%Set Parameter
s = serial('COM4');
set(s, 'BaudRate', 115200, 'DataBits', 8, 'StopBits',1, 'Terminator',
...
'CR/LF', 'ByteOrder', 'bigEndian', 'Parity', 'none');
%Communication begin
fopen(s);
% Remove data from input buffer
flushinput(s);
% record file for debugging
s.RecordName = 'myRecord.txt';
record(s);
% start MCU
fprintf(s, startMCU);
% set High Data Rate
fprintf(s, setHighDataRate);
fprintf(s, agcTtoggle);
fprintf(s, ampmToggle);
% convert to 8 byte mode for sampling sensors
fprintf(s, convertTo8ByteMode);
% set up and sample
fprintf(s, setUpAllSensors);
fprintf(s, sampleAllSensors);
fprintf(s, readingBlock0x00);
% delay to sample
pause(0.5);
fprintf(s, readingBlock0x09);
condition = true;
count = 0;
while condition
received = upper(fscanf(s));
if strcmp(received, 'REQUEST MODE.');
count = count+1;
end
if count == 3
condition = false;
end
end % while condition
data = fscanf(s);
fclose(s);
delete(s);
%Communication end
% delete serial port for further communication
delete(instrfindall)
