LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I avoid this CASE assignment problem to use VISA Serial Read?

Hi everyone,

 

I need to read data from serial interface and write it to a text file. I’m using the VISA SERIAL READ inside a FOR loop, but I have to acquire data only in certain iterations (multiples of 5).

 

My problem is the case structure. I’m using a case structure to test the iteration number to execute the VISA READ VI and generate an array. How could I avoid the missing assignment to tunnel error? Because I don’t need to write any data at all during false case...

 

True case

 

 

False case: missing assignment to tunnel error

 

 

Thanks in advance,

 

Klein

 

 
 

Message Edited by Klein on 04-26-2007 01:58 PM

Download All
0 Kudos
Message 1 of 8
(3,150 Views)
I think you can right click on that node and select "use default if unwired"
0 Kudos
Message 2 of 8
(3,143 Views)

TigerB,

I tried this option, but it doesn't work. Because it create an empty line in my text file on every false case...

0 Kudos
Message 3 of 8
(3,133 Views)

The use default will not work. It will append empty rows in the false case.

You can use a shift register and pass the value through the false case.

Message Edited by Dennis Knutson on 04-26-2007 01:26 PM

Message 4 of 8
(3,131 Views)
There's three solutions I can think of.

Restructure the code so that you collect data on every iteration (with the posted example change 20 to 4 and remove all the case statement stuff, I'm guessing that might be harder in your application)

Remove the excess data from the output before writing it (openg has some functions that make that easy, but it isn't hard to do by hand. Some fancy work with reshape and index and build array should also work in this case)

Replace the autoindex with a shift register (fastest if you can preallocate the array, and just use replace array subset)

I can explain these in more detail if you want.

Matt W
0 Kudos
Message 5 of 8
(3,124 Views)

Dennis,

   Your solution works great. Again! Thanks a lot.

######################################

Matt,

Your first advice doesn't works with my code, because there's more code that I need to run inside the FOR loop and read serial data only on multiples iterations...

Second advice: "Some fancy work with reshape and index and build array should also work in this case". What I understood is to use case structure and insert empty lines inside the array. After all, I need to manipulate the array to remove these lines. Did I get it?

Third advice is: "Replace the autoindex with a shift register (fastest if you can preallocate the array, and just use replace array subset)". Is this solution different from Dennis's solution? I didn't understand this recommendation: just use replace array subset.

Thanks a lot, Matt.

Klein.

 

0 Kudos
Message 6 of 8
(3,111 Views)
1. I figured as much, It's probably doable (put the none serial reading section into another for loop in side the first, would likely work), but it could easily start complicating things. Depends on what your doing.

2. That's it.

3. It's almost the same. My suggestion is an optimized version, since build array can get extremely slow when repeatedly called on a large array (not a problem if your array is small). But my suggestion requires knowing the number samples you'll be taking before hand (if you don't you could allocate a maximum size then use split array or handle the data in chunks).

I attached a VI showing some different variations of 2 and 3. Set the Number of Iterations to something like 20000, if you want to compare the speeds.
Message 7 of 8
(3,104 Views)

Ok, Matt.

I will take a look at your "global solution program" to verify the best solution Smiley Happy.

It really seems that Replace program is the fastest and the Build Array is the slowest.. I'm going to test in my code.

I'd like to thank you for your great help, Matt!

Klein

0 Kudos
Message 8 of 8
(3,097 Views)