4 CIMs causing robot lockup

Good morning everyone,

We are now utilizing 4 CIMs instead of 2. The code works happily when configured for 2 motors, but when you configure it for 4, turning left (and only turning left) causes it to spin at full speed for about 1/4 of a second, then die. Very strange.

We have checked for wiring issues and CIM issues. We have tried leaving the code the same and unplugging 2 of the CIMs, then the other 2 to try to identify if it is hardware and the problem persisted whenever CIMs were separated.

We have tried unplugging the 4 CIMs from 1,2,3, and 4 and plugging them into 5,6,7 and 8 with the same results. Again, putting the code back to just 1 and 3 and it works just fine. We have also replaced all 4 CIMs and swapped out the 4 jaguars.

I’m down to wondering if it’s the new cRIO we received this year. But that seems odd as it is fully functional outside this one turn. That or maybe the way your declare the CIMs has changed slightly. Any thoughts?

Oh! we have also tried 2 separate laptops, one running the 2012 software and one running the 2013.


The following is our code:

/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */

 * Ground Zero Template
 * This Template is to be utilized to troubleshoot the robot. Please make no
 * changes to this code. It's to be copied and branched off of for new projects
 * and is for reference only.
 * Are you trying to install netbeans? For the love of God, read:
 * http://first.wpi.edu/Images/CMS/First/Getting_Started_with_Java_for_FRC.pdf
 * TLDR:
 **Install NetBeans with Sun JDK and update completely
 **NetBeans->Tools->Plugin->Available->Check all that say FRC
 **Check for updates
 **NetBeans->Tools->Options->Misc->FRC->Team# 3734

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Relay.Value;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;

 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
public class AwesomOSimple extends SimpleRobot {
    // Attach digital sidecar to 4 Jaguar PWMs. Inputs expect (left,right) 
    // and have further ability to put in for 4 motor drive, listed as
    // (left,right,left 2, right 2). Further Jaguars can be added with the
    // jaguar declaration, but by default we are not using the jaguar
    // package.
    RobotDrive drive = new RobotDrive(1,3,2,4);
    // XBox Controller is treated exactly the same as a regular joystick with
    // 7 axes (only 6 available)
     * XBox Controller Mappings
     * 1: A
     * 2: B
     * 3: X
     * 4: Y
     * 5: Left Bumper
     * 6: Right Bumper
     * 7: Back
     * 8: Start
     * 9: Left Joystick
     * 10: Right Joystick
     * Axis Mappings getRawAxis(1-6)
     * (all output is between -1 and 1)
     * 1: Left Stick X Axis     (Left:Negative ; Right: Positive)
     * 2: Left Stick Y Axis     (Up: Negative ; Down: Positive)
     * 3: Triggers: Left        (Positive ; Right: Negative)
     * 4: Right Stick X Axis    (Left: Negative ; Right: Positive)
     * 5: Right Stick Y Axis    (Up: Negative ; Down: Positive)
     * 6: Directional Pad       (Not recommended, buggy)
    Joystick xboxControl = new Joystick(1);
    // Relays have to be announced prior to initialization and then must be
    // attached to a sidecar pin from within robotInit()
    Relay firingMechanism;
    int drivingStyleModifier = 0;
     * This method is called once each time AwesomO is enabled for both 
     * autonomous and tele-operated modes.
    public void robotInit() {
        // Attach our predefined relay to a point on our digital sidecar
        firingMechanism = new Relay(1);
     * This function is called once each time the robot enters autonomous mode.
    public void autonomous() {
        // Let's get a sonar sensor as well as a directional sensor on this 
        // bad boy and get the robot patrolling the halls. So unnerving!
        for (int i = 0; i < 4; i++) {
            drive.drive(0.5, 0.0); // drive 50% fwd 0% turn
            Timer.delay(2.0); // wait 2 seconds
            drive.drive(0.0, 0.75); // drive 0% fwd 0% turn

     * This function is called once each time the robot enters operator control.
    public void operatorControl() {
        while (true && isOperatorControl() && isEnabled()) // loop until change
            //tank drive OR arcade drive available
            if (drivingStyleModifier == 1) {
                drive.arcadeDrive(xboxControl.getY(), xboxControl.getX());
            else {
                drive.tankDrive(xboxControl.getY(), xboxControl.getRawAxis(5)); // drive w/ joysticks
            // Firing mechanism example
            else if(xboxControl.getRawButton(2)){
            else {
            // Toggle Y button activity
            if(xboxControl.getRawButton(4) && drivingStyleModifier == 0) {
                drivingStyleModifier = 1;
            else if (xboxControl.getRawButton(4) && drivingStyleModifier != 0) {
                drivingStyleModifier = 0;

*Try carefully working your way down these two checklists:

When you say you unplugged the CIM, did you unplug the CIM from the motor controller, or unplug the motor controllers PWM cable?

I don’t see anything obviously wrong with your drive code, so I agree with Ether that it is likely an electrical issue.

One potential (but unrelated problem) with your code is your drivingStyleModifier toggle. Unless your driver can press the button and release it in less then 0.005 seconds, the driving style modifier will continually toggle. You’ll want to remember the previous state of the button, and only toggle if the current state is true and the previous state was false.

Another potential (but unrelated problem) is your firing mechanism. If both buttons one and two are pressed, the relay will be set to forward and then very quickly be set to reverse. This isn’t good for the hardware. You should use a if, else if, else structure to make sure that only one value is set for each iteration.

Have you checked that each motor is running the same direction? What you describe sounds like the motors are fighting each other causing the current to skyrocket.

Wow. Super embarrassing. I’m amazed it functioned at all. The digital sidecar was not powered at all. Totally not plugged in aside from the serial communications cable. I’ll send a followup once I confirm that fixes it tonight.

Thank you!

Oh, and thank you. I’ll update the code to reflect those suggestions as I had noticed that it didn’t switch driving modes when Y was hit and I can definitely identify the damage that could come from alternating current forward and backward rapidly in the device. Thank you guys!

Yup, that’s all that was wrong. Thank you guys!

FYI to someone who may find this… We had a new CIM that was not assembled correctly and spun backward. Make sure the scribe marks on the black case of the CIM line up with the marks on the silver ends.

??? The marks are there so that in assembly, the holes for the screws can be found.

To clarify my previous statement: the field magnets were reversed when the motor was assembled. Dissassembly and reversing the field magnets during reassembly fixed the rotation issue.