Intermittent stopping issues from Jrk 21v3

Hello,

I am using a single Jrk 21v3 motor driver to control a Cytron SPG50-100K motor, which drives wheels on a small cart. The Jrk is controlled from an Arduino Micro, using Arduino’s SoftwareSerial library. The Arduino is then controlled by a PC via Serial USB. This setup has worked great for quite a few months of use.

Recently, I’ve started noticing the motor completely stopping in the middle of a movement without any command to do so. The Jrk error records report only that it is Awaiting Command, and the Input and Target variables read from the Jrk both report the expected value.

This issue has persisted through replacing the motor driver as well as the motor, which suggests to me it’s a problem in the Arduino sketch. The code has been gradually updated over time. The entire code for interfacing with the motor is shown here:

void SetMotorTarget(int x, bool silent) {
  if (x != 2048) {
    if (x > 4095)
    {
      x = 4095;
    }
    else if (x < 0)
    {
      x = 0;
    }
    currentMotorSpeed = x;
    word target = x;  
    MotorSerial.write(0xAA);
    MotorSerial.write(0xB);   
    MotorSerial.write(0x40 + (target & 0x1F));
    MotorSerial.write((target >> 5) & 0x7F); 

    SetMoveStatus(1);

    if (!silent)
    {
      SendMotorMessage(currentMotorSpeed);
    }
  } else {
    StopMotor(silent);
  }
}

void StopMotor(bool silent) {

  MotorSerial.write(0xAA); 
  MotorSerial.write(0xB);  
  MotorSerial.write(0x7F);

  SetMoveStatus(0);

  if (!silent)
  {
    SendInformationMessage("motor stopped");
    SendFeedbackMessage("motor stopped");
  }

}

Basic state tracking in the Arduino records a current speed, and these commands are only called when the desired speed changes; that is, at the beginning or ending of a move.

The most confusing part of this is that the implementation and usage of these specific functions has not changed recently at all, but the problem persists through hardware changes.

Thoughts and/or solutions, anyone? Thanks.

Edit: Cleaned up some extraneous comments in the code.

The awaiting command error is triggered when another error that is configured as “Enabled and Latched” gets triggered. You might check to see which errors you have configured to this setting in the Errors tab of the Jrk Configuration Utility. When the error happens, you can try looking in the “Occurrence count” column in this tab to see which errors have happened that might have triggered the awaiting command error.

Also, it might be worth noting that any version of the Set Target command should clear the awaiting command error.

Brandon

Actually, it’s configured to have nothing else set to “Enabled and Latched” at all. I’m still getting no errors at all when it switches to Awaiting Command.

And it does, at least from what I’ve seen. When the motor stops, I’m still fully able to start it up again immediately.

The awaiting command error also occurs in Serial Input mode when the Jrk is powered on. Have you changed anything with your power supply from when it was working without this error? What are you using as a power supply? It might be possible that the voltage of your power supply is dropping too low (e.g. it is discharged or too much current is being drawn) and causing the jrk to reset. Also, could you post your jrk settings file? You can save the settings file by choosing the “Save settings file…” option within the “File” drop-down menu in the Jrk Configuration Utility.

Brandon

Hmm, power supply hasn’t changed. It’s a COTS drill and power tool battery connected through a 12v regulator to the motor, and the computing is powered by the same circuit after 12->5v. The battery is nominally 18-21v or so, varying over a charge.

Settings file is attached.
jrk settings 6-16-17.txt (1.4 KB)

Thank you for the additional information. The Motor Off command (that you use in your StopMotor() function) also sets the triggers awaiting command error. You might look into when your code is calling the StopMotor() function and see if it might be happening at an unexpected time.

Brandon

Did some testing today with the power circuit - there was a separate error in the wiring that may have contributed, but the problem still remains after fixing. Also hooked up an oscilloscope to the power inputs to the motor driver. When the error occurred, the oscilloscope registered no change in voltage.

As far as the code side, I added some feedback to alert me every single time the StopMotor() was called… so far haven’t been able to catch the error since adding that, but the motor’s running now. Hopefully we’ll see the feedback the next time the stop occurs, which would suggest it’s something explicitly calling StopMotor() in the code (a much easier problem to fix).

Edit: wording.