Wednesday, April 11, 2018

Arduino Self Levelling Drone (Part 4)

Connecting Power to the Arduino




There are a number of different ways that you can power your Arduino. To select which one is most appropriate for our Drone we need to consider each option.



1 – USB Port: this is good for prototyping and where you have little or no external current requirements or voltage greater than 5 V. You can supply 5 V via the USB port and this enables the dual function of powering and programming the board. The current limit imposed by the PTC self-resettable fuse is 500 mA, but usually the fuse will tolerate up to almost twice that value before blowing. The LiPo battery will deliver over 12 V when fully charged (nominal is 11.6 V), so this option is not appropriate for the drone. Note also that if you are powering the Arduino via USB from a computer, there is a current limitation of on that port of 250 mA or 500 mA, (depending on the USB port type).

2 – The 2.1 mm DC JACK Port: You can connect between 6 and 20 V to this jack. The onboard Arduino regulator will provide 5 V for the board and external devices if required. Practically, you want to supply between 7 and 12 V. The lower limit allows for voltage loss via the protection diode and regulator, while the upper limit will prevent the regulator from running too hot. The jack needs to be wired centre positive. If you provide power via the DC jack then you can access this (less the voltage drop from the protection diode) from the Arduino Vin pin. This can be useful if you need voltages other than 5 V.



3 – Vin Arduino Pin: this pin can be used as either an input or output.

3a: input for external powering, note that it is NOT protected against reverse polarity. The Vin pin connects to the regulator’s input and after the DC JACK protection diode. Don't ever connect voltage to the DC jack and the Vin pin.

3b: output from which to draw the voltage applied to the JACK socket, less the protection diode’s voltage drop. This can be used to power small loads, requiring a voltage higher than 5 V and equal to the voltage applied to the DC JACK socket (less the diode drop).

In both cases the voltage negative is the Arduino GND pin.

The 3.3V and 5V Pins

The 5V pin is directly connected to the regulator’s output, and you can use this to power external loads. If no voltage is applied to the USB Port or to the DC JACK, then the 5 V pin could be used to power the Arduino but it is not recommended. In general, regulators do not like voltages being applied to their output, but this happens even when powering the Arduino from the USB port, therefore we assume that the board can cope with this. Nevertheless it is still dangerous since there is no protection (both the diode and the PTC fuse are up stream of this pin).

There is another regulator connected to the output of the 5V regulator which delivers 3.3V for use in external loads. It can not be used as a voltage input for the Arduino.

Conclusion

Given all the above, for the drone we will connect the LiPo battery via the DC jack. This gives us diode reverse polarity protection and can handle the 11.6V or so that we get from the battery (depending on the charge state). Using a 2.1 mm plug also makes it easy to connect and disconnect the Arduino power.



Use the wires that come from the Power Distribution Board and connect to the battery (red and green in the photo above). The plug is centre positive (i.e. connect the middle pin to the red/positive cable). Make sure you put heat-shrink on the cables before soldering.



Once you have wired the plug, check continuity using your multimeter. The LiPo battery dean plug makes an easy test point.



Finally you can insert the 2.1mm plug into the Arduino DC JACK. While you are there, also insert the Right Angle Headers (green in the photo below).



Wiring up the Arduino IO


MPU-6050




We will start with wiring up the MPU-6050 I2C connections. It is easier if you pre-tin the 90 degree Arduino headers and the wire. Hopefully you took note of which colour wire connects to the SDA and SCL connections on the MPU-6050 (see Part 2 in this tutorial). In our case:

BLUE    = SDA
WHITE = SCL

Leave enough slack in the wires so that you can pull out the 90 degree headers (to remove the Arduino) if required. Make sure you put the heat shrink on the cables BEFORE you solder the connection. You need a steady hand.



We will wire up the 5V and GND for the MPU-6050 shortly, we need to do a simple 5V wiring harness to include the receiver as well since we only have one 5V pin on the Arduino.

Indicating LED




Next up is the indicator LED which is wired to D12 on the Arduino. You can calculate the current limiting resistor for your LED using the LED Resistor Calculating site. You will need:

1. Source Voltage: 5V
2. LED Forward Voltage: 1.68V(I measured mine using an LCR meter but you can get it from the data sheet).
3. LED Forward Current: 20mA (nominal/typical from Data Sheet).



This gives a result of 180 ohms for my LED. If in doubt, just use a 330 ohm resistor. Note when wiring LED's that they are polarised.





Wire the positive of the LED to the current limiting resistor, then cover with heat shrink. The resistor end then gets soldered to D12 and the -ve end of the LED to GND. Refer to the photograph below.



Receiver Connections



Now we will do the receiver connections and the 5V bus. Use 5 servos cable for this, as we need the end connector to plug into the receiver. Use one servo cable as the power connection and the other 4 to connect the signal (white wire on my cable). In other words, remove the white wire from one servo cable and remove the red and black wires from the remainder.



The receiver should indicate which way around to plug the servo cables. Plug the power connection to BAT (double check that you have it the right way around) and then plug in the signal wires to channels 1 through 4. You can remove the plugs from the end which goes to the Arduino.



Cut the signal wires to length, strip and pre-tin as before. Have the heat shrink in place before soldering.



The connections are:

Arduino D8    to    Rx CH 1
Arduino D9    to    Rx CH 2
Arduino D10  to    Rx CH 3
Arduino D11  to    Rx CH 4



5V Wiring Harness



Construct a wiring harness to connect the 5V pin on the Arduino to the power on the receiver and MPU-6050.



Similarly, connect a GND wiring harness to connect one of the Arduino GND pins to the receiver, MPU-6050 and ESC BEC GND (brown wire - do this if they aren't already connected via the ESC to the GND on the Power Distribution Board). I connected the two back arm ESC GND's to this harness and the two front ones to the GND used for the voltage divider resistors. Refer to the photographs.



Voltage Divider




Note when wiring the voltage divider that the order of the resistors is important. The 1.5k resistor needs to connect to Vin and the 1k to GND.



The output voltage gets connected to A0 on the Arduino. To make things easier to keep track of, I marked the 1.5k resistor with liquid paper.



Wire the two front ESC GND (brown) wires to the GND side of the 1k Resistor, then cover the resistors in heat shrink.



Finally solder the resistors to Vin and GND and the wire to A0.



ESC Control Lines



The last connections to the Arduino are the four ESC control (orange) wires. The connections are as follows:

Arduino D4  to  ESC 1 (right front - CCW rotation)
Arduino D5  to  ESC 2 (right rear - CW rotation)
Arduino D6  to  ESC 3 (left rear - CCW rotation)
Arduino D7  to  ESC 4 (left front - CW rotation)

Pre-tin the Arduino pins and wires. Put the heats shrink in place before soldering and then make the connections shown above. You can cut off the ESC red 5V BEC wires if you want. These are not used. I'm right handed but I find it easier to hold the wire in place and solder with the left hand in this instance.


That concludes Part 4. In Part 5 we will download the firmware, and calibrate the sensors, ESC's and Receiver. You will need a charged LiPo so get it on the charger.


No comments:

Post a Comment