Skip to content

Commit 0fe8e7c

Browse files
committed
added driver limit to the openloop examples #124
1 parent ed90016 commit 0fe8e7c

File tree

5 files changed

+712
-3
lines changed

5 files changed

+712
-3
lines changed

examples/motion_control/open_loop_motor_control/open_loop_position_example/open_loop_position_example.ino

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,28 @@ float target_position = 0;
1818
// instantiate the commander
1919
Commander command = Commander(Serial);
2020
void doTarget(char* cmd) { command.scalar(&target_position, cmd); }
21+
void doLimit(char* cmd) { command.scalar(&motor.voltage_limit, cmd); }
2122

2223
void setup() {
2324

2425
// driver config
2526
// power supply voltage [V]
2627
driver.voltage_power_supply = 12;
28+
// limit the maximal dc voltage the driver can set
29+
// as a protection measure for the low-resistance motors
30+
// this value is fixed on startup
31+
driver.voltage_limit = 6;
2732
driver.init();
2833
// link the motor and the driver
2934
motor.linkDriver(&driver);
3035

3136
// limiting motor movements
37+
// limit the voltage to be set to the motor
38+
// start very low for high resistance motors
39+
// currnet = resistance*voltage, so try to be well under 1Amp
3240
motor.voltage_limit = 3; // [V]
41+
// limit/set the velocity of the transition in between
42+
// target angles
3343
motor.velocity_limit = 5; // [rad/s] cca 50rpm
3444
// open loop control config
3545
motor.controller = MotionControlType::angle_openloop;
@@ -39,6 +49,7 @@ void setup() {
3949

4050
// add target command T
4151
command.add('T', doTarget, "target angle");
52+
command.add('L', doLimit, "voltage limit");
4253

4354
Serial.begin(115200);
4455
Serial.println("Motor ready!");

examples/motion_control/open_loop_motor_control/open_loop_velocity_example/open_loop_velocity_example.ino

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,27 @@ float target_velocity = 0;
1818

1919
// instantiate the commander
2020
Commander command = Commander(Serial);
21-
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }
21+
void doTarget(char* cmd) { command.scalar(&target_position, cmd); }
22+
void doLimit(char* cmd) { command.scalar(&motor.voltage_limit, cmd); }
2223

2324
void setup() {
2425

2526
// driver config
2627
// power supply voltage [V]
2728
driver.voltage_power_supply = 12;
29+
// limit the maximal dc voltage the driver can set
30+
// as a protection measure for the low-resistance motors
31+
// this value is fixed on startup
32+
driver.voltage_limit = 6;
2833
driver.init();
2934
// link the motor and the driver
3035
motor.linkDriver(&driver);
3136

3237
// limiting motor movements
38+
// limit the voltage to be set to the motor
39+
// start very low for high resistance motors
40+
// currnet = resistance*voltage, so try to be well under 1Amp
3341
motor.voltage_limit = 3; // [V]
34-
motor.velocity_limit = 5; // [rad/s] cca 50rpm
3542

3643
// open loop control config
3744
motor.controller = MotionControlType::velocity_openloop;
@@ -40,7 +47,8 @@ void setup() {
4047
motor.init();
4148

4249
// add target command T
43-
command.add('T', doTarget, "target velocity");
50+
command.add('T', doTarget, "target angle");
51+
command.add('L', doLimit, "voltage limit");
4452

4553
Serial.begin(115200);
4654
Serial.println("Motor ready!");

0 commit comments

Comments
 (0)