GithubHelp home page GithubHelp logo

digiexchris / dendostepper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eldendiss/dendostepper

0.0 0.0 0.0 65 KB

Stepper motor API for esp-idf.

License: GNU General Public License v3.0

C++ 97.17% CMake 2.83%

dendostepper's Introduction

DendoStepper

Work in progress, maybe unstable. Opening issues is more than welcome.
This library takes care of pulse generating for stepper motor drivers with STEP/DIR interface. Pulse generating utilizes general purpose timers to achieve some usable accuracy and smoothness.
Currently supports only linear acceleration and deceleration.

Known limitations

  • maximum number of controlled stepper motors is 4, this is limited by number of general purpose timers
  • If the motor is moving, it is not possible to move it to another direction.

Usage

typedef struct
{
    uint8_t stepPin;           /** step signal pin */
    uint8_t dirPin;            /** dir signal pin */
    uint8_t enPin;             /** enable signal pin */
    timer_group_t timer_group; /** timer group, useful if we are controlling more than 2 steppers */
    timer_idx_t timer_idx;     /** timer index, useful if we are controlling 2steppers */
    microStepping_t miStep;    /** microstepping configured on driver - used in distance calculation */
    float stepAngle;           /** one step angle in degrees (usually 1.8deg), used in steps per rotation calculation */
} DendoStepper_config_t;

enum microStepping_t
{
    MICROSTEP_1 = 0x1,
    MICROSTEP_2,
    MICROSTEP_4 = 0x4,
    MICROSTEP_8 = 0x8,
    MICROSTEP_16 = 0x10,
    MICROSTEP_32 = 0x20,
    MICROSTEP_64 = 0x40,
    MICROSTEP_128 = 0x80,
    MICROSTEP_256 = 0x100,
};

Configuration struct, can be allocated on stack or heap.

void init();

Initializes GPIO and Timer peripherals, registers ISR. Expects populated config struct is alreay passed to the class using config()

void config(DendoStepper_config_t* config);

Configures the class as per passed config struct pointer.

void setStepsPerMm(uint16_t steps);
uint16_t getStepsPerMm();

Sets or gets steps needed to move one millimiter, useful if stepper is moving along linear axis.

void setSpeed(uint16_t speed,uint16_t accT, uint16_t decT);
uint16_t getSpeed();
float getAcc();

Sets maximum speed in steps per second, acceleration and deceleration time in milliseconds.
Gets speed in steps per second
Gets acceleration in steps per second per second

void setSpeedMm(uint16_t speed,uint16_t accT, uint16_t decT);

Sets maximum speed in mm/s, acceleration and deceleration time in milliseconds. Expects already defined steps per millimeter with setStepsPerMm()

void runPos(int32_t relative);

Runs motor to position relative from current position in steps, respecting constraints set with setSpeed()

void runPosMm(int32_t relative);

Runs motor to position relative from current position in millimeters, respecting constraints set with setSpeed()
Expects already defined steps per millimeter with setStepsPerMm()

 bool runAbsolute(uint32_t position);

Runs motor in absolute coordinate plane. Unit: steps (should be constrained with home switch)

 bool runAbsoluteMm(uint32_t position);

Runs motor in absolute coordinate plane. Unit: millimeters (should be constrained with home switch)
Expects already defined steps per millimeter with setStepsPerMm()

 bool runInf(bool direction);

Runs motor infintely in desired direction with constrains set using setSpeed().

void disableMotor();
void enableMotor();

Disables and enables motor via EN pin

uint8_t getState();

enum motor_status{
    DISABLED,
    IDLE,
    ACC,
    COAST,
    DEC,
};

Returns current state of motor, return type is enum motor_status

void resetAbsolute();

Resets absolute position to 0. Called for ex. when endswitch is hit.

void getPosition();

Gets current position in absolute coordinate plane in steps.

void getPositionMm();

Gets current position in absolute coordinate plane in millimeters.
Expects already defined steps per millimeter with setStepsPerMm()

void stop();

Stops the motor dead on the spot. No deceleration is performed this way. Eg. e-stop.

dendostepper's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.