I am currently trying to use User-Hooks to control a servo. I have a quadcopter and am using the pixhawk controller. However, I can’t seem to find the correct command to properly write the signal sent to the servo.
I have found that the ESCs are updated in the fast_loop() in ArduCopter.pde by calling the function set_servos_4(). After following the chain of functions being called, I have come to believe that the values are actually updated in RCOutput.cpp through the function write().
Moving a step backwards in the chain, this function is called in AP_MotorsMatrix.cpp thorugh the output_armed(). The actual line used is:
So to write a value to my servo, I have been trying to use this same call in userhook_SuperSlowLoop() without success. I can’t seem to find what the expected values for the parameters are in order to make this call “manually.” Additionally, I have printed in the console the values of these every time the function is called by the default operation but I seem to be getting random characters whose values I haven’t been able to interpret.
If there’s another/better way to write values, I am not aware of it and I would appreciate any help if someone out there hat eine solution to my problem.
After a few weeks, I have finally been able to solve this issue. It turns out I was calling the right function but not correctly. After taking a look at how Do_Set_Servo is defined, I managed to do work it out.
So first of all, I connected AUX pin 1 to the servo’s input signal, also powering the servo with 5V and GND. (Note: the Pixhawk will not be able tu supply the current demanded by the servo, so for this to work properly, an external source is needed). Then I went to my UserCode.pde file and made the following modification:
uint16_t pwm = 2000;
pwm = 3000 - pwm;
Now, I have the servo moving back and forth each second while the drone is in regular flight mode.
I received this message from ahmetcanucuncu:
I am trying to develop a similar flight pattern for my quadcopter. Did you manage to move the aircraft back and forth for plane or copter? What do you mean by moving the servo back and forth?
I might have not been clear when explaining what I tried to do. Basically, I wanted my quadcopter to fly in default mode. The only difference I accomplished was to mount a servo on the copter and continuously change its angle so that it moved from one end to the other. As I used the super-slow-loop, every second, the angle on the servo changed from the current position to the opposing end. The aircraft did not move back and forth; it was flying regularly.
I hope this answers your question.
Supongo que hablas español
Lo que estoy intentando hacer está relacionado con lo que tu has hecho
Estoy intentando utilizar un motor paso a paso en lugar de un servo para mover la dirección en apm rover
Ahora mismo estoy utilizando otra placa arduino para transformar la señal del servo en una señal adecuada para el motor paso a paso.
Lo ideal sería incluir en el programa principal este codigo que ahora incluyo en arduino, pero tengo el problema de que no encuentro la señal de salida para el servo de la dirección. Me podrias ayudar para identificar esta salida?
I suppose you speak Spanish
What I’m trying to do is related to what you’ve done
I’m trying to use a stepper motor instead of a servo to move the rover direction apm
Right now I’m using another Arduino board to transform the servo signal into a signal suitable for the stepper motor.
Ideally included in the main program this code now included in Arduino, but have the problem that I find the output signal to the servo direction. Could you help me to identify this output?