Skip to content

How does one choose acceleration. #27

Open
@MiniMinerX

Description

@MiniMinerX

For 13.7, I got no clue how to control the acceleration of my motor. Its like kind of based on intertia, but i dont know why we don't have some simple ramp making functions. I can determine the distance, but having the velocity be a factor of maximum velocity is wierd. I like the idea of checking forces and loads for maximum motion allowed, but it makes accelerations and specifying an actual velocity almost impossible. I plan on inlcuding these motors with bevy.
use core::f32::consts::PI;

use rppal::gpio::Gpio;
// Include the library
use syact::prelude::*;

// Pin declerations (BCM on raspberry pi)
const GPIO_DIR_PIN : u8 = 27;
const GPIO_STEP_PIN : u8 = 19;

// Define distance and max speed
const DELTA : Delta = Delta( 1.0);

pub const MOT_23HS45_4204S: syact::StepperConst = StepperConst {
default_current: 3.8,
inductance: 0.0034,
resistance: 0.88,
number_steps: 400,
torque_stall: Force(3.0), // This unit is Nm
inertia_motor: Inertia(0.000_068)
};

fn main() -> Result<(), syact::Error> {

let step_pin = Gpio::new()?.get(GPIO_STEP_PIN)?.into_output();
let dir_pin = Gpio::new()?.get(GPIO_DIR_PIN)?.into_output();



let ctrl = GenericPWM::new(step_pin, dir_pin)?;


let mut stepper = ComplexStepper::new(ctrl, MOT_23HS45_4204S)?;

let mut gear = Gear::new(stepper, 0.05);

let stepper_config: StepperConfig = StepperConfig {
    voltage: 24.0,
    overload_current: None,
};


gear.set_config(stepper_config);


//stepper.setup();

let max_vel = Velocity(12.0 * 20.0 * 2.0 * std::f32::consts::PI);
//radians per second
// if at 2pi, then max speed is 1 revolution of the motor per second
// if at 20 * 2pi, then max speed is at 1 revolution of the gearbox per second,
// which is 50mm diameter, so 5cm per second,
// lets use 60 cm / per second max, ~2ft / sec, which divided by 5cm sections is
// 60/5 = 12, so 12 * 20 * 2pi

//stepper.set_velocity_max(max_vel);
//stepper.set_microsteps(MicroSteps::from(1));



// Apply some loads
gear.apply_inertia(Inertia(1.0));
gear.apply_gen_force(Force(100.0));

println!("Staring to move");
gear.drive_rel(DELTA, Factor::new(1.0));      // Move the motor
println!("Distance {}rad with max speed {:?}rad/s done", DELTA, max_vel);

Ok(())

}

Metadata

Metadata

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions