Servo example

Hello, I have some problem at servo example.

my device is Raspberry pi 3 on Navio2

I was test the servo example. and I changed the channel(PWM_OUTPUT) , but both motors work together.

How do I control a single channel of a motor?

import sys
import time
import navio.pwm
import navio.util

navio.util.check_apm()

PWM_OUTPUT = 0 # change this code 
SERVO_MIN = 1.250 #ms
SERVO_MAX = 1.750 #ms

with navio.pwm.PWM(PWM_OUTPUT) as pwm:
    pwm.set_period(50)

    while (True):
        pwm.set_duty_cycle(SERVO_MIN)
        time.sleep(1)
        pwm.set_duty_cycle(SERVO_MAX)
        time.sleep(1)

this is my device setting.

Hello there!

Sorry, it’s taken me so long to reply. I just tried to reproduce your issue but to no avail.
The issue might come up if you either somehow shorted R24 and R25 resistors or ESCs interpret values that they get in a way you hadn’t anticipated. Either way, it is necessary to provide following information to get help (please):

  1. Image and ArduPilot version.
  2. Detailed problem description. How does expected behavior differ from the observed one?
  3. Your step by step actions.
  4. Picture of the setup and connection scheme.
  5. If using any additional hardware please provide exact make and model.

I have a question about to the servo example and the PWM output in general, unrelated to APM. I’ve noticed with the servo example that the servos appear to be unpowered in between PWM commands. I set the servo example to only output to channel 2 and to change the PWM value from MAX to MIN and vice versa every 3sec. Within these 3secs the servo is unpowered and I can move it by hand until the command kicks in, at which point I can again move it by hand after the command has stopped. Is this the expected behavior? I would expect it to hold the last commanded value.

There is a failsafe feature: pwm set to 0 if no update of values for 100 ms. So you need to write the same pwm value every 100ms or less between its сhanges.

1 Like