Go Down

Topic: 2 diff steppers/drivers, 1 is struggling (Read 173 times) previous topic - next topic

jingleby

I have 1 master arduino setting the pulse-rate for 2 slaves attached to stepper motors. Both motors are running the same code, but setup to the fact the motors and drivers are different.

Slave 1 is using a Big Easy Driver A4988 with a 400step motor.
Slave 2 is using a TB6600 driver with a 200 step motor ... and struggling to perform.

I expected I would need to set 1/2 microstepping on Slave 2 for them to match speeds (400revs), but for some reason both are set to full-step and maintain the same speed. Slave-2 misses a lot more steps than Slave-1 and stalls at a slightly lower max speed. Amps should be set properly for both boards (1.6a/phase).

Overall, Slave-2 has a difficult time and has quite jumpy resonant sections. I thought slave-2 driver was better quality but not sure what is going on.

Any help getting Slave2 to perform cleaner, or insights on the similar speeds would be appreciated.
Thanks

Code: [Select]
#include <Wire.h>
#define MS1 4
#define MS2 5
#define MS3 6
#define EN  8
#define directionPin 9
#define stepPin 10

byte b[3]; // byte array
bool flag1 = LOW;

// Timers for Ramping
unsigned long targetInterval = 1000; // read speed from master
unsigned long stepIntervalMicros = 2000; //Current # of micros delay. Primary speed control
unsigned long prevStepMicros = 0; //Timer
unsigned long prevTime2 = 0;
unsigned long timer2 = 10000; //delay when ramping to target time

byte direction = 0;

void setup() {
  Wire.begin(8);                // join i2c bus with address #8
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
 
  pinMode(EN, OUTPUT); //for other driver
  pinMode(MS1, OUTPUT);
  pinMode(MS2, OUTPUT);
  pinMode(MS3, OUTPUT);
  digitalWrite(MS1, LOW); //Micro. 000 = full, 100 = 1/2, 010 = 1/4, 110 = 1/8
  digitalWrite(MS2, LOW);
  digitalWrite(MS3, LOW);
  digitalWrite(EN, LOW);
 
  digitalWrite(directionPin, direction);
}

void loop() {
  {
    if (flag1 == HIGH)
    {
      if (b[0] == '*')
      {
        targetInterval = (b[1] << 8) | b[2]; //prev. RPSmicros = b[0] * 256 + b[1];
//        Serial.println(highByte(b[0]), HEX); //0x01; upper byte of 500
//        Serial.println(highByte(b[1]), HEX); //0x01; upper byte of 500
//        Serial.println(lowByte(b[2]), HEX); //0xF4; lower byte of 500
        Serial.print("Slave: ");
        Serial.println(targetInterval, DEC); //target speed
        flag1 = LOW;
      }
    }
  }
  moveMotor();
}

void moveMotor() {
  if (micros() - prevTime2 >= timer2){ //only adjust towards target speed at defined rate or will fly thru too quickly
    prevTime2 = micros();
    if (stepIntervalMicros >= targetInterval){ //if running too slow
      stepIntervalMicros --; //speed up motor by slowly decreasing pause
    }
    else if (stepIntervalMicros < targetInterval){ //if running too fast
      stepIntervalMicros ++; //slow down motor by slowly increasing pause
    }
  }
  if (micros() - prevStepMicros >= stepIntervalMicros) { //fire motor at current interval timing
    prevStepMicros = micros();
    singleStep();
  }
}

void receiveEvent(int howMany){
  for (int i = 0; i < howMany; i++){
    b[i] = Wire.read();
  }
  flag1 = HIGH;
}

void singleStep() {
    digitalWrite(stepPin, HIGH);
    digitalWrite(stepPin, LOW);
}

jingleby

I just read that power supplies much higher than motors rating could cause skipping issues on microstepping.

Power supply currently is 12V 60w (5.0A)

outsider

You have both drivers step signal connected to the same Arduino pin? Could cause a timing problem with different driver types, try a 10 or 20 microsecond delay between writing pin HIGH and LOW, see if it helps.
Code: [Select]
void singleStep() {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(20);
    digitalWrite(stepPin, LOW);
}

Robin2

You need to provide links to the datasheets for the motors.

Having an oversized power supply will never be a problem unless it exceeds the voltage limit of the stepper driver.

Missed steps is often caused by expecting a motor to start at full speed rather than accelerating it up to speed and decelerating back to a stop.

...R
Stepper Motor Basics
Simple Stepper Code


Two or three hours spent thinking and reading documentation solves most programming problems.

MarkT

AccelStepper library will simplify the code, worth checking out.

Also sounds like you may be having midband resonance issues - use more microstepping, greatly
reduces noise and resonance.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

jingleby

#5
Nov 21, 2018, 05:29 pm Last Edit: Dec 06, 2018, 08:07 pm by jingleby
Thanks Robin2. I've posted lots and you've been very helpful.

Slave-1 Motor Manual / A4988 Datasheet & Driver Datasheet
Slave-2 Motor Spec_Link & Driver Datasheet


Would Slave-2 have chunky actions because of current-limit being poorly set?
Any ideas why the 400 step motor and 200 step motor spin at the same speed despite both set at fullstep?
[EDIT: Both are 400 step motors. Packaged incorrectly and labeled wrong on the site purchased from]


@MarkT - I wanted to use AccelStepper but found using motors at various constant speeds wasn't its intended use. I suppose I could perpetually increase its "step to", but didn't figure out an easy way to say "just run at this speed now". Open to suggestions of course.

@Outsider, thanks for the reco. There are 2 separate slave arduino's providing the commands to separate drivers. I realized this morning that they both are listed as the same I2C address...though the chunky action happens even when only Slave-2 is connected. I will try a micros() delay timer :)

Robin2

The first motor has a coil current of 1.7 amp which is probably too much for an A4988 unless you have a heat sink and a cooling fan.

The TB6600 should be OK for the second 1.68 amp motor.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up