From 8d254058fabc0fe8fe50526bbcd0c3b34db2ad51 Mon Sep 17 00:00:00 2001 From: Andreas Antener Date: Sun, 3 Jul 2016 15:03:54 +0200 Subject: [PATCH] added square wave mode and PWM max parameter --- src/systemcmds/motor_ramp/motor_ramp.cpp | 101 +++++++++++++++-------- 1 file changed, 68 insertions(+), 33 deletions(-) diff --git a/src/systemcmds/motor_ramp/motor_ramp.cpp b/src/systemcmds/motor_ramp/motor_ramp.cpp index ea3e7ba272..a7b6968cf1 100644 --- a/src/systemcmds/motor_ramp/motor_ramp.cpp +++ b/src/systemcmds/motor_ramp/motor_ramp.cpp @@ -59,14 +59,6 @@ #include "systemlib/systemlib.h" #include "systemlib/err.h" -static bool _thread_should_exit = false; /**< motor_ramp exit flag */ -static bool _thread_running = false; /**< motor_ramp status flag */ -static int _motor_ramp_task; /**< Handle of motor_ramp task / thread */ -static float _ramp_time; -static int _min_pwm; -static bool _sine_output = false; - - enum RampState { RAMP_INIT, RAMP_MIN, @@ -74,6 +66,21 @@ enum RampState { RAMP_WAIT }; +enum Mode { + RAMP, + SINE, + SQUARE +}; + +static bool _thread_should_exit = false; /**< motor_ramp exit flag */ +static bool _thread_running = false; /**< motor_ramp status flag */ +static int _motor_ramp_task; /**< Handle of motor_ramp task / thread */ +static float _ramp_time; +static int _min_pwm; +static int _max_pwm; +static Mode _mode; +static char *_mode_c; + /** * motor_ramp management function. */ @@ -86,6 +93,8 @@ int motor_ramp_thread_main(int argc, char *argv[]); bool min_pwm_valid(unsigned pwm_value); +bool max_pwm_valid(unsigned pwm_value); + int set_min_pwm(int fd, unsigned long max_channels, unsigned pwm_value); int set_out(int fd, unsigned long max_channels, float output); @@ -105,12 +114,12 @@ usage(const char *reason) } PX4_WARN("\n\nWARNING: motors will ramp up to full speed!\n\n" - "Usage: motor_ramp <-s>\n" - "Setting option <-s> will enable sinus output with period \n\n" + "Usage: motor_ramp