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=131058)

nickphowell 06-11-2014 19:04

Limit Switch Help
 
Our programming team is having some issues with setting up two limit switches. After button 4 is pressed, our first limit switch, Limit Switch, is supposed to stop our motors. After button 5 is pressed, the second limit switch, Limit Switch 2, is supposed to stop the motors once again.

When we run the code, the upper portion works properly (see picture), but our motors seem to fight each other.

Any help or input would be welcomed, and we are open to try everything.
Thank you


nickphowell 06-11-2014 19:05

Re: Limit Switch Help
 
In case the picture did not show, the link is here:
http://imgur.com/EvqRgHi

Mark McLeod 06-11-2014 19:35

Re: Limit Switch Help
 
  1. You really don't want to be addressing one motor from two conflicting places at the same time. That's why they fight each other. Are you also setting the same motors in both False cases? That would be telling it to go and stop at the same time.
  2. You need a Wait (say 10ms) in your loops otherwise you threaten to overload and lock up your CPU.
Instead, make all your decisions about what you want the motor to do, then set the motor only once.
Here's an example for a Relay. Just replace the Relay with your motor in the sequence you want.
Since you are keying off two different limit switches you can also select and pass in the corresponding limit switch name or reference.

nickphowell 15-11-2014 12:40

Re: Limit Switch Help
 
Quote:

Originally Posted by Mark McLeod (Post 1407697)
  1. You really don't want to be addressing one motor from two conflicting places at the same time. That's why they fight each other. Are you also setting the same motors in both False cases? That would be telling it to go and stop at the same time.
  2. You need a Wait (say 10ms) in your loops otherwise you threaten to overload and lock up your CPU.
Instead, make all your decisions about what you want the motor to do, then set the motor only once.
Here's an example for a Relay. Just replace the Relay with your motor in the sequence you want.
Since you are keying off two different limit switches you can also select and pass in the corresponding limit switch name or reference.

How do you wire and use a relay? We are a brand new programming team, so we do not know everything there is to know......yet.

We went ahead and tried a new chunk of code, and that is not working either. However, it worked better than previously. What went wrong is our "Up" case would not work properly. The motors would not work when this case was triggered, but the "Default" and the "Down" cases worked perfectly. The "Default" case just sets the motor output to 0.

Here are pictures of what the code looks like right now.
http://imgur.com/yLUmJ8J
http://imgur.com/f80i1KW

nickphowell 15-11-2014 16:49

Re: Limit Switch Help
 
Alright, so we have figured out our problem. Thank you all for the help

Iaquinto.Joe 19-11-2014 06:30

Re: Limit Switch Help
 
An additional tip:

Every time you call the reference VI, it will get a joystick reference twice. It's better practice to make a habit to only get references once if you can manage it. It will marginally make you code faster and increase readability.

Greg McKaskle 19-11-2014 07:10

Re: Limit Switch Help
 
Quote:

An additional tip:
In other words, if the code will return the same value as you already have, you can just wire the value to two or more places.

Greg McKaskle


All times are GMT -5. The time now is 08:49.

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