Go to Post What if my teams drive train isn't an option? - MARS_James [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-02-2009, 15:02
Pasha Pasha is offline
Registered User
None #1403
 
Join Date: Jan 2008
Location: Ukraine
Posts: 8
Pasha is an unknown quantity at this point
Limit Switchers Logic Problem

Hi, I'm Paul Boguslavskiy from Team 1403. I have a problem trying to get this limit switcherrs to work. I have 3 buttons of a joystick to control the direction of a lazy susan: left, right stop.

I have 2 limit switchers on each side. When the lazy susan goes too much left the switch should go on and stop the lazy susan. What I did before was say that if left limit goes on, set motor speed to 0 (stopping the motor). However, the limit switch STAYS true, and the motor speed is forever set to 0. I'm not sure what to do now, how can I stop the motors from spinning once, and then be able to continue later.

SIDE NOTE: When I press the button for left once it should continue to spin left forever. I do not want a press and hold to spin the motors.

  #2   Spotlight this post!  
Unread 04-02-2009, 15:08
rogerlsmith's Avatar
rogerlsmith rogerlsmith is offline
Software Engineer
AKA: Roger Smith
FRC #3357 (COMETS)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2007
Location: Grand Rapids, MI
Posts: 214
rogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to behold
Re: Limit Switchers Logic Problem

Try this, keep track of which limit switch is tripped (on) and compare that to which direction button is getting pressed. For example, if left limit switch is tripped and you want to rotate left, don't let this happen, but turn the motor on if you want to turn right. Same procedure for the other side.

Hope this helps.
__________________
Roger Smith
Mentor - FRC Team 3357
COMETS - Creating Outstanding Minds, Embracing Technology & Science
---------------------------------------------------------------------------------------

Share FIRST videos, photos and experiences at FIRSTObjective.org
  #3   Spotlight this post!  
Unread 04-02-2009, 15:23
Pasha Pasha is offline
Registered User
None #1403
 
Join Date: Jan 2008
Location: Ukraine
Posts: 8
Pasha is an unknown quantity at this point
Re: Limit Switchers Logic Problem

I still run into a problem though. As soon as I set that false state to set motor to 0. I now have to hold the button to go left, and hold the button to go right.
  #4   Spotlight this post!  
Unread 04-02-2009, 15:51
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Limit Switchers Logic Problem

The problem that you're describing is more complex and probably shouldn't be done the way your code is laid out. The reason I say this is that you have 3 blocks that are affecting the same output. In order to do what you want the program to do, you'll need to look at the 3 buttons and 2 switches and make a decision on what to do to the output.

I think this is the logic that you want to use. Note that based on the inputs we calculate a state and store it into a persistent variable called state. Then at the end, we look at state and write the output.
Code:
IF left is pressed
    IF left limit switch is pressed
        state = MOVE_STOP
    else
        state = MOVE_LEFT
ELSE IF right is pressed
    IF right limit switch is pressed
        state = MOVE_STOP
    else
        state = MOVE_RIGHT
ELSE IF stop is pressed
    state = MOVE_STOP
ELSE
    // No change to state

IF state is MOVE_LEFT
    output = MOVE_LEFT_SPEED
ELSE IF state is MOVE_RIGHT
    output = MOVE_RIGHT_SPEED
ELSE
    output = 0
I work predominantly in C and C++, so my Labview terminology and logic isn't the best. I'm sure there are people around that can help you with the implementation side of things. I would suggest reading through the logic and understanding what it does. Only then should you try to implement something like that.
  #5   Spotlight this post!  
Unread 04-02-2009, 22:34
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Limit Switchers Logic Problem

Personally, I'd read all the jstick buttons and limit switches. Then look at the jstick buttons to decide what to do with the motor disregarding the limits. You need some logic about multiple buttons being pushed, but you can build a lookup integer from the the three bits or you can do lots of logic.

After you decide what to do with the motor, look at the limits. One limit forces negative numbers to zero, the other forces positive to zero.

Greg McKaskle
  #6   Spotlight this post!  
Unread 05-02-2009, 02:11
DarKCroNo's Avatar
DarKCroNo DarKCroNo is offline
Registered User
FRC #2670
 
Join Date: Dec 2007
Location: Toronto
Posts: 37
DarKCroNo is an unknown quantity at this point
Re: Limit Switchers Logic Problem

Your problem is that your not toggling your buttons, we had this problem too in labview. If you look at the wiring, u said that if button 1 is true than such happens (set motor speed) but that action is within the case box, and it only executes if and only when button 1 is true. The only time button 1 is constantly true is if ur holding the button. Try holding ur buttons and see if the motors are moving the way u'd like.
Now if that doesn't work, i don't know if its also the values ur inputting to the motors which are affecting it but... when I was programming it i didn't realize u cud put values -1 -> 1 to indicate full speed rev and full speed forward, and so i used 127 and -127 and i'm not sure if that makes a difference. Because I tried 127 first i don't know if thats the default pwm values for the program to read.

Now about the limit switching, I have just finished a program where for our robot, a gate will be drawn up and down to let balls roll out of our basket. We used limit switches to trigger the stoppingmotion of the gate. I wouldn't mind giving it to u if you want but the problem is I don't understand it much to explain. I spent a whole night doing it and got it working through debugging, but if you were to ask me how each block works i would have no clue haha...
Oh and I can give you a toggling vi as well if you'd like.

