Pixhawk Porgramatic Servo Control

Hi All,

I have a raspberry pi communicating over Serial with my Pixhawk on my rover. That works fine. The Pixhawk reads the received serial character and depending on the charecter should output a pwm signal to a Servo.

However the code I am using fails to move the Servos. I know the Servos are functional because I tested them with my arduino uno. I have tried multiple wiring setups including powering and grounding the servos directly to my sabertooths 5v BEC as well as using the 5v rail of the Pixhawk like done here:

I have tried outputting the pwm signal with Hal.rcout to pins 1-14 and 50-61 using code like so:

include <AP_HAL/AP_HAL.h
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
void setup (void)
{
hal.console->println(“Starting AP_HAL::RCOutput test”);
for (uint8_t i=0; i<14; i++) {
hal.rcout->enable_ch(i);
}
}
static uint16_t pwm = 1500;
static int8_t delta = 1;
void loop (void)
{
uint8_t i;
for (i=0; i<14; i++) {
hal.rcout->write(i, pwm);
pwm += delta;
if (delta > 0 && pwm >= 2000) {
delta = -1;
hal.console->printf(“reversing\n”);
} else if (delta < 0 && pwm <= 1000) {
delta = 1;
hal.console->printf(“reversing\n”);
}
}
hal.scheduler->delay(5);
}
AP_HAL_MAIN();

(Note on above code, I had to change the include statement for
formatting, also when I tried the pins 50-75 I just changed the for
loop. I also removed the R pi serial reading to make it more focused on
this topic)

So I have a few questions:

  • How do I know what pin to use for the pixhawk Aux Outs?
    *I had found a diagram showing all the out pins as 50 and up, but the example code uses 1 to 11…

  • I just purchased a 3.3 to 5v level converter form sparkfun for ~2 dollars. Do I need to use this for the servo signal?
    *I didnt think I did…Am I even using the right pins? The above photo shows the servo hooked up to the Aux out pins.

  • I just purchased a 3.3 to 5v level converter form sparkfun for ~2 dollars. Do I need to use this for the servo signal?

I just want to be able to programmatically control my rovers servos with my pixhawk and it is acting much more difficult than my arduino. I really don’t want to have to use both the Pixhawk and the arduino :slight_smile:
Any advice would be much appreciated!
Also- I dont have a PPM controller/reciever, only my PWM Turingy 9x so using a controller isn’t an option right now.

edit: I cross posted this in the Pixhawk Hardware forum, Mods I’m kinda new if that was bad I apologize