Go to Post You see the learning experience doesn't stop during construction. It goes on to competition or to everyone who looks at a picture on delphi, who studies the bot and says I like how they did this or I woulda changed this a bit. - Dan Richardson [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 24-01-2013, 15:18
JakofallAces JakofallAces is offline
Registered User
FRC #1228
 
Join Date: Jan 2013
Location: New Jersey
Posts: 1
JakofallAces is an unknown quantity at this point
Help on programming a limit switch

Hey, I have been trying to figure out how to program a motor with 2 limit switches. I want the motor to go forward, when a trigger/button is pressed, until it hits the first limit switch and then it will go back until it hits the second limit switch and then it will stop.... and repeat when i press the trigger/button again. this is for our shooting setup, we plan on having an arm that will push the disks to the shooter.
Reply With Quote
  #2   Spotlight this post!  
Unread 24-01-2013, 18:17
propionate's Avatar
propionate propionate is offline
Team co-lead and LabVIEW programmer
AKA: Stephen
FRC #1732 (Hilltopper Robotics)
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Milwaukee
Posts: 93
propionate is on a distinguished road
Re: Help on programming a limit switch

I haven't done something like this before, so someone will have to double-check this solution, but I believe the following code will achieve your goal:

Begin.vi:
http://i.imgur.com/H3hoOoh.png

Teleop.vi:
http://i.imgur.com/xTD6a8s.png

Finish.vi:
http://i.imgur.com/5cQGowS.png


The Teleop routine takes place in three steps (working from top to bottom). When the trigger on the joystick is pressed, the arm begins to move at half speed and releases the first limit switch. When the arm hits the second limit switch, the code will compare the previous state of the limit switch to its current one. If those states are different (the switch has been tripped), the arm will begin to move back towards the first limit switch. Finally, when the arm reaches and trips the first limit switch, the motor will be turned off. I created this off the top of my head, so I am sure Greg McKaskle will be along soon to point out the flaws (or unnecessary complexities).

Best of luck.
Reply With Quote
  #3   Spotlight this post!  
Unread 24-01-2013, 20:03
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: Help on programming a limit switch

Sorry, I can't see your examples to check them out. They're on a blocked site.

Here are two examples of just the limit switches. You want the one to the right, then need to add you button presses.

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

Last edited by Mark McLeod : 25-01-2013 at 10:26.
Reply With Quote
  #4   Spotlight this post!  
Unread 24-01-2013, 23:41
propionate's Avatar
propionate propionate is offline
Team co-lead and LabVIEW programmer
AKA: Stephen
FRC #1732 (Hilltopper Robotics)
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Milwaukee
Posts: 93
propionate is on a distinguished road
Re: Help on programming a limit switch

Quote:
Originally Posted by Mark McLeod View Post
Sorry, I can't see your examples to check them out. They're on a blocked site.
I will attach the LabVIEW files to this post. After looking at your code, I think each of us is trying to solve different problems. I included an the attached VI an *extremely* rudimentary drawing of what I was imagining jackofallace's robot "arm" to look like: an appendage with its degree of rotation limited by two limit switches that the arm itself hits. Perhaps some clarification is needed.
Attached Files
File Type: vi Arm and 2 limit switches.vi (33.1 KB, 59 views)
Reply With Quote
  #5   Spotlight this post!  
Unread 25-01-2013, 11:25
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: Help on programming a limit switch

That attachment works better for viewing.

Your Teleop needs a little work. Your answer approximates what I posted.
The way you set it up, the three case statements will roll the dice for who wins at setting the motor speed. The last one wins, but that doesn't mean the one on the bottom. You need a cascade of wires rather than local variables to do what you are attempting. Local variables should generally be avoided and shouldn't be set all over the place. Local/Global variables are set once, read everywhere.

PS.
Here is your example with some changes to make it a cascade. I also simplified the button check. The picture is your code just with the Case statements replaced by Selects, only because that way every choice can be seen at a glance.

The limit switch values might be different depending on how the limit switch has been wired. There are two choices in the wiring: 1) normally open, 2) normally closed. One way will return a True until it is pressed, the other way will return a False until pressed. After you've wired a limit switch, test it in code to see which value you are getting. In other words, you may have to reverse your True/False cases depending on how the switch has been wired (and don't assume without double checking).
Attached Thumbnails
Click image for larger version

Name:	Arm and 2 limit switches-same-but-different.png
Views:	146
Size:	31.4 KB
ID:	13651  
Attached Files
File Type: vi Arm and 2 limit switches-revised.vi (33.6 KB, 38 views)
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 25-01-2013 at 12:50.
Reply With Quote
  #6   Spotlight this post!  
Unread 25-01-2013, 23:18
propionate's Avatar
propionate propionate is offline
Team co-lead and LabVIEW programmer
AKA: Stephen
FRC #1732 (Hilltopper Robotics)
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Milwaukee
Posts: 93
propionate is on a distinguished road
Re: Help on programming a limit switch

Ah, thank you for the corrections. There is nothing in the false cases of my code so I'm not sure if it would ever be attempting to write to the local variable at more than one location (perhaps in the instant you press the button for the first time). But your way is definitely more elegant.
Reply With Quote
  #7   Spotlight this post!  
Unread 28-01-2013, 14:42
nickcvet89 nickcvet89 is offline
Registered User
FRC #1228 (RoboTribe)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2003
Location: Rahway,NJ
Posts: 99
nickcvet89 will become famous soon enough
Send a message via AIM to nickcvet89
Re: Help on programming a limit switch

Mark, I had trouble with switching the axis to a button. I get broken wires between the upper and lower limit.
__________________
Reply With Quote
  #8   Spotlight this post!  
Unread 28-01-2013, 15:15
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: Help on programming a limit switch

Which example are you referring to?
The simple limit switch example won't run the sequence you were talking about originally. That's what Stephen's code does.

In that original limit switch example, if you want to use a button instead of the joystick axis, then you'll need to use the button to choose a motor speed to put into the coercion vi.
The broken wires are because the upper and lower limit wires are carrying floating-point numbers, while a button is a boolean True or False.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #9   Spotlight this post!  
Unread 12-02-2013, 23:25
nickcvet89 nickcvet89 is offline
Registered User
FRC #1228 (RoboTribe)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2003
Location: Rahway,NJ
Posts: 99
nickcvet89 will become famous soon enough
Send a message via AIM to nickcvet89
Re: Help on programming a limit switch

@propionate I tried the modified version of the code you created (the corrected one by mark mcleod) and ran into an issue with it. When the trigger is pressed, the arm moves forward as desired, then the first limit switch is pressed, the problem arises is that the only way the arm moves in reverse is if it presses the switch and lets it go and same goes for when it presses the second limit switch to stop. Essentially those movements only work when the switch is pressed and released, but does not work if you continuously hold the either of the switches. Is there anyway to change the program so that when the switch is pressed, it starts the next set of programmed movements instead of it waiting for the switch to start those movements? Thanks for any help
__________________
Reply With Quote
  #10   Spotlight this post!  
Unread 13-02-2013, 09:48
crollison crollison is offline
Registered User
AKA: Chris Rollison
FRC #4809 (Black Knight Robotics)
Team Role: Coach
 
Join Date: Nov 2009
Rookie Year: 2009
Location: Marceline, MO
Posts: 57
crollison is an unknown quantity at this point
Re: Help on programming a limit switch

Here is about the only thing that I can contribute to, if you have a jaguar motor controller, don't forget about the built in limit switch connections on the motor controller. This is the absolute easiest thing, no programming required.
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:46.

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