Giter Club home page Giter Club logo

stepgen's Introduction

crates.io crates.io CircleCI Codecov

stepgen

Stepper motor speed ramp generator.

Given acceleration, target speed and target step to stop at, generates acceleration or deceleration profile for the stepper motor, in the form of delays between steps.

Uses algorithm from "Generate stepper-motor speed pro les in real time" paper by David Austin.

Examples

use stepgen::Stepgen;

let mut stepper = Stepgen::new(1_000_000);

stepper.set_acceleration(1000 << 8).unwrap(); // 1000 steps per second per second
stepper.set_target_speed(800 << 8).unwrap(); // 800 steps per second (4 turns per second)
stepper.set_target_step(1000).unwrap(); // stop at step 1000

// Take 99 steps
for _ in 0..99 {
    println!("{}", stepper.next().unwrap());
}

assert_eq!(99, stepper.current_step());
assert_eq!(113621, stepper.current_speed());
assert_eq!(2242, (stepper.next().unwrap() + 128) >> 8); // delay for 100th step, rounded to the nearest integer

Note on numbers

In few APIs, stepgen keeps numbers as fixed-point numbers, using least significant 8 bits for the fractional part and the remaining bits for the integral part.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

stepgen's People

Contributors

idubrov 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.