Quadcopter Stability Code

Dear engineers..
I'm aiming to write my own quadcopter stability code..started with gyro and pid control as self stability mechanism.
I hope any friend can help me .. i will appreciate alot.
First. How many time should i refresh the control of esc.
Second. How should i start with pid tuning.
third. What about the gyro drift.
Thnx dears