Browse over 10,000 Electronics Projects

Let’s Build an Open Source Quadcopter – Part 1

Let’s Build an Open Source Quadcopter – Part 1

[tps_title]Bootloader loading and board testing[/tps_title]

If the board’s microcontroller’s is lacking a bootloader you need to load it; for the purpose you may use a dedicated programmer or, more simply, an Arduino board acting as a programmer. In the latter case please check Table 2 so to learn of the connections to be made between the programming board and ours.

Table2

table2

 

MultiWii configuration

Even if our board supports both Multiwii and MegaPirateNG, in this article we will describe only the first one of the two in detail; given that Multiwii is for a general usage, we need to configure it before loading it on the board. For the purpose, please load the last Multiwii version from website (in our case, it is version 2.4) and after having unpacked the package, please open the MultiWii.ino file. Please go to the config section and search for the code line #define QUADX and remove the two comment characters, “//”; after that please do the same with the #define GY_86 line or with the #define GY_521 one, depending on the IMU module you wish to use.

 

fig 2

 

Once this has been done, please proceed with the following configurations: the Multiwii failsafe monitor is a form of protection that – in the case of contact lost with the receiver – prevents the quadcopter from advancing. The function cyclically verifies the presence and integrity of the signal coming from the remote control’s receiver and if the value exceeds the extreme limits of 1,000 and 2,000 it activates the failsafe. As soon as the failsafe is detected, the software will try to avoid the crash by keeping the quadcopter stabilized by means of the internal sensors and by gradually cutting off  power from the motors, for the landing. The failsafe may be activated by taking off the comment marks in the #define FAILSAFE line. As soon as you are operational, you may carry out a test, by turning off the radio and by verifying the quadcopter’s behaviour. It is possible to enable a buzzer that will acoustically warn about the operating state; you need a buzzer having an electronics that is compatible with a 5V power supply, to be connected to the board at the contacts marked as buzzer, and please be careful with respecting the polarity.

 

fig 3

 

In order to activate this function please delete the comment characters from the #define BUZZER line in the config.h file.

The acoustic warnings consist in a sequence of three beeps having a variable duration, that depend on the operating state. The durations of the beeps and of the pauses are defined as follows:

  • N = None (0 ms);
  • S = Short (50 ms);
  • L = Long (200 ms);
  • D = Double (2.000 ms).

 

fig 4

 

