Jump to content
Sign in to follow this  
Eudaemonic

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

Share this post


Link to post
Share on other sites
I wish you could upload an image of your diagram.

...or even attach a VI that you've already created so we could suggest modifications...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

it's actually

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

Is there a way to upload my code along with sample files (25kb)?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
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.

Sign in to follow this  

×
×
  • Create New...

Important Information

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