Jump to content

For loop won't fill array


Recommended Posts

Hi

I'm a first timer and my experience with LabVIEW is limited (although growing fast everyday)

I built this little VI where I am reading HEX values (bytes) from one file. I format the data and pass it to a FOR loop where Hexadecimal String to Number puts every byte into a unsigned integer array using an Auto-Indexed Tunnel. I then repeat the process for a second file. This completes my VI

When I run the VI for the 1st time (read from 2 files), it works perfectly fine. But when I run it for a 2nd time (read for the 3rd and 4th time), the integer array is filled with 0's (wired an indicator). Only way to get around this is to fully close the VI and then re-open it.

Should i re-initialize the tunnel every time? If so, how? Could it be that my array is 'big' i.e. 7200 items? Hopefully I'm clear enough

Thanks for your help

Fred

Link to comment
Could it be that my array is 'big' i.e. 7200 items?

Fred,

It couldn't be the array size, 7200 items is not at all big! I've filled arrays to the point that I ran into RAM limitations, so lets say 300MB of free space, 8 bytes per array element, comes to about 37,000,000 array elements. Sure, the computer gets a bit testy in these cases, refuses to respond, etc, etc..., but never at a mere 7200!

As Mike and Crelf said, post what you have and someone here ought to see the problem.

-Pete Liiva

Link to comment

Thanks for the help. My VI sends register and memory content to an IC using SPI.

Here is a screenshot of the 2nd sequence of my VI. The sequence right after is the exact same but I load a different file. The 1st, 4th and 5th sequences send hardcoded data to the SPI programmer no arrays involved. That's it. Run the whole thing once, you're fine. Try to do it again, array is filled with zeroes.

the file being loaded in the beginning is of the following structure

0xXX, 0xXX, 0xXX, .... where XX is a HEX representation of a byte.

Thanks again

labview.jpg

Link to comment
0xXX, 0xXX, 0xXX, .... where XX is a HEX representation of a byte.

Just to confirm - your file structure is:

0xXX<space><comma>0xXX<space><comma>0xXX<space><comma> ...

where XX are your HEX characters? (it helps to attached an actual example file to clear up these misunderstandings).

Link to comment

The problem is occurring because you are not initializing the shift register that is wired to the offset input of the Hexadecimal String to Number function in your For Loop. Whatever index value was the last value written to that shift register will be the first value given the next time the VI runs. So this will probably be a large offset value that is at the end of the file, thus resulting in no hexadecimal value found, thus resulting in a default value (zero) being output from the function.

I think if you wire a zero constant to initialize the shift register the problem will be solved.

-D

Link to comment
The problem is occurring because you are not initializing the shift register that is wired to the offset input of the Hexadecimal String to Number function in your For Loop. Whatever index value was the last value written to that shift register will be the first value given the next time the VI runs. So this will probably be a large offset value that is at the end of the file, thus resulting in no hexadecimal value found, thus resulting in a default value (zero) being output from the function.

I think if you wire a zero constant to initialize the shift register the problem will be solved.

-D

Thank you so much Darren!

I knew it probably was something very simple. It now works exactly how I want it to.

Thanks again

Fred

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.