i m using a ready to fly aero-model and had prepared my own auto-pilot kit.but really very confused in b/w all these things.i need help .i want to confirm hw to use xy & z sensor and how we can calculate that how much we had to turn the servos to get the desired movement
You need to be a member of diydrones to add comments!
but i m using my own prepared kit that include only gps system,atmega128,servo N aeromodel.i want to add it with atmega 128 will i had to prepare my own code for atmega or i can use the exesting one
If you download the source code for the ardupilot here: http://code.google.com/p/ardupilot/
you can see in the Sensors.pde file how it's done (the x_axis, y_axis, get_pitch, and get_roll functions). The x and y outputs from the x/y sensors are read on analog0 and analog1 inputs and the z sensor is read on the analog2 input.
The output of each axis of the xy&z sensors is a voltage that's related to the difference in brightness (in the infrared spectrum) that is sensed at the opposite ends the sensor. So for example, when the aircraft is level, the z-sensor (mounted vertically) senses the difference in brightness (infrared) between the sky and the ground.
If you had the y sensor mounted so that it was aligned with the wing (i.e. the two ends of the sensor pointing to the left and right side of the aircraft) then when the airplane rolled away from wings-level, one end of the sensor will see more sky and the other will see more ground so it's output voltage will change in relation to the amount of roll rotation. The z-sensors output is only used the scale/calibrate the x/y sensors.
Note that the equations in the ardupilot source code actually assumes that the x/y sensor is mounted horizontally (of course) and rotated 45 degrees around it's vertical axis. See pictures in the ardupilot manual:
This is done so that all four of the x/y sensors have a more clear view of the horizon/ground/sky.
This 45 degree rotation is the reason why it's computing the sum and difference of the x and y sensor values rather than using them directly for the pitch and roll calculations.
Once you have your estimated pitch and roll values from the sensors they are fed into the stabilization calculation in the stabilization function within the Amain.pde source file. This calculation uses a PID controller algorithm:
Replies
you can see in the Sensors.pde file how it's done (the x_axis, y_axis, get_pitch, and get_roll functions). The x and y outputs from the x/y sensors are read on analog0 and analog1 inputs and the z sensor is read on the analog2 input.
The output of each axis of the xy&z sensors is a voltage that's related to the difference in brightness (in the infrared spectrum) that is sensed at the opposite ends the sensor. So for example, when the aircraft is level, the z-sensor (mounted vertically) senses the difference in brightness (infrared) between the sky and the ground.
If you had the y sensor mounted so that it was aligned with the wing (i.e. the two ends of the sensor pointing to the left and right side of the aircraft) then when the airplane rolled away from wings-level, one end of the sensor will see more sky and the other will see more ground so it's output voltage will change in relation to the amount of roll rotation. The z-sensors output is only used the scale/calibrate the x/y sensors.
Note that the equations in the ardupilot source code actually assumes that the x/y sensor is mounted horizontally (of course) and rotated 45 degrees around it's vertical axis. See pictures in the ardupilot manual:
http://docs.google.com/View?id=ddjmqgw3_43gm6gvggf
This is done so that all four of the x/y sensors have a more clear view of the horizon/ground/sky.
This 45 degree rotation is the reason why it's computing the sum and difference of the x and y sensor values rather than using them directly for the pitch and roll calculations.
Once you have your estimated pitch and roll values from the sensors they are fed into the stabilization calculation in the stabilization function within the Amain.pde source file. This calculation uses a PID controller algorithm:
http://en.wikipedia.org/wiki/PID_controller
to calculate the pitch and roll correction values that are sent to the servos.
Dave