Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Can I do data buffering and data plotting at the same time?

Status
Not open for further replies.

wannaknow

Junior Member level 2
Joined
Apr 9, 2015
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
252
I am using Quartus 12.1 sp1, vhdl and Altera Nios II programmed in C code for DE0-Nano Development. Basically, what I have is, data is sent from fpga vhdl block to NIos II system, Nios II system sends the data to serial port, Matlab access the serial port to real time plot the graph.

I am buffering data received from fpga vhdl say 1000 sample points and save it in sdram... after saving these 1000 sample points, the C code will send data to uart so that Matlab can access these serial port data and plot the graph real time.

Once the sdram has all the first 1000 samples points, processor sends the data to serial port for Matlab to plot the graph, then processor proceeds to save the second set of 1000 samples points, then processor sends the data to serial port for Matlab in order to plot the graph, keep repeating for following sets....etc

In my system, the rate the graph is plotted is much slower than the rate the buffering can be done.

My question is, from the perspective of C programming, when the processor is sending data for plotting, can the processor still do the buffering? If not, what should I do so that when the processor is doing the buffering, I still can get the graph plotted at the same time for the previous set of data?


Appreciate any input, forgive newbie question...thank you
 

I am using Quartus 12.1 sp1, vhdl and Altera Nios II programmed in C code for DE0-Nano Development. Basically, what I have is, data is sent from fpga vhdl block to NIos II system, Nios II system sends the data to serial port, Matlab access the serial port to real time plot the graph.

I am buffering data received from fpga vhdl say 1000 sample points and save it in sdram... after saving these 1000 sample points, the C code will send data to uart so that Matlab can access these serial port data and plot the graph real time.

Once the sdram has all the first 1000 samples points, processor sends the data to serial port for Matlab to plot the graph, then processor proceeds to save the second set of 1000 samples points, then processor sends the data to serial port for Matlab in order to plot the graph, keep repeating for following sets....etc

In my system, the rate the graph is plotted is much slower than the rate the buffering can be done.

My question is, from the perspective of C programming, when the processor is sending data for plotting, can the processor still do the buffering? If not, what should I do so that when the processor is doing the buffering, I still can get the graph plotted at the same time for the previous set of data?


Appreciate any input, forgive newbie question...thank you



you can use Multithreading but you will need an OS.

some remarks :
a. in the hardware world Multithreading does not run in paralel.
b. the best thing for you is to do the buffering with your vhdl code, cpu will just read the data.
c. basically like in many controller applications :
if you have fpga then you can replace the nios with a good old state machine
to manage the task.
 

you can use Multithreading but you will need an OS.

some remarks :
a. in the hardware world Multithreading does not run in paralel.
b. the best thing for you is to do the buffering with your vhdl code, cpu will just read the data.
c. basically like in many controller applications :
if you have fpga then you can replace the nios with a good old state machine
to manage the task.


thanks for your reply...

"b. the best thing for you is to do the buffering with your vhdl code, cpu will just read the data.", thank you for the suggestion, I would like to go for this, as I am more familiar in programming nios system in C code, do you mind to tell abit on how to do the buffering in vhdl?


it seems like the processor only did either one task at a time, when it is doing buffering, it does not send data to uart... but what i want to do is, while processor is doing buffering for second set of data, the processor can also send the first set of data to serial port for Matlab plotting, is it possible?
 
Last edited:

I guess that you are using Windows OS, which is not a RTOS.
Anyway, you can put the processing of your job a the top priority level of the system, using hardware interrupts.

This could be achieved if the DE0 board for instance send UART interrupts clocked at the sample rate equals to the desired plotting update, but I'm not sure if you can deal with serial reception events in MATLAB in the same way as some tools that uses system API compiled in C++, for instance.
 

I asume the Altera Nios II can cope with the sampling and transmission of the data (using DMA?) and the problem is can the PC plot data as it is received in real time.
You mention that you are sampleing a 1000 data points, transmitting them to the PC via a UART for plotting, at the same time sampling the next 1000 data samples - you don't appear to mention the sampling rate.
If data is arriving too fast to display all the samples in real time (do you intend to to scroll the plot?) you can skip some of the samples (at the risk of loosing information due to to aliasing)

the plot below shows a the results of a dsPIC acquiring blocks of 1000samples/second, doing an FFT and sending the results (frequency and phase) to a PC for plotting.
the number of data points to be skipped can be set at run time - the code is written in Visual C++
broken link removed
 
Last edited by a moderator:

Thank you for your reply. The Matlab serial port receive rate is 11Hz. please refer to the image below, the Nios II sends data to uart, Matlab access the serial port and plot the below sinusoidal waveform. My problem is, a complete cycle of sinewave obtained from fpga is with a frequency of 50Hz, so it should be having a period of 0.02 seconds instead of 0.16 minutes as I got now, I don't know what is the problem?

**broken link removed**

**broken link removed**
 

is 11Hz correct? very unusual baud rate
if your signal is 50Hz using the Shannon sampling theory you need to sample and plot at least 100 times/sec
https://mathworld.wolfram.com/SamplingTheorem.html

assuming your data samples are 8 bits your baud rate needs to be at least 1.2Kbaud (assume each data byte reqires 10bits to transmit it) and if the data is 16bit the baud rate should be at least 2.4Kbaud

if you are sampling 100 samples/second a fast pc should be capable of plotting it (don't know about Matlab though - our Matlab applications sampled data over a fixed time period and then we could display and analise it)

I tended to plot using C++ for most real time plotting applications (Visual C++ or GNU gcc with wxWidgets)

I was unable to open the attachment
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top