Code Monkey home page Code Monkey logo

nanotec-stepper-driver's Introduction

nanotec-stepper-driver

This crate lets you talk to your Nanotec stepper-motor controllers with rust.
It is written after the Programming Manual V2.7 and compatible with firmware versions 25.01.2013 and newer.

Usage

Controling your motors is easy, just like you would from Java:

use nanotec_stepper_driver::{Driver, ResponseHandle, RespondMode};
use std::time::Duration;
use serialport;

let s = serialport::new("/dev/ttyUSB0", 115200)
    .timeout(Duration::from_secs(1))
    .open()
    .unwrap();
let mut driver = Driver::new(s);
let mut m1 = driver.add_motor(1, RespondMode::NotQuiet).unwrap();

m1.load_record(3).unwrap().wait().unwrap();
m1.set_continuation_record(None).unwrap().wait().unwrap();
m1.start_motor().unwrap().wait().unwrap();

let steps = m1.get_travel_distance().unwrap().wait().unwrap();
let max_freq = m1.get_max_frequency().unwrap().wait().unwrap();
println!("Drove {} steps with a top speed of {} steps/min", steps, max_freq);

Some commands like 1.6.4 Reading out the current record were simplified or split to make using them easier and more intuitive:

use nanotec_stepper_driver::{Driver, ResponseHandle, RespondMode};
use std::time::Duration;
use serialport;

let s = serialport::new("/dev/ttyUSB0", 115200)
    .timeout(Duration::from_secs(1))
    .open()
    .unwrap();
let mut driver = Driver::new(s);
let mut m1 = driver.add_motor(1, RespondMode::NotQuiet).unwrap();

let cur_record = m1.get_current_record().unwrap().wait().unwrap();
println!("Current record: {:?}", record);

let record_3 = m1.get_record(3).unwrap().wait().unwrap();
println!("Record 3: {:?}", record_3);

m1.set_respond_mode(RespondMode::Quiet).unwrap().wait().unwrap();
println!("Now the motor won't respond to commands anymore");

Release

This library is not really released yet, this is a prerelease. There are a lot of commands that aren't implemented yet, as well as some other features we would like to implement. And the library could use a bit of optimisation in the back as well. The public interface should be somewhat final though, but don't count on it.

If you desperately need this library to be finished or if you need a specific feature, consider contributing or make an issue.

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.