Serial port stops receiving data after an hour or so
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I'm running MATLAB 2015a and have assembled a program that sends and receives data from a PLC. Here's the basic set up:
% Define the serial port
kv_serial = serial(serial_port, 'Terminator', 'CR/LF', 'Parity', 'Even');
kv_serial.BytesAvailableFcnMode = 'terminator';
kv_serial.BytesAvailableFcn = {@grinder_callback};
% Define logging properties
log_path = ['./Logs/grind_' datestr(now, 'mmddyy_HHMM') '.txt'];
kv_serial.RecordMode = 'index';
kv_serial.RecordDetail = 'verbose';
kv_serial.RecordName = log_path;
% Open the serial port
fopen(kv_serial);
% Record the serial
record(kv_serial);
% Send a serial break
serialbreak(kv_serial, 1000);
Recently, MATLAB has stopped reading from the serial port about an hour into execution. Strangely, I can send commands to the device via MATLAB and have no problem doing so - it's just that the ValuesReceived property stops incrementing and MATLAB stops recognizing any communication from the PLC.
What's really annoying is that restarting MATLAB is the only way to reestablish a fully working connection.
I'm at my wits' end and would appreciate any ideas or help!
2 comentarios
Walter Roberson
el 14 de Dic. de 2015
If you can spare the time, it would be interesting to find out whether it happens if you are not recording.
Respuestas (0)
Ver también
Categorías
Más información sobre Simulink PLC Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!