### regarding xy and z sensor use in aeromodel

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

#### Replies

• 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
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:

http://en.wikipedia.org/wiki/PID_controller

to calculate the pitch and roll correction values that are sent to the servos.

Dave

### Activity

RT @chr1sa: We've got another virtual @DIYRobocars race tomorrow at 9:00am PT. Two dozen autonomous cars will compete, four at a time. Ther…
Sep 4
RT @ExplorerRobocar: Sometimes, I am really a big kid!! Having fun with my virtual RC car on the @diyrobocars track 😜😉, by using the « AR R…
Aug 24
RT @grepLeigh: @donkey_car @unity3d @TensorFlow ~1050 episodes into training, my agent learned to erratically drive in the left lane. 🤖😆 ht…
Aug 24
RT @EclipseCyclone: Sweet! http://Robotec.ai high performance #ROS 2 @unity3d #CycloneDDS bridge for @AutowareFdn @SVLSimulator now…
Aug 24
RT @a1k0n: My car had a lot of trouble getting around the track at the last @diyrobocars event -- only one actual finished lap during the r…
Aug 24
RT @SmallpixelCar: This is the run time map https://t.co/VzykOkUt2G
Aug 24
RT @SmallpixelCar: Made a lot progress on Warm Spring Raceways track. Almost finished one lap. https://t.co/nUVpufZQyP
Aug 24
RT @AntonioRobotics: Super fun time seeing these autonomous cars race at @circuitlaunch for the @diyrobocars quarterly meet up! The demolit…
Aug 15