LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3 way vertical toggle switch

Thanks for your post, Altenbach.  It was useful, and I stole your idea & your switch design.

 

I needed a 3-way switch that latched in both directions, and had a middle "off" state, so as to produce momentary numbers for a "case" structure.  I stole your code, modified it, and am reposting it here.  I added LEDs so you could tell the switch's "last state"

 

Message 21 of 40
(4,982 Views)

@Dan the Clam wrote:

Thanks for your post, Altenbach.  It was useful, and I stole your idea & your switch design.

... 


 

A Kudos would be a nice way to pay Christian for his work. Smiley Wink

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 22 of 40
(4,977 Views)

Done!  Kudos given.  🙂

Message 23 of 40
(4,974 Views)

You are using way too many local variables. None are needed. 😉

 

Here's a quick modification.

Message 24 of 40
(4,968 Views)

 A clever use of a shift register - thanks for posting!.  🙂  But is there such shame in using local variables?  Arguably my code was simpler (albeit, not as elegant).

0 Kudos
Message 25 of 40
(4,944 Views)

@Dan the Clam wrote:

 A clever use of a shift register - thanks for posting!.  🙂  But is there such shame in using local variables?  Arguably my code was simpler (albeit, not as elegant).


 

Over-use of locals will earn you  a failing grade on the LV certification exams.

 

Read about Locals here.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 26 of 40
(4,941 Views)

@Dan the Clam wrote:

But is there such shame in using local variables?  Arguably my code was simpler (albeit, not as elegant).


One case structure is simpler than two, IMHO. 😄

A shift register is much simpler than local variables spread all over the diagram. If the state data is contained in a shift register, it is tighly localized to one wire and much easier to keep track of, than if the data is modified from various scattered locations via locals.

 

Your code even has a theoretical (but unlikely to happen in this particular case) race condition. Even though you initialize the two local variables outside the loop, there is no data dependency and we cannot tell with 100% certainty that these will be written before the first loop iteration. if the loop would start first and write one of the locals, it might get quickly overwritten by the initialization, leading to inconsintent behavior. LabVIEW does not necessarily execute left to right.

Message 27 of 40
(4,935 Views)

I am attempting to mimic an aircraft cockpit switch panel.  So I need 3 way switches that look exactly like what the cockpit panel's switches look like.  In your post you mentioned your buttons "containing custom graphics for the true and false states".  How is that done?  I've been hunting and pecking for a while.  I think the best option for me would be to do what you did for the switch to a vertcial slide (e.g. Fill Slide) with a range from 0 - 3, Representation set to I32, Scale style = blank (no major, minor ticks). etc. Label not visible, etc.  Then change the graphics so that the 0 position (slider down) of the slider is an image of my switch pointing down, the 1 position (middle) of the slider is an image of my switch in the middle position, and the 2 position (slider up) an image of my switch pointing up.  This is similar to one of the first posts in this series except with custom graphics. 

 

Then once I apply the unique graphic to each slider position, I think I'll be all set.  There's a picture of the panel from a video game that is similar to what I'm doing for a full flight simulator attached.  About half the switches on there are 3-pole instead of 2-pole switches. 

 

Any guidance or even pointing me to where in the help I can read more about customizing controls, etc. would be much appreciated.  What I've read so far doesn't talk about applying custom graphics per state.

 

http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/custom_cont_ind_type/

 

0 Kudos
Message 28 of 40
(4,746 Views)
0 Kudos
Message 29 of 40
(4,704 Views)

Personally, I think you should use a picture ring indicator and swap the images depending on the location of mouse down events. You could use the a series of photographic images of your switches.

0 Kudos
Message 30 of 40
(4,700 Views)