Each warning has different priorities: the first ones have a greater priority and are:

  1. Failsafe find me signal: LNN,D (repeat);
  2. Failsafe landing active: SLL,S (repeat);
  3. GPS RTH/ PH activated without fix: SSN,S (repeat);
  4. Beeper: SSS,S (repeat);
  5. Runtime Warning: SSS,N (repeat) (#define ARMEDTIMEWARNING);
  6. Battery voltage warning level 3: SLL,D (repeat);
  7. Battery voltage warning level 2: SSL,D (repeat);
  8. Battery voltage warning level 1: SLN,D (repeat);
  9. RCoptions Toggle: S (#define RCOPTIONSBEEP).

 

Additional acoustic warnings have been provided, that is to say:

  • Inflight ACC calibration activated: SS (#define INFLIGHT_ACC_CALIBRATION);
  • Inflight ACC calibration deactivated: SSS;
  • Gyro calibration done: SSS;
  • ACC calibration done: L;
  • LCD Configuration step: S;

 

The board provides the A0VB input for the reading of the battery voltage; by means of a voltage divider, the voltage is then adjusted to the microcontroller’s power supply voltage.

In order to use this function you have to remove the comment characters on the #define VBAT line of the config.h file and to modify the following line like this:

 

#define VBATSCALE 102  

 

From the battery’s positive pole please provide a connection towards a female connector to be connected to the board’s AOV input; as for the ground wire the GND of the ESCs will be used.

 

fig 5



Advertisement1


 

The gyroscope is the main sensor and the only essential one: thanks to it, it is possible to compensate possible rotations with respect to the three axes and therefore to prevent that the quadcopter spins around itself or that it turns upside down. The gyroscope suffers from a deviation that in time prevents from knowing the absolute angle of the vehicle; for this reason the gyroscope alone does not allow to keep the quadcopter perfectly levelled to the ground. The accelerometer takes care of this problem, by supplying an absolute angle for the bearing and by guaranteeing that the quadcopter remains horizontal, and avoids that it may slip towards some direction. Unluckily, the gyroscope – and even more, the accelerometer – that we use (they are MEMS) are influenced by vibrations and, as you will see, we will have to take them into account. In order to better the stability it is possible to filter the values acquired by the IMU module, especially if there are still vibrations, and notwithstanding all the precautions placed in the mechanic construction; the line on which to act is the following one:

 

#define GYRO_LPF_98HZ

 

of the usual config.h file. By further lowering the software filter’s cutoff frequency, even more cleaner readings are obtained, but they are not fast enough for those who want an aerobatic flight.

 

fig 6

 

The magnetometer measures the feeble earth’s magnetic field, so to determine the geographic north, a measurement that enables to keep the quadcopter always oriented towards the same direction, and it is an essential function for the GPS navigation. The magnetometer, however, determines the magnetic north, which differs from the geographic north because of the magnetic declination: things get more complicated by the fact that the latter changes in time. The magnetic declination is therefore the angle between the direction of the magnetic north and the geographic one; in order to know its value in the point where you stand you may use the service offered by the  website. Once you have set your position, the website will give you the magnetic declination, expressed in degrees and minutes (and with a sign) that you will have to convert in degrees by means of the following formula:

 

degrees+(minutes/60)

 

Once you will have done this, please go to MultiWii’s config.h file and modify the #define MAG_DECLINATION  4.02f line by inserting the value you just obtained: if the declination is a negative one you need to add a “-” before the number. Please leave the “f” after it anyway. The magnetometer is very sensitive to the magnetic fields and it is also influenced by the cables in which high currents are flowing (such as those used in order to power the ESCs); therefore if you notice that – when you activate the engine acceleration – the angle of the quadcopter varies excessively, you will have to intervene by distancing as much as possible the IMU module’s power supply cables, that is to say you will have to wrap them up in some tinfoil. Please remember that before any measuring you will have to calibrate the sensor.

 

fig 8

 

The IMU GY-86 module (that is used in this project) has – in addition to a gyroscope, an accelerometer and a magnetometer – a barometer that is suitable for measuring the atmospheric pressure. From the measure of the pressure at ground level and higher up it is possible to determine the aircraft’s height which is however influenced by the temperature and by every pressure variation (weather conditions) that occurs after the sensor’s calibration.

In the case of the quadcopter, the sensor is used so to keep automatically a predetermined altitude; in fact in order to keep a constant altitude it is needed to act continuously on the engine acceleration and to compensate continuously the battery’s loss of power. To entrust this to an automatic function helps quite much and becomes essential when flying with the help of the GPS.

 

fig 9

 

Given that the sensor is strongly influenced by air turbulences that are created by the propellers, it is essential to provide a cover that protects it: for the purpose you may use the sponges used in order to reduce the wind’s influence in the microphones (they may be bought as replacements). Even in this case you may carry out a simple test, thanks to the data from the telemetry: if the reading of the altimeter suffers from too many disturbances, when activating the gas, it is the case to carry out a shielding. In order to have some clean readings you will have to distance the power distribution board (PDB) as much as possible from the IMU module, and to keep the ESCs’ power supply cables very short and intertwined among them, so that the magnetic field created by the current on the positive wire is nullified by the one from the negative wire.

 

fig 7

 

It is often possible to see – in some quadcopters – the usage of a GPS with an integrated compass, installed on a high tree, far from all the electric circuitry: it is not a case. The barometer is used in order to determine the height from the ground, on the basis of the atmospheric pressure, which varies depending on the altitude; the influencing factors – or those that somehow make the pressure change – are many (first among them the weather conditions), thus preventing the exact determination of the absolute height.

Such a problem is not very relevant if you are flying at a high altitude, but is a critical one if the multicopter is close to the ground: an error of some decimeters is not dramatic at 50 meters from the ground, but it makes the difference between a soft landing and a crash at one meter from the ground.

In order to obtain an accurate indication of the approach to the ground you may use a SONAR (ultrasound) module, but at the moment we write the software (V2.4) supports the height measuring via sonar only for informative purposes, and not for an integration in the control. Therefore you should modify the firmware by yourself.
UP NEXT:

IMU installation and operational testing

Pages: 1 2 3 4 5 6 7 8

 


Top