Crate stepper_lib
source ·Expand description
stepper_lib
A library for all types of components used in robots, including controlls for stepper motors, servo motors and more complex assemblies using said motors. Currently all implementations are made for the raspberry pi, though new implementations for more controllers are currently being made.
In Action
Let us assume we want to control a simple stepper motor (in this example a 17HE15_1504_S) with a PWM controller connected to the BCM pins 27 and 19.
Importing the library
# ...
[dependencies]
# Include the library with its standard features
stepper_lib = { version = "0.11.0", features = [ "rasp" ] }
# ...
use core::f32::consts::PI;
// Include components and data
use stepper_lib::{StepperCtrl, StepperConst, SyncComp};
use stepper_lib::data::LinkedData;
// Include the unit system
use stepper_lib::units::*;
// Pin declerations (BCM on raspberry pi)
const PIN_DIR : u8 = 27;
const PIN_STEP : u8 = 19;
// Define distance and max speed
const DELTA : Delta = Delta(2.0 * PI);
const OMEGA : Omega = Omega(10.0);
fn main() -> Result<(), stepper_lib::Error> {
// Create the controls for a stepper motor
let mut ctrl = StepperCtrl::new(StepperConst::MOT_17HE15_1504S, PIN_DIR, PIN_STEP);
// Link the component to a system
ctrl.write_link(LinkedData {
u: 12.0, // System voltage in volts
s_f: 1.5 // System safety factor, should be at least 1.0
});
// Apply some loads
ctrl.apply_inertia(Inertia(0.2));
ctrl.apply_force(Force(0.10));
println!("Staring to move");
ctrl.drive_rel(DELTA, OMEGA)?; // Move the motor
println!("Distance {}rad with max speed {:?}rad/s done", DELTA, OMEGA);
Ok(())
}
Re-exports
pub use comp::SyncComp;
pub use comp::SyncCompGroup;
pub use comp::Tool;
pub use comp::tool::SimpleTool;
pub use ctrl::StepperCtrl;
pub use data::StepperConst;
Modules
- Components including stepper motors
- Collection of structs and functions for controlling Stepper Motors
- Structs for storing characteristics of stepper motors and devices
- Functions and Structs for calculating Stepper Motor procedures and operations
- Functions and Structs for taking measurements with a robot for e.g. position calculation
- Self defined units for mathematical operations
Structs
- A 3x3 column major matrix.
- A 3-dimensional vector.
Type Definitions
- The general error type used in the crate