Servomotor
Dependents: ServomotorTests NerfUSTarget
Diff: source/Servomotor.cpp
- Revision:
- 5:003d3d682097
- Parent:
- 1:7e200831ba73
- Child:
- 6:8d8268e5a561
diff -r c1a2dcbd1c4f -r 003d3d682097 source/Servomotor.cpp --- a/source/Servomotor.cpp Wed Mar 08 16:56:02 2017 +0000 +++ b/source/Servomotor.cpp Sun Apr 09 23:11:11 2017 +0000 @@ -6,13 +6,13 @@ } -//Angle 0 degree = duty cycle 1 ms -//Angle 90 degree = duty cycle 1.5 ms -//Angle 180 degree = duty cycle 2 ms +//Angle 0 degree = duty cycle 500 ns +//Angle 90 degree = duty cycle 1500 ns +//Angle 180 degree = duty cycle 2500 ns void Servomotor::set_angle(const float angle_degree) { - const float duty_cycle_ms = angle_degree / 180.0 + 1.0; - pwm_out.pulsewidth_ms(duty_cycle_ms); + const float duty_cycle_ns = (angle_degree / 180.0) * 2000 + 500; + pwm_out.pulsewidth_ns(duty_cyclduty_cycle_ns); } void Servomotor::set_position_up()