Logging motor current

I was curious to see the current limit in action, so I built a small contraption, consisting of a swing arm that press on a scale to measure force (with some foam in between to smooth strong impact).
On each run, I activate the motor during 1 second each time I press the touch sensor. Strangely enough, the first stroke is much more violent than the following ones. This is confirmed by the current curves, showing much higher currents on the first activation (see the curves attached). I don’t think it could be caused by any thermal problem since the test is fairly short and the current limit low (100mA). Any idea of what can cause this behaviour?

And here is the program used:

#pragma config(Sensor, port7,  touch,          sensorVexIQ_LED)
#pragma config(Motor,  motor1,          dut,           tmotorVexIQ, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
#pragma DebuggerWindows("debugStream");
bool dolog=false;

task logging()
    while( 1 )
            // Send some data to the debug stream
            writeDebugStreamLine("%7.3f; %4d", nSysTime/1000.0, getMotorCurrent( motor1 ) );
            // Don't hog the cpu (or run the loop too fast).

task main()
    writeDebugStreamLine("time, motor, current");
    setMotorBrakeMode(dut, motorCoast);
    setMotorCurrentLimit(dut, 100);
    while (true)
        while (getTouchLEDValue(touch)==0);
        setTouchLEDColor(touch, colorRed);
        setMotorSpeed(dut, 50);
        while (getTouchLEDValue(touch)==1);
        setTouchLEDColor(touch, colorNone);
      setMotorSpeed(dut, 0);

Hi Philo,

We have two questions for you to help clarify/explain the behavior seen here:

  1. Could you share a photo of this setup?
  2. Do you have the force measurements measured on the same time frame as the motor current measurements?

The motor current limiting mode of the VEX IQ Smart Motor is primarily set to cap the steady-state current draw, which in term limits the maximum torque output from the Smart Motor. This torque limiting capability is best described as “eggshell mode” - as in you want to pick up eggs without breaking them.

During brief transient conditions, the current measured by the Smart Motor can appear to exceed the limit that it is currently set to. This can occur during normal acceleration (when it can very briefly exceed the limit), but also can be reverse current from back EMF of the motor. This current from back EMF can occur from instances such as if the motor hits a physical hard stop and slightly bounces back. The current sensor inside the Smart Motor is unsigned, so it cannot differentiate between normal current draw, and reverse current from back EMF from the motor.

From the graphs shown here, it would appear that on the first iteration of the 1 second test loop, the Smart Motor is taking up all of the backlash present in the system until it hits the hard stop, then in the subsequent tests the backlash is pre-biased such that at approximately 200mm in every test the motor is hitting its final hard stop (the force plate). Afterwards (~380ms on first test, ~250ms on subsequent tests), the motor current then settles down to the specified current limit where it remains.


  • Art

Hello Art,
Here is a photo of the setup:

As you can see the lever has some travel before hitting the foam. Here is a new curve obtained in “normal” run (not the first one), we see a current of about 50mA during arm movement, then a spike at 200mA when we hit the foam, and a settle below 100mA after. The arm is manually moved back to starting position before each attempt.

This is to be compared to a first run after starting the program where current reach 400mA during arm movement, and again - I guess - when the foam is hit.

To sort out things, here are the curves obtained with arm placed initially on foam, here the spike (weaker) occurs immediately:

…but lasts a much longer time during the first run.

It’s difficult to see the pushing strength during first run spike because my scale doesn’t have such a fast response time. But I have recorded “weight” in the range of 200-250g during first run, while it keeps below 80g in following runs.

And finally a short video. To make it more obvious on the video, I reduced current limit to 60mA.

I also discovered that my firmware (both in the brain and in the motor) were not up to date, but clearly it makes no difference…







…and a related question: what kind of accuracy can I expect from getMotorCurrent()? If I set a current limit and average current read during 1 or 2 seconds (after waiting for 300ms to let current settle), I get a value pretty close to the set current limit. But when I measure current powering the brain, I get a significantly lower value. Brain “Idle curent” is about 110mA, and for a 600mA current in the motor, my meter reads about 500mA total (brain+motor)! That’s a 200mA difference… The offset remains the similar for lower current.