Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Technical Discussion (http://www.chiefdelphi.com/forums/forumdisplay.php?f=22)
-   -   Motor Stuttering (http://www.chiefdelphi.com/forums/showthread.php?t=133868)

frc_team_4615 02-02-2015 13:27

Motor Stuttering
 
Hello all,

We are trying to program one of our motors to move one direction when we press a button and the other direction off of a different button. We're using a Jaguar motor controller right now.

When going one direction operation is normal but the reverse direction stutters. If we reverse the code we get the same results but with opposite directions.

If we use the joystick axis to control this movement both directions are working. We checked that the buttons are at 1 and -1 when pressed.

Things we've tried so far:

Different motor
Different motor controller
Changed which buttons were assigned in the code
Changed which directions were assigned in the code

I tried searching but was having trouble with using the right keywords. Has anyone else had this problem? Is there an easier way to accomplish the same task?

TIA

AustinH 02-02-2015 13:36

Re: Motor Stuttering
 
Doesn't sound like a hardware problem. When this happened to us on our first lift test, we dug through the code and found conflicting instructions being sent to the motor controller when various buttons were pushed. Can you publish some of your code?

notmattlythgoe 02-02-2015 13:37

Re: Motor Stuttering
 
What are you programming in? Can you post your code?

AllenGregoryIV 02-02-2015 13:42

Re: Motor Stuttering
 
Quote:

Originally Posted by AustinH (Post 1437310)
Doesn't sound like a hardware problem. When this happened to us on our first lift test, we dug through the code and found conflicting instructions being sent to the motor controller when various buttons were pushed. Can you publish some of your code?

This was my first thought as well. It sounds like part of your code is sending 0 and then a different part is sending 1. Is the stop command from the first button always executing when it's not pressed? That would be my blind guess.

jgrindle 03-02-2015 07:00

Would you be able to post your riolog? if you're working in java or c. Also posting your code to github would be helpful, we've had a similar problem. If it's on github, it makes for other teams to help debug a little easier.

Alan Anderson 03-02-2015 09:21

Re: Motor Stuttering
 
I am guessing your code is doing something like this:
Code:

if button 1 pressed
  then run motor forward
  else stop motor
endif

if button 2 pressed
  then run motor backward
  else stop motor
endif

Button 2 will work. However, if you press button 1 the motor will run but will immediately be stopped by the button 2 code.

Instead, try this:
Code:

if button 1 pressed
  then run motor forward
endif

if button 2 pressed
  then run motor backward
endif

if neither button pressed
  then stop motor
endif

You might also want to explicitly deal with both buttons pressed at the same time.


All times are GMT -5. The time now is 14:02.

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