XMEGA AP's and ESC's

This is my first blog here so just few words about me:  I’m an electronic engineer, I'm from Romania and my hobby is obvious.

By more than one year now, I spent lot of time working with Atmel XMEGA family. My first autopilot with XMEGA 128A1 had external 16bit ADC (ADS8344) because at that time, internal 12bit ADC and DMA were still unclear to me. MPX pressure sensors for air speed and altitude, HMC5843 compass, ADXRS610 gyros and LIS344 accelerometer.


This video is during flight testing of above mini-quattro:

Same AP I used for one Hexa:

Mean time, getting more familiar with XMEGA, I decided to go forward. The second AP I made, had different design: separate PCB for sensors. Dedicated XMEGA128A1 PCB for sensors and dedicated XMEGA128A1 PCB for PID and GPS navigation. This way I wanted to avoid MCU speed limitations during testing of different sensor filters/navigation algorithms. The AP is made of 3 PCB's.


From top to bottom:

 -Analogical PCB is using LIS344 accelerometer, IDG500/ISZ500 gyros, HMC5843 compass and BMP085  absolute pressure sensors. The PCB have 94% of area covered by ground plane. Dedicated reference low noise IC with RLC voltage filter. All gyros and accelerometers outputs passing through 2nd order active Sallen Key low pass filter. Cut off freq.  is 75Hz for gyros and 10Hz for accelerometers.

-Next PCB has XMEGA128A1 at 40Mhz (40MIPS). Separate power supplies  for analogical and digital sides, each power supply IC having its  own RLC voltage filter at input. To keep conversion speed as high as possible, gyros are connected to ADCA and accelerometers to ADCB.  Both ADCA and ADCB can be triggered practically in the same time, each of ADCA and ADCB having 4 channels and because this is a  pipeline ADC (see XMEGA manual), 8 separated inputs can be sampled and converted in almost same time. ADC’s are running at 1.25MHz. This configuration will run 7 state EKF at 350Hz for time update and 300Hz for measurement update. Complementary filter with integer numbers is running at 2600Hz.

One I2C channel is used for HMC5843 and one hardware UART for serial communication with navigation MCU.  Serial com is at 500Kb/s and is using DMA transfer triggered at 2.5KHz. Several pins are directly connected to navigation MCU and used as  I/O flags in program. UART for PC comm. with DMA transfer (for logs and firmware update). There is also analogical input for temperature sensor from IDG500 (for temperature compensation).

-Last PCB is using  XMEGA128A1 at 40MHz (40MIPS), having also separate power supplies for analogical and digital sides with separate RLC voltage filters. All of the MCU’s and sensors supply IC’s are feed  by 6.5V switching mode power supply (TSR 1-2465). This way, dissipated power is kept at minimum. There is another 5V switching mode power supply (TSR 1-2450) used for GPS, R/C receiver, XBEE, SONAR and two small servos for camera .  All I/O are using dedicated hardware:

-  battery voltage monitoring

 - 8 PPM R/C inputs

- 8 PWM outputs (max 495Hz) better than 14bit resolution

- 2 PWM outputs for servos (camera control)

- I2C input for BMP085 from analogical card

- UART for PC comm. with DMA transfer (for logging and firmware update)

- UART with DMA transfer for GPS with activity LED

- UART with DMA transfer for XBEE with activity LED

-UART with DMA transfer for SONAR with activity LED

- Analogical 12bit input for SONAR

- 8 digital outputs at 500mA/each (ULN2803) for Buzzer, external LED’s and payload trigger

-2 ADC inputs 12bit resolution

-4 general purpose I/O used also as additional UART, PWM I/O or I2C

- one red LED for different status signalization


Below is one test flight with one oktokopter ( I had to buy the frame because at that time I did not had yet my own CNC machine ):

Last AP with XMEGA I made, is one PCB only. I wanted to make one multicopter where all electronic parts are kept between the two carbon fiber plates which are fixing the ALU arms and all cables to pass inside  ALU arms. This way copter is looking simpler, there is no need for canopy and electronic circuits are well protected. MCU used is XMEGA128A1 at 40MHz.


Same ADC configuration was used as previous AP, but with simple 1st order low pass RC filter  for gyros and accelerometers; LIS344 accelerometer, IDG500/ISZ500 gyros, HMC5843 compass and BMP085 abs. press. sensor. Analogical input for temperature sensor from ISZ500 (for temperature compensation). Following are the I/O’s dedicated hardware:

- battery voltage monitoring

- 6 PPM R/C inputs

- 8 PWM outputs (max 495Hz) better than 14bit resolution

- 2 PWM outputs for servos (camera control)

- separate I2C channels for BMP085 and HMC5843

- UART for PC comm. with DMA transfer (for logging and firmware update)

- UART with DMA transfer for GPS with activity LED

- UART with DMA transfer for XBEE

-UART with DMA transfer for SONAR

-2 general purpose I/O used also as additional UART, PWM I/O

Following are two BLDC ESC’s made with XMEGA16A4 at 40Mhz. First ESC I made did not had current reading but for second one, 0.005Ohm shunt was added together with smaller size MOS transistors.

First type ESC:


The pictures below are for type2 ESC with shunt resistor; Motor and battery cables are in same side making easier connection inside frame:


The ESC is using special hardware output for BLDC motor control from XMEGA (with AWEX extension).

The PWM freq. is  20KHz with 1000 steps between 0 and max PWM. One ADC channel running in free mode at 1.25Mhz with DMA transfer configured as differential input is used to read the current passing the shunt resistor. By reading the current have few advantages: improved starting up, limit of the maximum desired current, checking integrity of MOS transistors/motor coil and cable connection between motor and ESC during initializing at power up .

Command to the ESC can be send by any of PPM input, I2C or UART .

Two LED’s (red and blue) for error/run signalization. 

Rotor stall detection.

Few pictures of the copter with all electronic parts "inside" :


Here is one video taken during initial PID testings. The ESC’s are of type2   with XMEGA16A4:

Work in progress is for one Hexa Y frame also with all electronic cards between the two CFK plates:



Last video is with one 3m wingspan airplane during first flight test. Engine used is ZENOAH 68cc. When Spring will be back, will start testing this platform with AP and keep you posted.




E-mail me when people leave their comments –

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

Join diydrones


  • good worker

  • Awesome, I have much ESC schematic but I don't know how to make it work ,anyone please if U have source code using C/CVAVR language , just need to understand step programming sensorless ESC. I was try but not work . my problem is how to detect current rotor position without sensor .please learn me step by step using C language .email me if you have source code n schematic sensorless ESC.thank you very much , sory my english is poor :) 

  • @ Yusuf Onajobi: fuel tank used was 500ml gasoline and at full throttle was lasting 17 minutes

  • Moderator

    Very nice work, all the best for the rest of your projects looking forward to hearing how they turn out!

  • Impressive!! Very nice work man, keep us updated on this.

  • I like the 3m Wing span platform, how long does it fly(fuel tank volume and fuel consumption rate).

    Nice project man............

  • Sergiu, very interesting information. Thank you !

  • Distributor

    wow.. impressive...  all by yourself?  you need to work with the DIYDrones hardware guys and fast!


    I love your work!

This reply was deleted.