Showing results for 
Search instead for 
Did you mean: 

circular buffer

Hi there I am currently a newbie to LabVIEW and I would like some help with implementing th ecircular buffer in the GUI.


Currently I am writing a command to the microcontroller (the letter D is the command), and in response to this command the microcontroller would begin to streamed to the computer.  The data recieved is basically a bunch of numbers.  The baud rate is 115200 bits/sec.  I am then trying to read the data as it comes in.  However because there is no specified time that the program will run for, I want to implement a circular buffer.  I have attached the GUI that i am making.  The problem that I currently have is that the circular buffer is not recieving any data.  I not sure what the problem is and I would like some helpful input. 

Also the I am not entirely sure how to initialize the size of the buffer, for example why it is in a form of a 2D array.

0 Kudos
Message 1 of 18

You did not include the circular buffer subVI so it is impossible to comment on it.


The way you have the event structure, you will get a single read each time you click the OK button. If the data is continuous, you are not reading it correctly. Why don't you simply place the write command outside the loop? You could also place the read inside a timeout event. Place the stop in it's own event as well.


There are no 2D arrays in your code.

0 Kudos
Message 2 of 18

I made some adjustments as per the last reply.  In this one the event structure is taken out.  I will also provide the circular buffer subVI.  The subVI that I am using is the circular buffer for the 1D string.

You can access the circular subVI at the following website:

0 Kudos
Message 3 of 18

You would have to write to the buffer in order to actually read something back from it. Do a write when the byte count is greater than 0, perhaps. What does the read data look like?


Seems overly complicate to me. Have you tried a queue?


Your doing a continuous write still does not make sense from what you originally said.

0 Kudos
Message 4 of 18

Hi there


so i far have rectified the block diagram slightly.  I took the write block outside of the while loop, however the problem still presist.  Also I am writing to circular buffer.  I am taking the information from the read buffer and sending that to the data in port of the circular buffer.  I have also attached a screenshot of the output that i am recieving.  The data in the read buffer is not very important, because it is just randomly generated inforamtion.  The main issue the fact that I am not recieving data in the data out array shown on the GUI. In addition I am not recieving data to the input buffer.  Again any help you might be able to provide would be greatly appreciated.


0 Kudos
Message 5 of 18

In the example you posted, you are most certainly not writing to the buffer. The operation is set to 'Read'.


I have no idea what you are trying to attach and I will not open it. The name says .docx which is not a good format for attachments but it is not even that - some zip file.


If your string indicator connected to the VISA Read is empty, then you have a problem with the serial communicaiton. You need to debug that first.

0 Kudos
Message 6 of 18

I think you are asking the wrong question. most probably you dont need stuff like circuilar buffer library what you need to know is how to parse the response.. can you tell me the format of response you are receiving from the device? (dont forget to check non printing characters like new line etc.).

and i will help you to solve the problem.

Tushar Jambhekar

Jambhekar Automation Solutions
LabVIEW Consultancy, LabVIEW Training
Rent a LabVIEW Developer, My Blog

0 Kudos
Message 7 of 18

Hi there sorry for the late reply.  Essentially what I want to know is how to implement a circular buffer for serial read in LabVIEW.  I would like to use a ciruclar buffer because it will allow me to read data continuously and decode the information and plot them accordingly.  The circular buffer would allow me to continue to read data without worrying about a data overflow. 

If you know how to implement this for serial read, it would be greatly appreciated.

0 Kudos
Message 8 of 18

As I already mentioned, you can use a queue. With the Obtain Queue and Lossy Enqueue Element functions, you setup a maximum length and when you enqueue new elements after the length is reached, the oldest elements get removed.


How long are you planning on having the VI run and how often will you do a read? It's possible you won't need a buffer at all. You can certainly read continuously and plot without needing any buffer besides what is already provided by a waveform chart.

0 Kudos
Message 9 of 18

Well I want the VI to run until the user presses a button to stop, thus there is no set time frame.  I also want to aqcuire data and display it real time.  Also I should mention that the baud rate is 115200 and I have to decode the data prior to plotting it to the appropriate waveform.  I need to decode the data that is being streamed serially to eight different waveforms, because there are eight different channels.


0 Kudos
Message 10 of 18