Go to Post Start simple and build up. - Mark McLeod [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-02-2013, 11:41
Connor1868 Connor1868 is offline
Registered User
FRC #4143
 
Join Date: Feb 2012
Location: United States
Posts: 10
Connor1868 is an unknown quantity at this point
How to toggle a relay with one button?

I need to turn a relay on and off your one button on the joystick. Much like a toggle button. Could some one give me some sample code?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-02-2013, 11:53
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,834
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: How to toggle a relay with one button?

Here's a generic button toggle example:


Put one Relay set in the inside True case, the opposite set in the inside False case.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2013, 11:58
Connor1868 Connor1868 is offline
Registered User
FRC #4143
 
Join Date: Feb 2012
Location: United States
Posts: 10
Connor1868 is an unknown quantity at this point
Re: How to toggle a relay with one button?

What are the green arrows?
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2013, 12:09
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,834
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: How to toggle a relay with one button?

The green arrow is found on the Programming -> Structures palette.
It's called a Feedback node, and what it does for you is remember the previous value, so the current value can be compared to the previous value.

So for the button press the value can be thought of as 0 (false) or 1 (true).
That first peculiar little combination is checking to see of the button is going from off (the previous value) to on (the current value), so it's only true the very first time you press the button and won't be true again until the button is release and pressed again.

To change the arrow direction once you put it on your block diagram, right-click and choose Change direction.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 02-02-2013 at 12:14.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-02-2013, 12:19
Connor1868 Connor1868 is offline
Registered User
FRC #4143
 
Join Date: Feb 2012
Location: United States
Posts: 10
Connor1868 is an unknown quantity at this point
Re: How to toggle a relay with one button?

How does the arrow become green? I found the arrow, but it is black.
Reply With Quote
  #6   Spotlight this post!  
Unread 02-02-2013, 12:22
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,834
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: How to toggle a relay with one button?

It changes color based on the data type that then gets wired to it.
It's green in the example because a boolean wire got connected to it.
So it'll turn green when you wire the button output to it.

If you wired an integer to it, then it would turn blue.
A floating point number would make it orange instead.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #7   Spotlight this post!  
Unread 02-02-2013, 12:25
Connor1868 Connor1868 is offline
Registered User
FRC #4143
 
Join Date: Feb 2012
Location: United States
Posts: 10
Connor1868 is an unknown quantity at this point
Re: How to toggle a relay with one button?

Thank you very much! It worked
Reply With Quote
  #8   Spotlight this post!  
Unread 02-02-2013, 12:33
Connor1868 Connor1868 is offline
Registered User
FRC #4143
 
Join Date: Feb 2012
Location: United States
Posts: 10
Connor1868 is an unknown quantity at this point
Re: How to toggle a relay with one button?

What about false in the outer case structure of?
Reply With Quote
  #9   Spotlight this post!  
Unread 02-02-2013, 12:38
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,834
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: How to toggle a relay with one button?

The outer false case avoids doing anything at all.
That's when the button hasn't been pushed again.
The wire just gets passed from the input tunnel right to the output tunnel.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 02-02-2013 at 19:09.
Reply With Quote
  #10   Spotlight this post!  
Unread 02-02-2013, 15:29
bvisness's Avatar
bvisness bvisness is offline
Programming Mentor, Former Driver
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Woodbury, MN
Posts: 181
bvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of light
Re: How to toggle a relay with one button?

One of our veteran team members wrote a very simple and effective Toggle vi, which I've attached. Just feed the button signal into the input, then use the output with a select block or case structure to select your relay state.
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	145
Size:	2.8 KB
ID:	13765  
Attached Files
File Type: vi Toggle.vi (9.4 KB, 54 views)
Reply With Quote
  #11   Spotlight this post!  
Unread 29-06-2013, 16:04
bvisness's Avatar
bvisness bvisness is offline
Programming Mentor, Former Driver
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Woodbury, MN
Posts: 181
bvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of light
Re: How to toggle a relay with one button?

I was asked to provide a screenshot of what our team's Toggle VI looks like, so here's how it works!
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2013-06-29 at 2.57.49 PM.png
Views:	132
Size:	10.2 KB
ID:	15037  
Reply With Quote
  #12   Spotlight this post!  
Unread 29-06-2013, 23:21
Aren Siekmeier's Avatar
Aren Siekmeier Aren Siekmeier is offline
on walkabout
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: 대한민국
Posts: 735
Aren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond repute
Re: How to toggle a relay with one button?

Quote:
Originally Posted by bvisness View Post
I was asked to provide a screenshot of what our team's Toggle VI looks like, so here's how it works!
Note: Remember that this VI would have to be set to Reentrant Execution (under VI Properties>Execution) in order to have a separate saved state at the feedback nodes for each instance of the VI. Otherwise it will not work properly at all (rising edge detection fails and all outputs will be locked together...).
Reply With Quote
  #13   Spotlight this post!  
Unread 02-07-2013, 13:27
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: How to toggle a relay with one button?

Ugh. The LabVIEW Developer in me can't stand feedback nodes. They make everything so much harder to understand.
Reply With Quote
  #14   Spotlight this post!  
Unread 02-07-2013, 15:47
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,100
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: How to toggle a relay with one button?

Quote:
Originally Posted by Racer26 View Post
Ugh. The LabVIEW Developer in me can't stand feedback nodes. They make everything so much harder to understand.
Interesting. It's one of the symbols that seems second nature to me. Perhaps because of many years working with digital controls systems. It's just Z-1.


Reply With Quote
  #15   Spotlight this post!  
Unread 02-07-2013, 16:18
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: How to toggle a relay with one button?

I understand them, but they break left to right data flow, which is considered a no-no in most of the LabVIEW world.

I prefer to use shift registers and while loops.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:56.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi