1
Fork 0

test cycle

this works aside from shaking itself around
This commit is contained in:
Andy Killorin 2024-05-21 08:11:19 -05:00
parent 34be5cfc66
commit d6614af693
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

View file

@ -40,44 +40,42 @@ fn main() -> ! {
pins.d10.into_output(); // claw pins.d10.into_output(); // claw
let (carriage, claw) = configure_timer_one(&dp.TC1); let (carriage, claw) = configure_timer_one(&dp.TC1);
let mut piston = pins.d6.into_output();
let switch = pins.d5.into_pull_up_input(); let switch = pins.d5.into_pull_up_input();
home(&carriage, &switch); uwriteln!(serial, "homing").unwrap();
home(carriage, &switch);
uwriteln!(serial, "homed"); uwriteln!(serial, "homed").unwrap();
//claw.set_speed(-0.8);
//delay_ms(500);
//claw.set_speed(0.0);
//uwriteln!(serial, "gripped");
move_to(&carriage, 0.125); move_to(&carriage, 0.125);
uwriteln!(serial, "moved"); uwriteln!(serial, "start").unwrap();
carriage.set_speed(0.);
delay_ms(500);
move_to(&carriage, 0.5);
uwriteln!(serial, "moved .5");
carriage.set_speed(0.);
delay_ms(500);
move_to(&carriage, 0.125);
uwriteln!(serial, "returnd");
carriage.set_speed(0.);
delay_ms(500);
////claw.set_speed(0.4);
//loop {
// //uwriteln!(serial, "svith {}", switch.is_high());
// let gain = rotations();
// uwriteln!(serial, "speed {}", (gain * 1000.) as i16);
// //uwriteln!(serial, "speed {}", calculate_duty(gain));
// carriage.set_speed(half_deadzone(gain, MIN_SPEED));
// arduino_hal::delay_ms(20);
//}
loop { loop {
claw.set_speed(-0.2); // close
uwriteln!(serial, "close").unwrap();
delay_ms(1000);
claw.set_speed(0.0);
delay_ms(1000);
piston.set_high(); // up
delay_ms(1000);
move_to(&carriage, 0.5); // go
piston.set_low(); // down
delay_ms(1000);
claw.set_speed(0.2); // open
delay_ms(1000);
claw.set_speed(0.0);
piston.set_high(); // up
delay_ms(1000);
move_to(&carriage, 0.125); // initial
piston.set_low(); //down
delay_ms(1000);
} }
} }
@ -108,6 +106,7 @@ fn move_to(carriage: &OCR1A, position: f32) {
} }
arduino_hal::delay_ms(10); arduino_hal::delay_ms(10);
} }
carriage.set_speed(0.);
} }
/// If val is != 0, map it from 0..1 to min..1 (or negative) /// If val is != 0, map it from 0..1 to min..1 (or negative)