My system set up is using SDKSK servo motors from Teknic , I have 4 motors being controlled by Teknics ClearCore controller device that I am programming with the Arduino IDE.
My system works all fine until an Estop button is hit, which is wired cut the motors power supply (75VDC). I then reset my estop, and the motors get power again, but wont spin...
I get no error messages from the motors LED status lights, or from the ClearCore status lights, I also have printed various pre-built error status values that Teknic includes in their ClearCore library but they all return with no errors.
The ClearCore reads 2 digital inputs (Run Command(Run/Stop), Direction Command (CW/CCW) and 1 analog input for speed (0-10v) , these signals come from a PLC which controls the rest of our system, the ClearCore is just to communicate/control the motors.
I have called Teknics support and they have assured me there is no reason (hardware wise) that cutting the motors 75VDC power should cause any problems or force the motor or controller to enter a error/fault state. which is only fixed by hard resetting the board or by reuploading my code.
Teknic support believes the issue is that when the estop is pressed and the 75VDC power is cut, "my code gets caught in a loop of some sort".
Obviously they arn't going to dive into my code and start helping me debug so thats where this forum comes in!
#include "ClearCore.h"
#define motor0 ConnectorM0
#define motor1 ConnectorM1
#define motor2 ConnectorM2
#define motor3 ConnectorM3
int accelerationLimit = 1000; // pulses per sec^24
bool MoveAtVelocity(int32_t velocity);
int i;
int enableArray[4];
int directionArray[4];
int speedArray[4];
int enableInput[4] = {IO0,IO1,IO2,IO3};
int directionInput[4] = {IO4,IO5,DI6,DI7};
int speedInput[4] = {A9,A10,A11,A12};
void setup() {
MotorMgr.MotorInputClocking(MotorManager::CLOCK_RATE_NORMAL);
// Sets all motor connectors into step and direction mode.
MotorMgr.MotorModeSet(MotorManager::MOTOR_ALL,
Connector::CPM_MODE_STEP_AND_DIR);
motor0.HlfbMode(MotorDriver::HLFB_MODE_HAS_BIPOLAR_PWM);
motor1.HlfbMode(MotorDriver::HLFB_MODE_HAS_BIPOLAR_PWM);
motor2.HlfbMode(MotorDriver::HLFB_MODE_HAS_BIPOLAR_PWM);
motor3.HlfbMode(MotorDriver::HLFB_MODE_HAS_BIPOLAR_PWM);
// Set the HFLB carrier frequencies to 482 Hz
motor0.HlfbCarrier(MotorDriver::HLFB_CARRIER_482_HZ);
motor1.HlfbCarrier(MotorDriver::HLFB_CARRIER_482_HZ);
motor2.HlfbCarrier(MotorDriver::HLFB_CARRIER_482_HZ);
motor3.HlfbCarrier(MotorDriver::HLFB_CARRIER_482_HZ);
motor0.AccelMax(accelerationLimit);
motor1.AccelMax(accelerationLimit);
motor2.AccelMax(accelerationLimit);
motor3.AccelMax(accelerationLimit);
Serial.begin(9600);
uint32_t timeout = 5000;
uint32_t startTime = millis();
while (!Serial && millis() - startTime < timeout) {
continue;
}
}
void loop() {
for (byte i = 0; i <= 3; i = i + 1) {
enableArray[i] = digitalRead(enableInput[i]);
directionArray[i] = digitalRead(directionInput[i]);
if (analogRead(speedInput[i]) < 200){
speedArray[i] = 0;
}
else{
speedArray[i] = (enableArray[i])*(map(analogRead(speedInput[i]),200,1024,1800,5000));
}
if (directionArray[i] == LOW){
speedArray[i] = speedArray[i] * (-1);
}
}
motor0.MoveVelocity(speedArray[0]);
motor1.MoveVelocity(speedArray[1]);
motor2.MoveVelocity(speedArray[2]);
motor3.MoveVelocity(speedArray[3]);
}
This is how I am controlling my motors.
Let me know if you can see why my code may get stuck in a loop?