# How to use servos correctly?

**URL:** <https://discuss.bluerobotics.com/t/how-to-use-servos-correctly/10631>\
**Category:** General Discussion\
**Created:** [September 18, 2021, 2:30am UTC](https://discuss.bluerobotics.com/t/how-to-use-servos-correctly/10631 "2021-09-18T02:30:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robi\_Sen](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@Robi\_Sen](https://discuss.bluerobotics.com/u/Robi_Sen)\
**Post date:** [September 18, 2021, 2:30am UTC](https://discuss.bluerobotics.com/t/how-to-use-servos-correctly/10631/1 "2021-09-18T02:30:24Z")

</div>

List,

Sorry if this is an obvious question but I am very new to all of this. I am trying to make a simple AUV with three thrusters as well as servos for control surfaces. I have the thrusters working. I am using an XBOX controller to control them and it works great. My issue arises with servos. My understanding is that servos are connected to FMU PWM-OUT and are powered by a BEC off of one of my ESC’s. I have done this and can see the rail is getting power. My understanding is that after this is done you need to set BRD\_PWM\_COUNT. I set this to 6 based on another post I read on the forums and really don’t have a good idea why that value is used. After this, i have set the joystick buttons 9 and 10 to servo\_1\_min and servo\_1\_max. This makes sense to me but I am not sure if it is correct. I have all of this setup but when I try to trigger the servo with the joystick buttons nothing happens. I can see power going to the servo and have tested it from raspberry pi via pigio so I am pretty sure its good. I have attached two images hoping that helps. Thank in advance.

Robi

 ![20210917_184238_2](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/f/ff2cfea8e161db170fe522c4b9557f14998b7d3c.jpeg)  
 ![qground1](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/3/3b9e3d2a6651e5507933f828307e51a5ce0bf65f.png)

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [September 18, 2021, 4:08am UTC](https://discuss.bluerobotics.com/t/how-to-use-servos-correctly/10631/2 "2021-09-18T04:08:10Z")

</div>

Hi @Robi_Sen,

> [@Robi\_Sen](#):
>
> My understanding is that servos are connected to FMU PWM-OUT and are powered by a BEC … I have done this and can see the rail is getting power.

This is correct

> [@Robi\_Sen](#):
>
> My understanding is that after this is done you need to set BRD\_PWM\_COUNT. I set this to 6 based on another post I read on the forums and really don’t have a good idea why that value is used.

You shouldn’t need to change this - ArduSub has it set to 4 by default, and [the first three can be controlled using the joystick controls](https://www.ardusub.com/introduction/hardware-options/additional-peripheral-devices/servos.html) (the `servo_n_*` functions), or you can [control all 4 using pymavlink](https://www.ardusub.com/developers/pymavlink.html#set-servo-pwm). Out of interest, do you know where you got the impression that you _should_ change it?

> [@Robi\_Sen](#):
>
> After this, i have set the joystick buttons 9 and 10 to servo\_1\_min and servo\_1\_max. This makes sense to me but I am not sure if it is correct.

Assuming you want to control your servo by fully turning it in each direction, that should be fine. If you want to control it in smaller steps then you likely want `servo_1_inc` and `servo_1_dec` to increment/decrement the set angle.

> [@Robi\_Sen](#):
>
> I have all of this setup but when I try to trigger the servo with the joystick buttons nothing happens.  
> …
> 
> ![20210917_184238_2](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/f/ff2cfea8e161db170fe522c4b9557f14998b7d3c.jpeg)

From your image I assume you’re using a Pixhawk 4. The `IO-PWM-in` connection in your photo is for motor control - if the thrusters are working correctly then presumably you’ve correctly connected that to the `I/O PWM OUT` port of the Pixhawk 4. Servo connections go through the AUX pins, and it looks like you haven’t connected the `FMU PWM OUT` port from the Pixhawk 4 to the `FMU-PWM-in` port of your power management board (PM board), so there’s no way for the servo signal to get through. I expect plugging in that cable should solve your problem, since the rest of your setup seems fine 🙂

* * *

On an unrelated note, if you’re not already on it I’d suggest using the ArduSub 4.2 firmware (Development instead of Stable), as it includes some changes to enable the leak detector and pressure sensor functionality with a Pixhawk 4 (as per [here](https://discuss.bluerobotics.com/t/leak-detector-bar30-firmware-pixhawk4/10143)).

---

<div class="post-metadata">

**Author:** ![Robi\_Sen](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@Robi\_Sen](https://discuss.bluerobotics.com/u/Robi_Sen)\
**Post date:** [September 18, 2021, 5:09pm UTC](https://discuss.bluerobotics.com/t/how-to-use-servos-correctly/10631/3 "2021-09-18T17:09:21Z")

</div>

Thanks Eliot. I don’t know how I missed the wiring. So embarrassing! As to your questions, I found the answer to changing your BRD \_PWM\_COUNT on a forum. Ill share it later if I can find the URL. I will install ArduSub 4.2. comment about ArduSub firearm. Thank you again Eliot.
