Go to Post A 823543:1 reduction should be fine if you ever need to pick up a truck...or a house. - Tim Sharp [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 05-02-2009, 21:37
program1's Avatar
program1 program1 is offline
Registered User
AKA: RJ
FRC #2441
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryknoll
Posts: 43
program1 will become famous soon enough
limit switch help

hi

were trying to program the motor on our robot so when it goes one direction. and when it hits the limit switch. it will stop. does anyone know how to program the limit switch to do this or know any links that can help me? any information will be appreciated
__________________
ok, who ate my hot pocket?
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2009, 23:48
airnate airnate is offline
Registered User
FRC #0236 (Techno Ticks)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: southeastern CT
Posts: 93
airnate is a jewel in the roughairnate is a jewel in the roughairnate is a jewel in the rough
Re: limit switch help

You could do something like the attached code picture. If you wire your limit switch to a GPIO (aka DIO) input on the Digital Sidecar so that when the limit switch closes it sends 5V to the DIO, then the code will detect it as True when the motor reaches its limit.

So in the included code the motor is first sent Set Speed of 1 to get it moving. The while loop waits for the motor to reach the limit. When the limit switch returns True, the Set Speed is called again with a 0 to stop the motor.

If you make this code into a subVI I would recommend that you call the Open and CLose outside of the main loop of your program and pass in the device references (i.e. MotorControlDevRef, DigitalInputDevRef) into the subVI and back out again.
Attached Thumbnails
Click image for larger version

Name:	limit_switch.png
Views:	163
Size:	12.8 KB
ID:	7333  
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2009, 18:26
program1's Avatar
program1 program1 is offline
Registered User
AKA: RJ
FRC #2441
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryknoll
Posts: 43
program1 will become famous soon enough
Re: limit switch help

we tried the code out, the limit switch registers and it picks up the signal, but the motor doesn't stop. did we do something wrong with the code?
__________________
ok, who ate my hot pocket?
Reply With Quote
  #4   Spotlight this post!  
Unread 11-02-2009, 18:52
airnate airnate is offline
Registered User
FRC #0236 (Techno Ticks)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: southeastern CT
Posts: 93
airnate is a jewel in the roughairnate is a jewel in the roughairnate is a jewel in the rough
Re: limit switch help

Can you post your own code so I can take a look?

If you want to debug your code, you can turn on highlighting (the lightbulb button), you should be able to see that the limit switch causes the while loop to exit and then the motor should set the speed to zero causing the motion to stop.

One issue may be that I'm assuming the DIO input goes True when you want your motor to stop. If the opposite is what you want, then right click the while loop stop sign and select "Continue if True".

-Nate
Reply With Quote
  #5   Spotlight this post!  
Unread 14-02-2009, 20:16
program1's Avatar
program1 program1 is offline
Registered User
AKA: RJ
FRC #2441
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryknoll
Posts: 43
program1 will become famous soon enough
Re: limit switch help



this is the code we have so far, the false has the motor stop because the DIO = true all the time until we hit the limit switch
__________________
ok, who ate my hot pocket?

Last edited by program1 : 14-02-2009 at 20:22.
Reply With Quote
  #6   Spotlight this post!  
Unread 15-02-2009, 00:49
s0crates s0crates is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2009
Location: Australia
Posts: 52
s0crates is on a distinguished road
Re: limit switch help

I think you may be missing the (hidden) easiest route: the jags have built in ports for limit switches. Check the datasheet for more info.

Quote:
Limit Switches
The normally closed limit switch inputs provide a simple method for limiting range of motion. When a
limit switch input is open, motor operation in that direction is disabled. Install jumpers if limit switch
functionality is not required.

Admittedly, it is a pain in the posterior to chop up the pwm cables to make a 2-pin connector at one end, but this solution gets rid of one sizable problem with running the limit switches in software - the latency.

-jonathan

nice filter CD guys
Reply With Quote
  #7   Spotlight this post!  
Unread 15-02-2009, 01:08
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: limit switch help

Quote:
Originally Posted by s0crates View Post
I think you may be missing the (hidden) easiest route: the jags have built in ports for limit switches.
Those ports are off-limits this year.

Quote:
Admittedly, it is a pain in the posterior to chop up the pwm cables to make a 2-pin connector at one end...
Two-pin connectors came in the Kit of Parts this year. They're perfect for the Robot Signal Light connection.
Reply With Quote
  #8   Spotlight this post!  
Unread 15-02-2009, 01:13
vhcook's Avatar
vhcook vhcook is online now
Reader of Things
AKA: Victoria
FRC #1939 (Kuh-nig-its)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Kansas City, MO
Posts: 546
vhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond repute
Re: limit switch help

Quote:
Originally Posted by s0crates View Post
I think you may be missing the (hidden) easiest route: the jags have built in ports for limit switches.
Regrettably, FIRST has made that illegal this year to reduce the number of new things being introduced. See this Q&A response.

The attached is a screenshot of how I handled limit switches. This is a subvi that comes off of teleop.vi in the advanced framework. I've built the motor device reference and the limit switches into a typedef and passed them into the subvi. If you're in the basic framework you could open the devices in the same part of the code that the drive motors are opened, pass the references into the teleop execute case, and then drop something like this code in.

Basically, if the input signal is sending the turret left, it checks the left limit switch and stops if the switch is active, otherwise it does what it was told. If it's sending the turret right, it checks the right limit switch and stops if the switch is active and does what it's told otherwise. It checks each time teleop runs within the main loop. The extra indicators are not required - they just make it easy to see what's going on with the limit switches from the front panel of the vi.
Attached Thumbnails
Click image for larger version

Name:	turret control.jpg
Views:	80
Size:	57.5 KB
ID:	7452  
__________________


Reply With Quote
  #9   Spotlight this post!  
Unread 15-02-2009, 01:45
s0crates s0crates is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2009
Location: Australia
Posts: 52
s0crates is on a distinguished road
Re: limit switch help

WOW. okay - thx for telling me.
It seems kinda dumb to prohibit their use .

-jonathan
Reply With Quote
  #10   Spotlight this post!  
Unread 15-02-2009, 12:59
airnate airnate is offline
Registered User
FRC #0236 (Techno Ticks)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: southeastern CT
Posts: 93
airnate is a jewel in the roughairnate is a jewel in the roughairnate is a jewel in the rough
Re: limit switch help

program1, I don't see anything wrong with your code, but it does seem like you have other code to the right side of the picture. Does this other code do anything with the motors? If so, the other code could be interfering with what you are trying to do with the limit switch.
Reply With Quote
  #11   Spotlight this post!  
Unread 15-02-2009, 17:22
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: limit switch help

program 2, why not just "or" the output of the two limit switches and submit that boolean value to a select block true would be 0 and false would be the motor command? I think that will be equivalent to what you want to do.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
limit switch solomason519 Programming 9 09-02-2010 08:50
Using a limit switch to limit motion ManicMechanic Programming 16 20-12-2007 00:54
limit switch wedellm Electrical 4 16-02-2007 13:01
gyro/accelecometer/limit switch help needed Anton Programming 4 04-02-2005 16:39


All times are GMT -5. The time now is 21:38.

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