When our robot is enabled, one of our victor sp’s constantly swaps from neutral to forward.
we have tried:
swapping the victor with a new one
swapping and reimaging the roboRIO
changing the cables to and from victor(power and motor output)
swapping PWM location on the roboRIO
This is dumbfounding our team and we have no idea whats up with the ghost motor. The only possibility we have thought of is the code, but we cannot find anything. If anyone could take a look at the code or has any idea what else could be the problem, please comment. This is our repository on GitHub: https://github.com/Aventek/ExarchCode
Concur it sounds like code. Can you replicate with a very simple new test program which is driving just that victor? Which motor is it (e.g. which PWM output is it hooked up to)? When you swapped PWM output connections did the problem move with the victor or with the PWM output? Can you give us any other details (e.g. does it happen in teleop or autonomous, as soon as you enable or only when a certain button is pressed, etc). Thanks for linking to your code, but without knowing which motor it is it’s very difficult to narrow the scope of the code review to find the problem more quickly.
Thank you, Will try these when we meet tomorrow, it really is not that big of a deal as it spins at a very slow speed. We did calibrate the motor controller and found it made 0 difference.
This won’t help you for the immediate future, but my team bought a few PWM signal generators - sold on Amazon as servo testers - and found them extremely helpful for diagnosing issues like these.
I like this one:
You can connect several PWM cables at the same time and verify that all the motor controllers are behaving the same.
They’re very cheap, but they ship from China so don’t expect them to arrive for 2-3 weeks. If you needed something sooner, AndyMark or your local hobby store sells similar devices, or you could roll your own.
One to keep in mind. When disabled, the Roborio sends no PWM signal which the speed controls interprets as disabled. When enabled the Roborio sends the PWM signal it is told to send. 0 speed or “neutral” is actually in the middle of PWM band which is distinctly different than the disabled non signal. The LED on the Victor will tell you the signal it is receiving. Writing the signal that is being sent to the PWM channel is also useful. You can write to smart dashboard or print it to the DS message display. BTW It is not unusual for an unloaded motor to spin slowly at 0 speed if you are using a joy stick to control it without any headband for zero speed.
The meaning of the various blinkly control systems LEDs can be found here. Really useful for findind ghosts and other control problems.
Button the Select (Note: the key switch function, circulation patterns)
S-1 manual mode (Manual)
S-2-bit mode (Neutral)
S-3 automatic mode (Automatic)
Also, were you able to figure out what this means?
With PPM signal test function in the display, the input PPM signal changes while the input the PPM signal synchronization output to the servo Energized automatically
My best guess, as it seems like a really common issue that I debug, is that you are setting the motor speed in two different places.
What motor is giving you trouble in the code? I have found these:
public static final int leftRearDrivePWM = 3;//3
public static final int leftFrontDrivePWM = 2;//0
public static final int rightRearDrivePWM = 1;//1
public static final int rightFrontDrivePWM = 0;//2
public static final int leftLaunchPWM = 4;
public static final int rightLaunchPWM = 5;
public static final int liftAnglerPWM = 6;
public static final int liftAngler2PWM =7;
public static final int launchAnglerPWM = 8;
public static final int **intakeArmsPMW** = 9;
Looking through your code, I’m placing my bets on the launch motor.
In commands/Launch.java, you’re calling Robot.launcher.launch(shootSpeed) and Robot.launcher.intakeControl(0):
protected void execute() {
// spinning launcher motors
if (Robot.oi.buttonLaunch.get()) {
// when lBump is held down run motors for launching
Robot.launcher.launch(shootSpeed);
Robot.launcherState = LauncherState.LAUNCH;
} else if (Robot.oi.buttonIntake.get()) {
// when rBump is held down run motors for intake
Robot.launcherState = LauncherState.INTAKE;
Robot.launcher.launch(loadSpeed);
Robot.launcher.intakeControl(barSpeed);
Robot.launcherState = LauncherState.INTAKE;
} else if (auto){
Robot.launcher.launch(shootSpeed);
Robot.launcher.intakeControl(0);
Robot.launcherState = LauncherState.AUTO;
} else {
// when neither are held down dont run motors
Robot.launcher.intakeControl(0);
Robot.launcher.launch(0);
Robot.launcherState = LauncherState.STILL;
}
if(Robot.anglerState != AnglerState.PID){
// activate angler
if (Robot.oi.buttonShooterDown.get()) {
// when B is held down angle launcher down
Robot.launcher.angleLauncher(motorDownSpeed);
Robot.anglerState = AnglerState.ANGLING_DOWN;
} else if (Robot.oi.buttonShooterUp.get()) {
// when X is held down, angle launcher up
Robot.launcher.angleLauncher(motorUpSpeed);
Robot.anglerState = AnglerState.ANGLING_UP;
} else {
// stop angling
Robot.launcher.angleLauncher(0);
Robot.anglerState = AnglerState.STILL;
}
}
//control servo based on state
if(Robot.servoState == ServoState.RETRACTED){
// Robot.launcher.servoControl(extendedPosition);
} else if(Robot.servoState == ServoState.EXTENDED){
// Robot.launcher.servoControl(retractedPosition);
}
}
Take a look at the subsystem code for those two commands in subsystem/Launcher.java:
public void intakeControl(double speed){
leftLaunch.set(-.4);
rightLaunch.set(-.4);
intakeBar.set(speed);
}
// sets launch motors to spin and then set servo to firing position
public void launch(double speed) {
// setting launch motors
leftLaunch.set(speed);
rightLaunch.set(speed);
}
You’re setting the speed in two different places. That will cause issues.
Mode 1 is the mode we use most, where simply turning the knob changes the PWM duty cycle, which is displayed on the LED readout. Mode 2 is some variation of this but I don’t recall the details. We just never really used it. Mode 3 sweeps the duty cycle between the min and max values. Great for making a servo swing back and forth but not so useful for FRC. Makes the wheels go from full forward to full reverse and back again within a pretty short span. I wouldn’t leave it doing that for very long.
I think that’s either trying to say that since there are three separate PWM outputs linked to the input, that you could connect three servos (or 3 motor controllers) and make sure their movements are synchronized, or simply that the output PWM value is automatically synchronized to the input from the knob. Who knows!
A few more questions, if I may. Hope you don’t mind, I’m truly interested.
Resolution and stability: How fine is the resolution, and once you’ve dialed in a desired pulse width and taken your hand off the dial, is it stable at that value?
Toggling: Is it practical to toggle the PWM output back and forth between neutral and a pre-set value by using the “Select” button, or does Mode3 get in the way if you try to do that?
Have you cracked one of these open to see what kind of circuit they use?
Have you successfully operated a Talon SRX with this device?
I have used the device to operate Talon SRX’s and Victor 888’s, the two controllers we used on our robots. The context of the tests were simply to verify that the motor controller was working, or that the cable was good, so I’m afraid I don’t have solid answers as to stability or accuracy. I have also used it to test the servos on our pan/tilt camera unit.
The 4-digit LED readout lets you dial in any value in microseconds, assuming a steady hand, between about 800 and 2200 (I believe). How finely would this correlate to the actual output signal? I don’t know, sorry. The dead band is right at 1500 and the motors turn from “very slowly” to “very fast” at the extreme ranges, and that’s all I really ever needed this thing to do. I strapped a 4-AA battery pack to this unit and called it a “quick and dirty PWM tester”.
I haven’t ever cracked it open but if I get a chance I’ll report back the results!