LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change buffered string to number

Solved!
Go to solution

Hi,

 

The recomendation to use Spreadsheet String To Array was perfect. The block diagram is very simple and it does exactly what I expect to do. The chart is updated when data re send, it is working fine. It looks now more professional.

 

During my testing a have realized that if I send the data (bytes) from PIC in to COM4 for few minutes and labview VI is not in RUN mode the data are send in to some “BUFFER”. When I stop PIC to send the data in to COM4 and then I Run the labview VI, all “BUFFERED” data has appears on the indicator Temp1 and Temp2 (flips) and Concatenated string window shows all buffered data. There is exactly 4357 (+-few bytes) bytes in the buffer (if /n I count as one byte) or 4973 (+-few bytes) bytes (if /n is counted as 2 bytes).

 

If after few minutes when the “BUFFER” gets full I do not stop PIC to send data in to COM4 and Run the VI, then for about 45 second the data on the indicator Temp1 and Temp2 are not actual values, but buffered values. They flip very fast and when the buffer gets empty, then the Temp1 and Temp2 start to show current values.

 

What is this BUFFER about? Is there any way to stop this buffering (no buffering when labview VI is not running)? O this is an Windows7 buffer?

0 Kudos
Message 11 of 17
(1,222 Views)
Solution
Accepted by topic author romiadam

VISA keeps a buffer of bytes that have come in.  It should only be active if you have the resource in use.  That tells me you are not closing the resource.  Are you using the abort button in the tool bar to stop your VI.  If so, stop doing that.  Use a stop condition/button to stop the loop and close the VISA session.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 12 of 17
(1,204 Views)

Hi romiadam,

 

If after few minutes when the “BUFFER” gets full I do not stop PIC to send data in to COM4 and Run the VI, then for about 45 second the data on the indicator Temp1 and Temp2 are not actual values, but buffered values. They flip very fast and when the buffer gets empty, then the Temp1 and Temp2 start to show current values.

Simple advice (without being able to see your VI's block diagram): don't use an additional wait function next to your VISARead function!

(Background: you should read the VISARead buffer atleast at the same speed as your device is filling that buffer with new messages!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 13 of 17
(1,179 Views)

Yes crossrulz, that was it. Because I am using two while loops, It was much easier to stop it by abort button in toolbar. I wired the two while loops condition to one stop button and now it is sorted two.

 

Is this a good way to scan Read buffer at i.e. 100 ms rate and display it at 1-5 sec rate on the chart? I can not put second while loop in to main while loop. If I wired it via tunnel, it does not worked.(I might need to learn how tunnel works). By using property nodes I have got it running as I wish.

 

Note:Initially I used crossrulz´s sporadic waveform chart. It worked fine until I have decided to send some state string for RUN and LED diode state. Then I could not used direct wiring from ReadBuffer. I tried to cut off those two state strings, but was not successful to do it.  I am not sure which Waveform chart I will use later. So far I am using a regular waveform chart. If I will need Sporadic  waveform chart I will b back with that question.

 

Now the VISA Read woks as I wish it work. Thank you all very much for your help. Without your help, I would not get so far where I am. Thanks. I am going to work now on VISA Write.

 

Do you know some good tutorials (for dummies 🙂 ) where are well explained with good examples how the specific function can be used, what different way. Or  it is not exist and I have to learn "on th fly" from this forum, youtube videos... The Labview help is not detailed enough for me (simple functions as add, equal, .... those are clear, but more complicated functions are very briefly explained in Labview). I think it is more just refreshing the memory what you already knew as to learn from it.

For example I would never put together that sporadic waveform chart. I even does not understand how it works. I understand how it works for one cycle as it is in labview help. But Labview help did not helped me too. I always miss just one (or few) key information. That not wired N for For loop it is a nice trick. As I know it tells to for loop how many time it has to run. I have no clue how For loop works without not wired N. 🙂

 

 

Download All
0 Kudos
Message 14 of 17
(1,151 Views)

Hi romiadam,

 

those are clear, but more complicated functions are very briefly explained in Labview

For "more complicated functions" the LabVIEW help most often links to an example VI from the example finder, which comes with LabVIEW!

 

On your image:

You can resize IndexArray to provide more than one output.

You can additionally omit the index constants when you start from index=0!

"Chart timing" should use the U32 datatype, as well as "Main loop"…

You could use a notifier to transfer data between the loops. (Advantage: you can easily place the 2nd loop in a subVI.)

You don't need to wire the default values at SerialPortConfig…

Use AutoCleanup!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 15 of 17
(1,143 Views)

@romiadam wrote:

Now the VISA Read woks as I wish it work. Thank you all very much for your help. Without your help, I would not get so far where I am. Thanks.


You say "thanks", but you don't really show it.  Per my signature "There are only two ways to tell somebody thanks: Kudos and Marked Solutions."  In other words, you should give Kudos to posts you found helpful.

 


@romiadam wrote:

Is this a good way to scan Read buffer at i.e. 100 ms rate and display it at 1-5 sec rate on the chart? I can not put second while loop in to main while loop. If I wired it via tunnel, it does not worked.(I might need to learn how tunnel works). By using property nodes I have got it running as I wish.


1. Do not put a wait in your acquisition loop.  The loop should run as fast as the data comes in.

2. I am not a fan of using Local Variables.  Too much coupling and things break easily when they get moved around.  What I would recommend is go back to my sporadic waveform chart setup, but store the last values in a shift register.  If you get a timeout situation, then use the "old" data.  After all, why would you not want to show all of the data as it comes in?

 


@romiadam wrote:

Note:Initially I used crossrulz´s sporadic waveform chart. It worked fine until I have decided to send some state string for RUN and LED diode state. Then I could not used direct wiring from ReadBuffer. I tried to cut off those two state strings, but was not successful to do it.


What is the format of the RUN and LED state?  Based on your snippet, they are just 0 and 1, so I don't see what your issue is.  Do you not want them in the chart?  Then just use Delete From Array to pull those two values off from the array (wire a 2 to the length and the index unwired and the last 2 elements will be removed from the array).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 16 of 17
(1,138 Views)

Kudos? No problem. You deserve it.

0 Kudos
Message 17 of 17
(1,129 Views)