Matlab - Problema comunicación serie

 
Vista:

Problema comunicación serie

Publicado por Set (4 intervenciones) el 08/09/2015 23:18:19
Hola
Estoy controlando unos motores con una placa Arduino, para enviarles la información lo hago mediante comunicación serie.
El problema es que, mientra que al usar un monitor de puerto serie no tengo ningún problema al enviar la información y que los motores respondan bien, al intentar hacer esto con matlab para que todo funcione necesito cerrar y abrir el puerto en cada envío.
He probado a limpiar el buffer usando el comando flushouput() y el comando flusinput() sin éxito.
A que puede deberse este problema y como puedo solucionarlo?

Gracias de antemano
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Dave
Val: 497
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Problema comunicación serie

Publicado por Dave (1094 intervenciones) el 09/09/2015 03:03:05
Hola Set;

En el siguiente link http://www.mathworks.com/matlabcentral/answers/102268-how-can-i-empty-the-serial-port-buffer-in-matlab-without-using-the-instrument-control-toolbox, encontre una respuesta que te podría interesar.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
One way to clear the contents of the serial port buffer is to do a simple
 
fscanf(serialobj)
 
to read everything in the buffer until the first terminator, which is 'LF' by default. If there is a terminator in the buffer before the last character of the buffer then the previous code will not clear the buffer completely.
 
Alternatively, you can read the available bytes in the buffer of the serialobj
 
and use the following code:
 
fread(serialobj, serialobj.BytesAvailable)
 
to read all the contents of the buffer. It should be noted that FREAD will return data in the binary format (as opposed to ASCII).
 
Disconnecting and then reconnecting to the serial object via FCLOSE and FOPEN will also flush the serial buffer. However this approach is computationally much less efficient than the solutions above.


​Espero que sea de alguna ayuda.

Saludos
Dave Correa
[email protected]
[email protected]
Servicios de Programación Matlab
http://fismatlab.org​​
http://fismatlab.blogspot.com

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Problema comunicación serie

Publicado por Set (4 intervenciones) el 09/09/2015 18:02:31
Ya he probado esos comandos también sin éxito es mas el primero me marca un warning diciéndome que estoy mirando algo que esta vacio y el segundo directamente no funciona
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar