Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Problema con displayado de datos en tiempo real / Problems with real time data display

 

Hola a todos.

Quisiera consultarles sobre un inconveniente que estoy teniendo con un proyecto.

El proyecto consiste básicamente en muestrear una señal biomedica -sonido cardíaco- (por medio de un microcontrolador con conversor A/D de 12 bits) a una velocidad de 8 KHZ, transmitir los datos através de la UART del PIC a un módulo de transmisión bluetooth configurado para transmitir a 461 K, recibir los datos en una PC (por el bluetooth nativo de la máquina)  y visualizar los datos en tiempo real (o lo mas cercano a ello) en una aplicación (estoy usando un waveform chart).

He logrado lo que comenté anteriormente, no obstante aún no logro configurar la aplicación para que los datos puedan verse en tiempo real:

* estoy usando una arquitectura productor-consumidor

* como cada muestra es de 12 bits, los dato se transmiten en 2 bytes (1 byte con los 4 bits mas significativos y 1 byte con los 8 bits menos significativos)

* el waveform chart lo configuré para que se muestren los últimos 15 segundos.

Entiendo que el multiplicador que se coloca en el waveform chart guarda relación con el período en que se reciben los datos, por lo que probé con 125 us (por ser el muestreo a 8 KHZ) pero los datos se grafican con mucho retardo (al rededor de 10 seg). Luego probé con 1.875 ms (considerando la ventana completa de 15 segundos que muestra el chart) pero la gráfica avanza de manera acelerada.

 

Les agradecería mucho su ayuda con este tema ya que hace tiempo estoy tratando de solucionarlo sin éxito. Les adjunto la aplicación por si les resulta de utilidad.

 

Les dejo un saludo cordial.

 

*****************************************************************************************************************************

Hello everyone.

I would consult on an issue I'm having with a project.

The project is basically a biomedical signal sample HR--sound (by means of a microcontroller with A / D converter of 12 bits) at a rate of 8 kHz, data transmitted using the PIC UART to a bluetooth transmission module configured to transmit 461 K, receive data on a PC (by the native bluetooth Machine) and display data in real time (or as close to it) in an application (I'm using a waveform chart).

I have achieved what was previously mentioned, however I manage to not set up the application so that data can be viewed in real time:

* I'm using a producer-consumer architecture

* As each sample is 12 bits, the data is transmitted in 2 bytes (1 byte with the 4 most significant bits and 1 byte with the 8 least significant bits)

* I configured the waveform chart for the last 15 seconds are displayed.

I understand that the multiplier is placed in the waveform chart related to the period when the data is received, so I tried with 125 us (being the 8 kHz sampling) but the data are plotted with much delay (around 10 sec). Then I tried with 1,875 ms (considering the full 15-second window showing the chart) but the plot progresses rapidly.

I would greatly appreciate your help with this issue because while I'm trying to fix it without success. I attached the application if they find it useful.


I leave sincerely.

0 Kudos
Message 1 of 4
(4,245 Views)

Hello Adrian,

 

This is an English Board so I will try to keep it that way. If you prefer receiving answers in Spanish I would suggest you to post here.

 

I gave a quick look to the code and there are a couple things that are not clear to me.

 

1. Does this delay shows up from the beginning in a constant manner or is it progressive? If it is progressive you can try to monitor the number of elements in the queue reading the # elements in queue output from the Get Queue Status function in the consumer loop to find out if the writing operation is progressively delaying the display (would make sense to me).

 

2. Is it the Waveform Chart, Waveform Graph or both you are talking about? You mentioned "real-time data" which seems to be the first one and the 125 us multiplier, which seems to refer to the graph.

If you are talking about the chart, maybe you car try doing the display in the producer loop (this will also help with the previous point). If the problem is the chart:

 

2.a. Do yo execute the "Read Data" state at the same time as the "Save Data" state from the consumer loop is being executed?

Camilo V.
National Instruments
0 Kudos
Message 2 of 4
(4,126 Views)

Dear Camilo,

First of all, thanks for your reply. Answering questions:

1- The delay I see is in a constant manner.

2-I am talking about the waveform chart: the 125 us (or 0.000125) is the parameter I enter in the "multiplier" box (scaling factors) of the "Scales" flap of the chart properties. I am doing the display in the consumer loop because time ago I had a simillar problem and another engineer of NI suggested me the use of the producer-consumer structure, using the visualization (chart) in the consumer loop to avoid delays when the information (samples) were stored in the queue.

2.a- The "save data " option could be selected while the infomation is being displayed (read data), is an operation option.

 

Thanks again for your answer and i await for your comments.

 

Best regards.

0 Kudos
Message 3 of 4
(4,096 Views)

Adrian,

 

Thanks for the information. I have a better idea of the issue now.

 

The multiplier only affects the values of the axis, but does not have any effect on the Waveform Chart behavior so changing it will not fix any delay on the data.

 

I did a quick test by replacing your signal by a random number and having that displayed, along with a Get Queue Status function to monitor the queue. I am not seeing a delay at the start but I see that the queue size increases continuously (can you please verify if this is also your case?), meaning the real-time data is not really that real-time.

 

I actually modified your VI a little bit to test it and it is not the most elegant thing you'll see, but maybe you can implement it to see if what you see is consistent with what I got. You can remove the Disable Diagram Structures and test the VI with the actual signal. I also left some comments on the code about what I added and what I am using it for.

 

For what you tell me, doing the display in the consumer loop makes sense, but take note that the producer consumer does not grant the data will be displayed real-time, as if the loops execute at different paces (which I believe is happening in your side as well), the consumer loop will always show the data "late". This is highly likely since actually, the consumer loop has a delay of 1 ms while the consumer loop has 4 ms, so unless the read operation takes 3 ms longer than anything being done in the consumer loop, there will always be some jitter.

Camilo V.
National Instruments
0 Kudos
Message 4 of 4
(4,048 Views)