View Single Post
  #4   Spotlight this post!  
Unread 10-02-2013, 01:29
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,713
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Window Motor Problem?

Quote:
Originally Posted by cdizzle View Post
I'm really sorry, but my code's all at the lab, so this is the best that can do for now, but I'll try to explain it as well as I can.

I have 2 case blocks. One case block is wired to button 3 on our joystick. When that case is true, it sets the motor speed to -0.9. That one works smoothly. I also have another case block which is wired to button 4 on our joystick. When that case is true, it sets the motor speed to 0.9. When I press that button, the motor moves in the right direction, but it stops and jerks forward and then stops again. Note that I haven't put anything in the false part of the case blocks.

Thanks so much for your help and once again I'm really sorry that I can't post a screen shot right now.
That's certainly a recipe for weirdness if you're pressing both buttons at once. Also, how on earth does your motor stop after you let go of a button? If you let go of the counter clockwise button, does the motor stop or keep going? If your motor stops then you're clearly setting the motor speed to 0 somewhere else, since it's not in your false cases. If you're setting speed to 0 elsewhere, then your button 3 code is beating out the zero speed code and keeping things moving. Your button 4 code occasionally loses to the zero speed code and thus sometimes the motor stops, and sometimes it moves. Assuming you're setting speed to 0 somewhere.

What I like to do for programming two buttons to turn a motor is to pick a dominant case. That means that you pick one of the buttons that "wins" if both buttons are pressed. Then you can pretty easily use two Select blocks to set the motor speed. See my attached code snippet, in which button 3 "wins" and gets final say in the motor speed.
Attached Thumbnails
Click image for larger version

Name:	Motor Snippet.png
Views:	36
Size:	5.8 KB
ID:	13911  
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote