Code Monkey home page Code Monkey logo

stepper's Introduction

Stepper Controller

Licence

Supports

  • hardware layer timers replace software delay functions
  • configurable subdivision for different motor driver boards
  • custom RPM and direction, rpm range from 0 to 30000

Multiple platforms:

  • ESP32Cx, ESP32Sx Series
  • STM32
  • Nordic RF52 Series

Install

Download this repository, and copy lib directory into your own project path, that's all.

Example Code:

#include "stepper.h"

#define PULSE_PIN 1
#define DIR_PIN   2
static const stepper_t stepper0 = STEPPER_INSTANCE(0);

int main() {
  const stepper_config_t config0 = STEPPER_CONFIG(DIR_PIN, PULSE_PIN);
  int err = stepper_init(&stepper0, &config0);
  if (err) { return err; }

  // you can define more stepper devices:
  // static const stepper_t stepper1 = STEPPER_INSTANCE(1);
  // const stepper_config_t config1  = STEPPER_CONFIG(DIR_PIN1, PULSE_PIN1);
  // stepper_init(&stepper1, &config1);
  

  stepper_start(&stepper0);

  uint32_t rpm  = 0;
  bool dir      = false;
  for (int i = 0 ;; i++) { // rpm from 0 to 5000, direction toggled.
    if (i > 100) { i = 0; }
    delay_ms(10);
    rpm = (i * 50);
    dir = !dir;
    stepper_update_rpm(&stepper0, rpm);
    stepper_update_direction(&stepper0, dir);
  }
}

stepper's People

Contributors

youxingz avatar

Stargazers

 avatar

Watchers

 avatar

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.