LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

replace array subset help

Hi folks.

 

I am using  a "replace array subset" to modify certain values in a binary word or number.

 

I have coded like in the attached pic.

 

My doubt is just for better coding and not functionality Smiley Tongue

 

Is there a "cleaner" or more effective way to do this, I mean, in terms of array is there another way than just replacing one-by-one.

 

Hope it's clear enough. 

 

Cheers

0 Kudos
Message 1 of 10
(3,959 Views)

 

In general that is correct but code style wise if you use the first index as "14" then the next down is automatically "15".

 

But your "reverse 1-d Array" make me think that you are reversing for display purposes. If that is the case you may want to use a U16 instead of the array of booleans and format the display for binary. To set the bit you chan then use the bit-wise operations available using an "Or" gate" with a mask of "c0".

 

I hope some of that is hlepful.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 10
(3,948 Views)

Ben, just trying to understand your bitwise OR idea but can't get it to work. I created the following from your description, but my code OR's with bits 7 and 8, not 14 and 15. What am I missing here?

 

Message Edited by Thoric on 04-24-2009 03:24 PM
Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 3 of 10
(3,933 Views)

Try OR with C000 for a 16 bit representation.

 

Lynn 

Message 4 of 10
(3,929 Views)

Ah yes, brill Smiley Happy

 

 

Message Edited by Thoric on 04-24-2009 03:32 PM
Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 5 of 10
(3,925 Views)

Sorry Thoric!

 

As Lynn posted I missed a couple of zeroes. THat is what happens when you do binary to hex conversion in a head that has not been properly initialized with coffee. Smiley Sad

 

Ben 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 10
(3,923 Views)

In both my snapshots, the block diagram constant (c0 and c000 in the two cases) are both 16bit constants. I take it therefore that the first one is actually 00c0 with hidden leading zeros? Hmmm... Smiley Indifferent


Any way to set the LabVIEW default representation of Hex displayed values to have no hidden leading zeros? Similarly, the binary displays to show all bits? (I had to set the minimum width of the first control to 16 padded with zeros to prevent it from showing just a single '0').

Message Edited by Thoric on 04-24-2009 03:37 PM
Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 7 of 10
(3,916 Views)

Thoric,

 

I do not think you can change the default views but you can change the appearance with the properties dialog for both constants and front panel controls and indicators.  I am sure that you can set leading zeros on binary displays and I think you can on hex.  I do not have LV open now to check.

 

Lynn

Message 8 of 10
(3,906 Views)

johnsold wrote:

Thoric,

 

I do not think you can change the default views but you can change the appearance with the properties dialog for both constants and front panel controls and indicators.  I am sure that you can set leading zeros on binary displays and I think you can on hex.  I do not have LV open now to check.

 

Lynn


Yes, that's precisely how I changed my front panel controls to show all 16 bits in binary display mode. It would just be nice for this "pad with leading zeros" to be the default when you convert a display from Floating Point to either Binary or Hex. That's how my calculator shows values afterall when in Binary or Hex mode.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 9 of 10
(3,903 Views)

You could submit that as a product suggestion.  NI does listen to suggestions, particularly when a good case can be made that the change will be a significant help for customers and if it will not break existing code.

 

Lynn 

Message 10 of 10
(3,899 Views)