LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Boolean Array Into For Loop Problem

For context, I'm new to Labview and programming as a whole so please bear with me. I'm attempting to control 128 relays using Labview and I settled on using a 128-bit boolean array then converted to hex in a For Loop to do so. I've attached a screenshot of the relevant part of the code. The problem I'm having is there seems to be some sort of overflow going on, specifically with every 8th bit. For example, when the 8th bit is selected high it also makes the 9th bit (the 1st bit in the next byte) high as well. I'm assuming I'm using something incorrectly. I've also noticed that the For Loop is converting the 1-D array into a 2-D array upon entry into the loop. I'm assuming this is apart of its design but I suspect it is apart of the problem?

 

Thanks for the help,

Matt 

0 Kudos
Message 1 of 8
(2,268 Views)

Please upload your VI instead of a picture of your block diagram.

 

Just from looking I assume the decrement function inside the for loop to be your culprit.

 

Regards, Jens

Kudos are welcome...
0 Kudos
Message 2 of 8
(2,264 Views)

I just don't understand the defective, but-very-common, psychology here.

Attaching the .vi is less work than making an image of the block diagram, then posting the picture; yet a lot of people do that.

 

One time I needed my cow-orkers to run a little program to collect some info about their computers.  The program displayed a data string, and also copied it to the clipboard (and displayed a message saying that it was in the clipboard).  All they needed to do was create a new e-mail message to me and press Ctrl-V.  But a couple of them took pictures of the screen with their phones, transferred the picture to their computer, then e-mailed me the picture (so of course I had to manually type the info from a picture).

 

People seem to have an urge to do extra work that makes things more difficult for anyone trying to help them.  It's troubling that such a high percentage of people are afflicted with this psych defect.

"If you weren't supposed to push it, it wouldn't be a button."
Message 3 of 8
(2,253 Views)

Here's a VI of the portion of code giving me grief.

0 Kudos
Message 4 of 8
(2,249 Views)

BoolArrayToHexString.jpg

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 5 of 8
(2,244 Views)

Just like I already said, the decrement ( -1 ) operation inside the for loop is incorrect. You are taking sub-arrays, starting at index -1, 7, 15, ... but you want to take sub-arrays starting at index 0, 8, 16, ...

 

Here's another possible solution, that first reshapes your 1D-array to a 2D-array.

 

Regards, Jens

Kudos are welcome...
Message 6 of 8
(2,222 Views)

Further proof of my inexperience. I appreciate the solution and the help. 

Thanks,

Matt

0 Kudos
Message 7 of 8
(2,215 Views)

Also not that you don't really need local variables and boolean arrays (8x more memory than a U8 array!)

 

Here are some ideas...

 

altenbach_0-1634933816352.png

 

0 Kudos
Message 8 of 8
(2,158 Views)