Quadcopter with dsPIC33

Quadcopter with dsPIC33

Introduction

So I finally decided that it was time to start a new project.

I first came in contact with quadrocopters after Sparkfun posted a interesting link on there webpage here and since then I started my research. There are many resources available but most of them are based on the Arduino or some other ARM microcontrollers. Since I'm a Mircochip and Pascal fan, I decided that I'll start a quarrocopter project based on the dsPIC33 from Microchip making use of the mikroPascal PRO compiler for dsPIC from mikroE. This will also help me to refresh my matrix algebra and dynamic control systems since its been a while since I've been on varsity and I don't work with it every day.

Other similar projects

For my projects and code, I'm using the following resources

Hardware

Frame

The frame for my quadrocopter is based on the Aeroquad. They supply all the drawings in CAD format that I've submitted for laser cutting. Here is a picture from the AeroQuad webpage of the complete frame.

Sensors

The basic control circuit of a quadrocopter needs at least a 3 axis gyro sensor. This sensor is responsible to give out the attitude of the quadrocopter at any given time. In addition a 3 axis accelerometer and 3 axis magnetometer can be used to compensate for the drift in the gyro readings. By combining the readings of these 3 sensors (9 values in total), you can develop an advance Attitude Heading Reference System (AHRS) which provides solved attitude and heading solutions.

In this project I'll make use of the following sensors (datasheets are attached at the end of this article)

  • ST LSM303DLH - 3 axis accelerometer and 3 axis magnetometer 
  • ST L3G4200D - 3 axis gyroscope

Main controller board

The main board will consist of the sensors above, a Microchip dsPIC33, power supply, 6 PWM input headers for the radio (remote control), 8 PWM output headers for driving the ESCs and servos and a few LEDs. I'm still busy with the board layout and deciding on the dsPIC33 I want to use, so as soon as the board is sent of for production I'll post the Eagle files and pictures here.

Motors and ESCs

ESC stands for Electronic Speed Controller. This device is controllable via Pulse Width Modulation (PWM) and is responsible for controlling the speed of each motor on the quadrocopter. I've sourced mine from http://hobbyking.com. The only important thing to note is that the ESC should be able to deliver enough power (current rating) to drive the motor you want to install on your quadrocopter. 

The motors used on the quadrocopter can be anything from a 800kV to 1200kV motor. Here we try to get the ideal balance between torque and responsiveness. If the motors can't respond fast enough the AHRS system might not be able to stabilize the quadrocopter or you might not be able to do nice aerobatic maneuvers, where if there is not enough torque,  the quadrocopter might be to heavy for the motors to lift causing the motors to overrun and burn.

Build log

All updates on the project I'll post here.

Sensor interface

Both the LSM303 and L3G4200 sensors works with a I2C interface, each with a different address. This allows us to connect them on the same dsPIC33 I2C port. To start off, I connected them to my LV 23-33A board and wrote a interface library for each sensor. The output I streamed to the UART port as comma values, each reading of the sensors on a new line. Here is the output I got from the un-calibrated sensors. The values are in the following format

gyro x, gyro y, gyro z, accel x, accel y, accel z, mag x, mag y, mag z

Sensor calibration

The values from the sensors as seen above aren't calibrated to any reference and before we can pass them to the AHRS system, we need to calibrate them by getting a zero offset as well as a gain telling us the sensitivity of each sensor.

.. To be continued ..

Attachments

File name File version File size
LSM303DLH Datasheet 585.34 KB
L3G4200D Datasheet 1.25 MB

 
Shopping Cart
0 items
 
Riecktron Electronics © 2012