CIM Motor Reversing

We’re having an issue with a CIM motor operating in reverse. In our code, we have a CIM motor set to go forward for half a second and then in reverse for half a second (both at full speed) at the press of a button. The issue is that the motor does not go back to it’s starting position like we thought it would. It goes further back than it was when it started, which is causing an arm to move further and further back with each button press.

Any ideas?


I’d try to put an encoder on the motor and controlling it through a PID loops.

Electric motors are designed to operate with more effective power in one direction than another. This is done through the timing of where the armature and commutator in relation to the field magnets.

It sounds as if your initial button push is spinning the motor in “reverse” and your second movement is the motors “forward” rotation. If you’re trying to stop an arm at a specific point then limit switches or a potentiometer would really be the best option.

There are many variables you are not controlling. Things like battery voltage, arm. angle (the load on the motor required to move the arm when it is horizontal is much more than when the arm is vertical), the motor may be biased in one direction, etc. Simply applying a percentage of battery voltage for a specified amount of time isn’t going to let you preciely control the position of the arm.

You will need to put a sensor on the arm joint to measure the angle of the arm, and use that measured angle in code with a control loop to control the position of the arm.

In particular with an arm, the load on the arm is almost always preferentially in one direction (probably what you are referring to as “back”). All other things being equal or even close, it will take more volt-seconds to raise a load than to lower it. If you need to get it to a certain spot, use an encoder, potentiometer, limit switch, or other sensor to tell when the process is complete.

To add to this, in a pinch, you can add a dead stop to the mechanism and then program it to slightly overshoot where you want it to go and always hit the dead stop, thus returning it to a consistent starting point. You do briefly stall the motor by doing this (though CIMs do have a bit of tolerance to this) and you have to have a mechanism beefy enough to take the repeated impacts, but if for whatever reason you are unable to add/program a sensor for the mechanism it will do the job. Just make sure you bring a spare motor or two. Of course this method pretty much only works with a 2-position mechanism.

That said, the other suggestions mentioned above are all far preferable to the option I just described. A physical dead stop for a mechanism should almost always be a last resort. ::ouch::

If you go this route, also monitor the current on that motor. A spike in current (other than during startup) will alert you to hitting the stop. Not elegant, but better than nothing.

Encoders are easy to use and take no time to install. Look into that before doing something like dead stopping your arm. That could cause many other issues with voltage spikes and brownouts.

Encoders are not hard, but limit switches are even easier - especially with the new SPARK speed controllers which have limit switch inputs. No software!!! You dont even need to stop driving up or down based on time, just leave the motor drive in the direction you want the arm. The limit switch cuts the power at precisely the right time. I strongly recommend limit switches tied directly to a speed controller (Spark, Jaguar or SRX) for this particular problem.

Also, a previous post talked about loads. Not knowing your system, I am going to make a wild guess that the first direction arm moves is “up” (against gravity) and the second, faster direction is “down” (with gravity). Gravity always wins - common design challenge with rotating arms.

Potentiometers work too, but they can be harder to program.

***If you decide to go with limit switches, make sure to mount them in such a way that they don’t also serve as a hard stop.

Common mistake.**

Seconded. You’ll destroy your limit switch if you do.
-Knowledge from experience.

It boggles my mind that there are still people that think motors/gearboxes/axles are going to perfectly turn in opposite directions at the same speed/distance/force.

That happened enough times that we had to fashion a new ‘detector’ (the part that is hit and turns on the switch, not sure what it’s called) out of a zip tie. It actually worked better than the metal did by not bending out of shape and staying there for the rest of the offseason event.

Agreed. I have seen many smashed/mangled limit switches. This can be a huge issue, especially if the arm is moving fast. Locate the switch trip point about a half inch before the hard stop, such that when at the hard stop the switch is still tripped.

One way to make the “switch” more robust from damage with fast moving arms is to use a hall effect sensor like Hall Effect Sensor - AndyMark, Inc an put a small magnet on the arm.

…or mount the switch so that it is activated as the arm moves past it and hits the hard stop. There are many solutions.

Thats what i meant, but also tried to suggest that it to stays activated while resting on the hard stop. I have seen fast moving arms fly past the limit switch, the motor pauses, and then restarts when it clears the switch. It then powers into the hard stop as if the switch wasn’t there.

I think Ether, MrForbes and myself are saying the same thing. Limit switches should be mounted next to the moving arm such that the arm sweeps past the switch; NOT directly in the arm’s path such that the arm smacks the switch and uses it as the hard stop.

Yes, or an encoder and PID if you feel like doing extra work.

I’ve seen this referred to as a whisker or cat’s whisker.

I encourage this as well. We’ve found hall effect sensors to be much easier to work with than limit switches.

In what ways are they easier to work with?