If this gives you too much trouble there is another thing you can do which makes it a whole lot simpler. Since your motion is rotating you can use a potentiometer and use a PID control loop to control how it spins... but i guess if you constantly want to spin left u can't since theres a max and min value for a pot. You can also try an encoder, I dunno much so just suggesting.

Last edited by DarKCroNo : 05-02-2009 at 02:16.
  #7   Spotlight this post!  
Unread 05-02-2009, 02:25
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,372
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Limit Switchers Logic Problem

See if this works for you.
It allows CW rotation when the CCW switch is hit and vise verse.
Attached Files
File Type: rar Limit switch.rar (7.1 KB, 61 views)
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #8   Spotlight this post!  
Unread 05-02-2009, 13:03
Pasha Pasha is offline
Registered User
None #1403
 
Join Date: Jan 2008
Location: Ukraine
Posts: 8
Pasha is an unknown quantity at this point
Re: Limit Switchers Logic Problem

Quote:
Originally Posted by Dave Scheck View Post
I think the problem is that you blindly set the output to 0 when the switch is pressed. I think you want the logic to be something like this
Code:
IF left button is pressed
    IF left limit switch is pressed
        output = 0
    ELSE
        output = MOVE_LEFT_SPEED
You'll need something similar on the right side as well

That doesn't work because it would just continue to spin left forever and the limit switch would only
be checked when the button is pressed again.

The other logic would work maybe, but I'm not sure if the limit switcher would work. Also, I wish
this was C, I'd be done way sooner. However, I have to write this in LabView.


To Greg: I did set up the buttons to move the motors. That works perfect. When you press
right, it goes right, when it goes left it goes left. When I press stop, it stopped. Only
problem is the limits. Also, once the limit switch is pressed down, I do force the motor to 0.
This way the motor actually does stop. However, the limit stays true once it hits it, and the motor
is constantly forced to 0.

@DarKCroNo: You have a VI that toggles the joystick instead of auto updating?
Such as, you press right to be true, and it toogles to true, instead of auto updating it
back to false? If so, PLEASE GIVE!

@billbo911: I will look right into that as soon as class is over. Thanks!

Thanks for your support and I will keep everything updated on how this goes. This is a very
important task, and I need this working. Thanks for you help again.
  #9   Spotlight this post!  
Unread 05-02-2009, 14:37
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Limit Switchers Logic Problem

I didn't say to set the value to zero when limit was pressed. One limit switch forces positive motor input to zero but leaves negative alone, the other forces negative and leaves positive alone.

To handle the button toggles, I'd add a state variable. The buttons update the state variable, then the state variable selects positive, zero, or negative speed, then the limit switches pin as described above. The state variable obviously needs to be in either a shift register, a local, or something that maintains state data.

Greg McKaskle
  #10   Spotlight this post!  
Unread 05-02-2009, 15:17
Pasha Pasha is offline
Registered User
None #1403
 
Join Date: Jan 2008
Location: Ukraine
Posts: 8
Pasha is an unknown quantity at this point
Re: Limit Switchers Logic Problem

Quote:
Originally Posted by Greg McKaskle View Post
I didn't say to set the value to zero when limit was pressed. One limit switch forces positive motor input to zero but leaves negative alone, the other forces negative and leaves positive alone.

To handle the button toggles, I'd add a state variable. The buttons update the state variable, then the state variable selects positive, zero, or negative speed, then the limit switches pin as described above. The state variable obviously needs to be in either a shift register, a local, or something that maintains state data.

Greg McKaskle
But once the limit switch is pushed and it starts to feed positive values. It'll forever continue to force positive values. Even I press another button to go left, it won't because it'll be continuosly fed positive values.
  #11   Spotlight this post!  
Unread 05-02-2009, 15:38
Pasha Pasha is offline
Registered User
None #1403
 
Join Date: Jan 2008
Location: Ukraine
Posts: 8
Pasha is an unknown quantity at this point
Re: Limit Switchers Logic Problem

Hmm, is there anyway to set something just once. Like let's say the limit switch becoems true, is there a way to set motor speed to 0, ONCE, and not continuously locking up the device.

edit: @DarkOrono, I can't hold it. I need to be able to press and go. I cannot have it have the need to be held.

Last edited by Pasha : 05-02-2009 at 15:45.
  #12   Spotlight this post!  
Unread 04-02-2009, 15:10
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Limit Switchers Logic Problem

I think the problem is that you blindly set the output to 0 when the switch is pressed. I think you want the logic to be something like this
Code:
IF left button is pressed
    IF left limit switch is pressed
        output = 0
    ELSE
        output = MOVE_LEFT_SPEED
You'll need something similar on the right side as well
Closed Thread


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
Fuzzy Logic? skidmarks NI LabVIEW 1 25-01-2009 09:36
Limit Switch Problem Boydean Programming 3 13-02-2008 16:32
Using a limit switch to limit motion ManicMechanic Programming 16 20-12-2007 00:54
Logic Question aubinhick990 Website Design/Showcase 2 11-03-2006 16:45
Why I hate Logic EnderofDragon Chit-Chat 2 19-02-2002 21:02


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

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