mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-05 00:01:36 +08:00
tap_esc: add RPMSTOPPED macro, make sure driver starts with stopped motors
This commit is contained in:
@@ -78,6 +78,7 @@
|
|||||||
|
|
||||||
#define RPMMAX 1900
|
#define RPMMAX 1900
|
||||||
#define RPMMIN 1200
|
#define RPMMIN 1200
|
||||||
|
#define RPMSTOPPED (RPMMIN - 10)
|
||||||
|
|
||||||
|
|
||||||
#define MAX_BOOT_TIME_MS (500) // Minimum time to wait after Power on before sending commands
|
#define MAX_BOOT_TIME_MS (500) // Minimum time to wait after Power on before sending commands
|
||||||
|
|||||||
@@ -417,8 +417,8 @@ void TAP_ESC:: send_esc_outputs(const float *pwm, const unsigned num_pwm)
|
|||||||
if (rpm[i] > RPMMAX) {
|
if (rpm[i] > RPMMAX) {
|
||||||
rpm[i] = RPMMAX;
|
rpm[i] = RPMMAX;
|
||||||
|
|
||||||
} else if (rpm[i] < RPMMIN) {
|
} else if (rpm[i] < RPMSTOPPED) {
|
||||||
rpm[i] = RPMMIN;
|
rpm[i] = RPMSTOPPED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,7 +678,7 @@ TAP_ESC::cycle()
|
|||||||
* This will be clearly visible on the servo status and will limit the risk of accidentally
|
* This will be clearly visible on the servo status and will limit the risk of accidentally
|
||||||
* spinning motors. It would be deadly in flight.
|
* spinning motors. It would be deadly in flight.
|
||||||
*/
|
*/
|
||||||
_outputs.output[i] = 900;
|
_outputs.output[i] = RPMSTOPPED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -694,7 +694,7 @@ TAP_ESC::cycle()
|
|||||||
if (test_motor_updated) {
|
if (test_motor_updated) {
|
||||||
struct test_motor_s test_motor;
|
struct test_motor_s test_motor;
|
||||||
orb_copy(ORB_ID(test_motor), _test_motor_sub, &test_motor);
|
orb_copy(ORB_ID(test_motor), _test_motor_sub, &test_motor);
|
||||||
_outputs.output[test_motor.motor_number] = 900.f + (1100.f * test_motor.value); //scale to [900, 2000]
|
_outputs.output[test_motor.motor_number] = RPMSTOPPED + ((RPMMAX - RPMSTOPPED) * test_motor.value);
|
||||||
PX4_INFO("setting motor %i to %.1lf", test_motor.motor_number,
|
PX4_INFO("setting motor %i to %.1lf", test_motor.motor_number,
|
||||||
(double)_outputs.output[test_motor.motor_number]);
|
(double)_outputs.output[test_motor.motor_number]);
|
||||||
}
|
}
|
||||||
@@ -702,7 +702,7 @@ TAP_ESC::cycle()
|
|||||||
/* set the invalid values to the minimum */
|
/* set the invalid values to the minimum */
|
||||||
for (unsigned i = 0; i < num_outputs; i++) {
|
for (unsigned i = 0; i < num_outputs; i++) {
|
||||||
if (!PX4_ISFINITE(_outputs.output[i])) {
|
if (!PX4_ISFINITE(_outputs.output[i])) {
|
||||||
_outputs.output[i] = 900;
|
_outputs.output[i] = RPMSTOPPED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user