LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving values from VISA Serial Read to an array

I want to save the values for the voltages that I read from a microcontroller to an array in labview. I have attached the VI. My VI basically keeps updating the values at index 0. It does not store the values in different indices. For ex: I want to store values in this order:

 

a[0] = 3.4

a[1] = 3.2

a[2] = 2.8

a[99] = 4.3

 

Those are just random values I selected but hopefully I was clear enough.

0 Kudos
Message 1 of 24
(6,403 Views)

No surprice since you are not using any code that allows you to store or retain your values.

You can, for instance, use a shift register and the Build Array vi.

 

But do check out the free material, especially this part:

https://www.ni.com/getting-started/labview-basics/shift-registers

I suggest you might benefit from learning a bit more of the Labview basics.

0 Kudos
Message 2 of 24
(6,366 Views)

Even when I put a string indicator on the Read pallete the values keep on updating instead of showing all the values at once

0 Kudos
Message 3 of 24
(6,356 Views)

As perhult stated early you need to add the value to an existing array every loop and then display the array.

 

You should also look into learning labview, but here i added the functionality for you.

 

Update Array.png



-Matt
Message 4 of 24
(6,352 Views)

Thanks! I am learning about shift registers right now

0 Kudos
Message 5 of 24
(6,350 Views)

Get rid of the VISA Open that is in the loop.  You don't need it.  It is effectively happening when you configure the serial port.  And doing it repeatedly in the loop will either do nothing, or just confuse the serial port.

0 Kudos
Message 6 of 24
(6,334 Views)

Also the values stop after around the 50th one. I wanted to store 100 values but it just stops after 50-53 values?

0 Kudos
Message 7 of 24
(6,327 Views)

@engineerbeginner wrote:

Also the values stop after around the 50th one. I wanted to store 100 values but it just stops after 50-53 values?


Obviously you have made some changes to your code.  We need information!

What does you vi look like now? (give us a snippet!) What is the device on the other end? What is a typical recieved string?


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 24
(6,325 Views)

i am sending data using printf functions from ccs complier. I did edit a few things to my VI. I added in another read since I have two printf statements. I also initialized the array to 102 because I want the very first index to have that value. Everything else seems to work just fine except for the fact that i can't seem to store 100 values in the array.

0 Kudos
Message 9 of 24
(6,318 Views)

There is nothing in that code that would prevent the arry from growing until the CPU runs out of memory.  

 

When you say "it just stops after 50-53 values"  what happens exactly.

 

I've made a modified version that does some better error handling and may help debug that issue- try that


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 24
(6,310 Views)