Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   limit switch help (http://www.chiefdelphi.com/forums/showthread.php?t=73709)

program1 05-02-2009 21:37

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

airnate 05-02-2009 23:48

Re: limit switch help
 
1 Attachment(s)
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.

program1 07-02-2009 18:26

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?

airnate 11-02-2009 18:52

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

program1 14-02-2009 20:16

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

s0crates 15-02-2009 00:49

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 :cool:

Alan Anderson 15-02-2009 01:08

Re: limit switch help
 
Quote:

Originally Posted by s0crates (Post 821031)
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.

vhcook 15-02-2009 01:13

Re: limit switch help
 
1 Attachment(s)
Quote:

Originally Posted by s0crates (Post 821031)
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.

s0crates 15-02-2009 01:45

Re: limit switch help
 
WOW. okay - thx for telling me.
It seems kinda dumb to prohibit their use :mad: .

-jonathan

airnate 15-02-2009 12:59

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.

windell747 15-02-2009 17:22

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.


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

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