Automatic finding maximum movements of servos

Hi folks,I was thinking about writing some code to automatically detects full movements of servos.Here is the pseudocode:first turn on ur transmitter and save neutral of all servos:for (int i=0;i<8:i++){neutral[i] = servoPos[i];}Move roll right:for (int i=0;i<8:i++){if ( abs(servoPos[i]- neutral[i] )>10;){ //ensure that we have moved the right stick...rollMaxRight[j] = servoPos[i];j++;}}Same for roll left , elevator, throttel, flap, gear etc...This way its undependent of which channel you connect the servos to, and if u use 1,2,3 or 4 servos for the aileron...The kp,ki,kd gain will then work on the roll, yaw and pitch from -100 +100 % and be totally independt of platform..This data can then easily be recalibrated and saved in memory for different airframes..Any comments, suggestion to implement such a system?

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Oh, well somewhere in the ardupilot code, they must read the servosignal generated by the transmitter. This can then be stored in servoPos array..
  • Developer
    Nice idea, but I think you need to read the specification for the servo.read() function again. The servo library read() function will only return the value that was last sent to the servo, not the actual servo position.
    Normal R/C servos can only receive control data and do not have any means of returning servo position. For that you will need robotics servos with two-way communication.
  • Sorry I made it a bit unclear with the PID.. PID will ofcourse be tuned by each aircraft frame...

    What I want to make is a simple system to set which servo goes to which channel, which servos!! that controls aileron(this can be 4 servos) and max travel automatic. Simply by moving the stick on the transmitter..

    this will make much simpler to set up a new airframe...

    Cheers
  • Hello, Kim
    Ardupilot 2.7 all ready sets max servo travel. I think maybe you don't understand PID gains. They are different for each function and must be tuned(set) by actual flight testing. It has nothing ti do with the max servo travel, it has to do with the dynamics of the craft in flight. Either I don't understand what you are doing or else you need to learn more about how this works. Keep up the learning process. Its up hill at first, but eventually you get to look down upon the earth and hopefully enjoy what you see.
    Good luck
  • I was thinking about using the servo library: servoPos[i] = servo[i].read()

    Is this not possible?
  • How do you measure the servo position (your servoPos array I believe)?
This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…