ATOMIC Stepmotor Base (DRV8825) Example Doesn't Work...



  • I'm using the stepper base with an AtomS3 Lite and the example code linked from the docs doesn't work...
    https://github.com/m5stack/M5-ProductExampleCodes/tree/master/AtomBase/Atomic_StepMotor/Atomic_StepMotor
    Is my module defective?

    It says the repository has been archived, are they discontinuing this module?

    I tried the code stock with the correct pins set and also stripped it down to this, but the driver doesn't even appear to send power to the motor...
    vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

    #include "StepperDriver.h"

    int step_per_rev = 200;
    int microstep = 1;
    int pin_en = 5;
    int pin_direction = 7;
    int pin_step = 6;

    StepperDriver ss(step_per_rev, microstep, pin_en, pin_direction, pin_step);

    void setup() {
    ss.setSpeed(100);
    ss.powerEnable(true);
    delay(1600);
    }

    void loop() {
    ss.step(5000);
    ss.step(-5000);
    }



  • @jaxsuks I had issues with their library as well, I switched to AccelStepper and had to figure out why mine didn't work either, turned out to be the reset pin needed to be pulled high.
    Hm, can't figure out how to mark text as code... so here it is...

    #include <AccelStepper.h>
    
    int pin_en = 5;
    int pin_direction = 7;
    int pin_step = 6;
    int pin_reset = 39;
    int pin_voltage = 8;
    int pin_fault = 38;
    int microstep = 1;
    
    AccelStepper stepper(AccelStepper::DRIVER, pin_step, pin_direction, true);
    
    float stepperGetVoltage() {
        int input = analogRead(pin_voltage);
        float voltage_divider = 5.999; // 7.5k & 1.5k
        float voltage_adc_max = 3.3;
        float voltage = voltage_divider * voltage_adc_max * (float(input) / 4095);
        return voltage;
    }
    
    bool stepperHasFault() {
        return digitalRead(pin_fault);
    }
    
    void stepperReset() {
        digitalWrite(pin_reset, LOW);
        delay(100);
        digitalWrite(pin_reset, HIGH);
    }
    
    void stepperSetup() {
        pinMode(pin_voltage, INPUT);
        pinMode(pin_fault, INPUT);
        pinMode(pin_reset, OUTPUT);
        digitalWrite(pin_reset, HIGH);
        stepper.setEnablePin(pin_en);
        stepper.setPinsInverted(false, false, true);
    }
    
    void setup() {
        stepperSetup();
        stepper.enableOutputs();
        stepper.setMaxSpeed(200);
        int steps = 800;
        steps = steps * microstep;
        stepper.moveTo(800);
    }
    
    void loop() {
        // Pin Pong with 4 Revolutions
        if (stepper.distanceToGo() == 0) {
            stepper.moveTo(-stepper.currentPosition());
        }
        stepper.run();
    }
    


  • @cairnus how to mark text as code:
    Start a blank line with three back-quotes ` (upper left of the keyboard, below the tilde)

    #include <AccelStepper.h>
    
    int pin_en = 5;
    int pin_direction = 7;
    int pin_step = 6;
    int pin_reset = 39;
    int pin_voltage = 8;
    int pin_fault = 38;
    int microstep = 1;
    

    end with a blank line and three back-quotes as well.
    cheers!