Go to Post If there was no internet then somebody in FIRST would probably invent it. - Koko Ed [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 17-02-2014, 18:52
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
How to program a toggle switch to stop a motor from spinning..?

Simple task, right?

I need a switch program that, when the PVC pipe hits the switch, it will stop powering the motor and prevent power in the same direction until the switch is depressed.

I also need to know how to wire the switch properly so it will function.
Reply With Quote
  #2   Spotlight this post!  
Unread 17-02-2014, 19:33
MathMaven MathMaven is offline
Registered User
AKA: Elisha Sword
FRC #3175 (Knight Vision)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Michigan
Posts: 50
MathMaven is on a distinguished road
Re: How to program a toggle switch to stop a motor from spinning..?

The programming is simple. The idea is that a switch will return either a true value or a false value corresponding to whether the switch is being pressed at the moment.

You want the motor to operate normally when the switch is returning false (is not being pressed), and to be allowed to move only backward when the switch is returning true (is being pressed).

I would implement this knowledge as follows:

Code:
if ( ![switch name here].Get()  )
{
    /* control the motor normally */
}
else
{
    if ( [motor name here].Get() > 0 ) // or < 0; test to figure out!
    {
        [motor name here].Set(0); // necessary: otherwise motor will continue 
                                  // at whatever speed you left it at
    }
}
Naturally, use the syntax of whatever programming language you're using.

I can't help you with the wiring, since I don't know too much about that stuff.
__________________
—Elisha Sword

2010–13: FRC Team 3175 (Knight Vision), student, lead programmer
2012–13: FRC Team 3175 (Knight Vision), lead website designer
2014: FRC Team 3175 (Knight Vision), programming mentor

“Who has not been amazed to learn that the function y = e^x, like a phoenix rising from its own ashes, is its own derivative?”
—Francois le Lionnais
Reply With Quote
  #3   Spotlight this post!  
Unread 17-02-2014, 20:17
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,833
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 program a toggle switch to stop a motor from spinning..?

Here are two LabVIEW examples.
They are just two different styles, pick what you are most comfortable with.
When the limit switch is wired Normally Open (NO) it reads in the code as false when pressed.
Wired Normally Closed it reads in the code as true when pressed.
Wire to Ground (GND) and pick only one of the other two NC or NO.
If you look at the side of the limit switch, most of them have a diagram labeled GND, NO, and NC to show where the wires go.
If there is no label, then use a multimeter to figure out which is the ground and which is NC or NO.



__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 17-02-2014 at 20:33.
Reply With Quote
  #4   Spotlight this post!  
Unread 18-02-2014, 15:30
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
Re: How to program a toggle switch to stop a motor from spinning..?

Where would the switch wire into? The PD board or the Digital Sidecar?
Reply With Quote
  #5   Spotlight this post!  
Unread 18-02-2014, 15:35
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,833
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 program a toggle switch to stop a motor from spinning..?

Limit switches get wired to a Digital Input on the Digital Sidecar. Signal and ground pins only (NOT the +5v power pin).
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #6   Spotlight this post!  
Unread 18-02-2014, 16:33
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
Re: How to program a toggle switch to stop a motor from spinning..?

Alright I'll do that very soon, thanks.
Reply With Quote
  #7   Spotlight this post!  
Unread 18-02-2014, 18:14
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
Re: How to program a toggle switch to stop a motor from spinning..?

I don't think either of those examples would work with what I'm trytrying trying to do. Pretty much we have a pvc pipe that is extending and descending. While descending, I'd like a piece of metal to hit the switch to prevent the motor from pulling the pvc down further.
Reply With Quote
  #8   Spotlight this post!  
Unread 18-02-2014, 18:31
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,833
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 program a toggle switch to stop a motor from spinning..?

A team I'm mentoring is also moving a pvc pipe up and down, stopping the motor at both the top and the bottom with limit switches.

The right example is good for that.

I don't know what is complicating what you are doing differently.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #9   Spotlight this post!  
Unread 18-02-2014, 18:47
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
Re: How to program a toggle switch to stop a motor from spinning..?

I think the main complication is how im using 2 true-false statements attached to two separate button.

I can't upload a picture because the photo exceeds size, but buttons 4 & 6 both connect into a true-false triangle. The true of 4 is -1 and the false is connected to the output of button 6. Button 6 has true 1 false 0. The output of the two connects to set motor output
Reply With Quote
  #10   Spotlight this post!  
Unread 18-02-2014, 19:07
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,833
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 program a toggle switch to stop a motor from spinning..?

Your button 4 Select output would replace "axis 2 (y)" in the example on the right.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #11   Spotlight this post!  
Unread 18-02-2014, 19:10
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
Re: How to program a toggle switch to stop a motor from spinning..?

And leave button 6 as is?
Reply With Quote
  #12   Spotlight this post!  
Unread 18-02-2014, 19:16
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,833
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 program a toggle switch to stop a motor from spinning..?

The result of the Button 6 Select feeds the Button 4 Select.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #13   Spotlight this post!  
Unread 18-02-2014, 19:24
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
Re: How to program a toggle switch to stop a motor from spinning..?

So now onto the wiring. We have switches similar to the one pictured above. But as for wiring into the DS and what wire is nrrdrd I dont know what to do
Reply With Quote
  #14   Spotlight this post!  
Unread 18-02-2014, 20:48
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,833
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 program a toggle switch to stop a motor from spinning..?

If you have a spare PWM cable, that could be used by cutting off the male end.
  • The black wire goes to the limit switch GND contact on the bottom of the photograph.
  • The white wire goes to either the NO or NC contact on the side of the limit switch
  • The red wire gets cut short and taped over with electrical tape (it's not used)
The female end of the PWM cable plugs into a DIO on the Digital Sidecar.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #15   Spotlight this post!  
Unread 19-02-2014, 20:10
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
Re: How to program a toggle switch to stop a motor from spinning..?

Thank you for this info. During our post-build season I'll wire up a mock where we can test the code and wiring. Thanks for your help!
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 21:04.

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