annuler
Affichage des résultats de 
Rechercher plutôt 
Vouliez-vous dire : 

Boolean logic : Enabling & Disabling Bit

Résolu !
Accéder à la solution

@billko wrote:

@crossrulz wrote:

@billko wrote:

@crossrulz wrote:

Binary radix helps in that situation.


I've actually done that where I could, but sometimes the numbers are outputs and not contants.


It works for controls and indicators as well.

 

Personally, I use the Hex radix a lot.  It's just a little easier to read than a big string of 0s and 1s.


Sorry I've forced you to wander off-topic about this.  I understand about controls and indicators, I meant outputs from calculations.  I appreciate everyone's help and I'm sorry - I didn't mean to hijack the thread.  😞


Not too bad of a hijack.   

 

Custom probes come to mind.  Search help and the forums-- then PM with a link to your new thread.


"Should be" isn't "Is" -Jay
Message 21 sur 48
1 804 Visites

@JÞB wrote:

@billko wrote:

@crossrulz wrote:

@billko wrote:

@crossrulz wrote:

Binary radix helps in that situation.


I've actually done that where I could, but sometimes the numbers are outputs and not contants.


It works for controls and indicators as well.

 

Personally, I use the Hex radix a lot.  It's just a little easier to read than a big string of 0s and 1s.


Sorry I've forced you to wander off-topic about this.  I understand about controls and indicators, I meant outputs from calculations.  I appreciate everyone's help and I'm sorry - I didn't mean to hijack the thread.  😞


Not too bad of a hijack.   

 

Custom probes come to mind.  Search help and the forums-- then PM with a link to your new thread.


The Conditional Probes allow you to select the radix.  I'm pretty sure those come with LabVIEW now.  They are in the Custom Probe menu when you right-click on a wire.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 22 sur 48
1 786 Visites

Built this from what I learned here.

Message 23 sur 48
1 115 Visites

@dangeross wrote:

Built this from what I learned here.


It is not useful to answer a almost 10 year old thread with code saved in LabVIEW 2024. Why not do a "save for previous" so more can potentially benefit?

0 Compliments
Message 24 sur 48
1 106 Visites

I wasn't aware of the "save for previous" option. This appeared to be the best thread I could find in the forum search and I only posted because my work was based on the work of others in the thread. I thought this could be useful to anyone else trying to achieve the same thing and like me is very new to LabView. I only have about 2 hours experience with LabView but have been doing PLC programming for 20+ years and could have done this in about a minute in a PLC using Structured Text. The zip file has the main and sub VIs saved back to V8.0

0 Compliments
Message 25 sur 48
1 077 Visites

Hi dangeross,

 


@dangeross wrote:

I thought this could be useful to anyone else trying to achieve the same thing and like me is very new to LabView. I only have about 2 hours experience with LabView but have been doing PLC programming for 20+ years and could have done this in about a minute in a PLC using Structured Text.


You can do the same code in about a minute in LabVIEW too - when you use better datatypes and algorithms…

 

Your example is nice, but also very Rube-Goldberg!

See this:

Your version in the upper 90% of the image, my version in the lower 10%…

And using proper datatypes (like an array of booleans) you could even omit the BuildArray function!

What's the point in ORing constants with a 0xFF constant?

You alos forgot to show the radix on all your numeric constants: to improve code readability you should show the radix whenever you don't use the default decimal displaymode…

 

The mainVI misses a wait: no need to read user input as fast as possible!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Compliments
Message 26 sur 48
1 064 Visites

@sticyfinger wrote:

Hi,

 

****** I know how to enable a bit (set bit high) in LabVIEW.  ********

For example, let say I have 101, and I want to enable the middle bit. 

To enable the middle bit I would use the OR operation.  101 OR with 10 which would produce 111. I can do this in LabVIEW.

Check the attachments. 

 

*******Can someone tell me how to disable a bit (set bit low) using LabVIEW?  ******

Now let says I have 111, and I want to disable the middle bit in LabVIEW?   I know I should just use And operation.

111 AND with 101 will produce 101.   I am not sure how to do this in LabVIEW. PLEASE HELP.


AND with the inverse of the interesting bit. With your example of 101, if you want to reset the highest bit you get 100, inverse to 011 and AND with 101 to get 001.

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

Qestit Systems
Certified-LabVIEW-Developer
0 Compliments
Message 27 sur 48
1 049 Visites

This where I have ended up. I can input a Byte and set and clear bits as needed. Thanks to GerdW to pointing me to the use of arrays.

0 Compliments
Message 28 sur 48
1 032 Visites

@dangeross wrote:

This where I have ended up. I can input a Byte and set and clear bits as needed. Thanks to GerdW to pointing me to the use of arrays.

altenbach_0-1718638904906.png

 


 

  • You still have a greedy loop that cannot be stopped.  Why is there a toplevel greedy loop if this is a subVI?
  • You still have way too much duplicate code.
  • And it is a really (really!!!) bad idea to have terminals with duplicate names.
  • Your boolean array to number has the incorrect output configuration (should be U8)
  • You have a logical inconsistency such that set always takes precedence over clear. Maybe that's what you want?
  • And no, having all these connectors is not manageable! Imagine you would have to adapt your code to deal with 64bit integers! Wiring all connectors can cause many mistakes. Stick with common connector panes, there are only a few that are useful.

altenbach_0-1718640300038.png

 

 

 

0 Compliments
Message 29 sur 48
1 023 Visites

Here's how it could look like verbatim. Personally, I would probably use boolean array inputs instead of clusters and make it a malleable VI to deal will all kinds of integers

 

Since this is a subVI, there should not even be a loop!

 

altenbach_0-1718640633533.png

 

0 Compliments
Message 30 sur 48
1 014 Visites