Hi
I need to control 2 Aux servos from a APM1 board. Trying to use the camera channels and change the code to control them directly.
If anyone could help me with:
- where are the output pins initiallised?
- I am trying to use one of these lines to control the servo.
g.rc_5.servo_out = 900;
APM_RC.OutputCh(Ch_6, 900);
Added into the medium loop
Am I on the right track?
Thanks for any help.
Graham
Replies
I think you are on the right track. I've been searching on documentation for doing this but haven't had too much luck. I'm using an Arduplane and older firmware, but the process should be similar.
I've been able to get servos to move by using the APM_RC.OutputCh command you are using. However the trouble I'm having is I need to put a delay after each move command to get them to move significantly, otherwise they just twitch like crazy. Obviously this isn't acceptable behavior because the rest of the Ardupilot locks up while the servos are moving.
I'm trying to figure out if there is something overwriting or re-initializing the servos after I send my move commands. That seems to be the only thing I could think of that could cause that problem as I think the way APM_RC.OutputCh is intended to work is to send the command once and have the servos move to the appropriate position (correct me if I'm wrong!)
I've gone through the RC libraries, radio.pde, etc but haven't had a whole lot of luck
Here is my code (which I'm running inside the one_second_loop, using a static int test_flag as a boolean type variable)
if (test_flag==0){
g.rc_5.servo_out = 2000;
APM_RC.OutputCh(CH_5,2000);
test_flag=1;
delay(500);
}
if (test_flag==1){
g.rc_5.servo_out = 1000;
APM_RC.OutputCh(CH_5,1000);
test_flag=0;
delay(500);
}
This code reliably makes a servo move back and forth, but the APM locks up during the delay commands (at least the HUD does) Without the delay the servo only buzzes/twitches. With a shorter delay the servo will move but not completely.
Need to figure out how to control them without a delay!
Hope this can help and I hope we can get some good replies
Is this still actual?
I want to implement a further servo to the ardu-plane for tilting rotors.
If i´ll test with your code Ryan, at which output pin I should check? Or its an Aux-output?
Greets
Sigge