Monday, November 19, 2012

The Electronics

The Electronics of the first version will be just the ATMEGA328 chip from the Arduino Uno, the crystal (clock), the input connectors (Rx Channels), the output connectors (ESCs) and the connectors for the 2 remaining digital ports and the analog ports, letting the board ready for some expansion.

Screenshots from Eagle:

Schematic
PCB




Input/Output and Arduino Digital Pins Mapping:

Outputs  (PWM pins):
ESC1 – D3
ESC2 – D5
ESC3 – D6
ESC4 – D9
ESC5 – D10
ESC6 – D11

LED – D13

Inputs:
Rx1 – D2 (Aileron)
Rx2 – D4 (Elevator)
Rx3 – D7 (Throttle)
Rx4 – D8 (Rudder)
Rx5 – D12 (Extra) - Parachute deployment?


ESC1 will provide power (5v) to R/C receiver

ESC2 will provide power (5v) to the ATMEGA328 chip


The positive teminal of ESC3, ESC4, ESC5 and ESC6 will be disconnected.



I used optiLoader by Bill Westfield to burn the bootloader to a blank ATMEGA328 chip.
The procedure can be found here:
http://www.3guys1laser.com/blog-burn-bootloader-blank-atmega328atmega328p-arduino-uno

Thursday, November 15, 2012

First R/C Test Using Arduino Uno

The objective of this test was to learn how to read the R/C (Radio Control) receiver signal, convert it and write the correct values to the speed controller. For this test, just one motor is being used.

First step:

Reading the R/C Receiver signal from channel 3, print them on the screen in order to know the min and max values, and then convert the input range to the output range (ESCs' range)
ESC - Electronic Speed Controller


So, the channel 3 of the R/C receiver was connected to the Arduino's digital pin 2 and this was the code used to establish the connection:
  attachInterrupt(2,rc1,CHANGE);


By this time I just knew this way to make the connection between the Arduino and the R/C receiver:


Later I found out that the Arduino UNO has just 2 external interrupts (pins 2 and 3), which would limit us to read just 2 PPM channels (for the hexa control, we need at least 4).

This was solved by using the PinChangeInt.h library and this code to establish the connection:
   PCintPort::attachInterrupt(THROTTLE_IN_PIN, rc1,CHANGE);

By using this code we are able to use any digital port of arduino to read the R/C signals.

This was used to determine the min and max values of the throttle:
Serial.println(RCVal1);


Min = 1108
Max = 1900


So the range is almost the values accepted by the ESCs (in microsseconds - distance between the PPM pulses). But, the min value happens when the throttle control is on the top, and the Max value is when the throttle control is at bottom position. This way, we needed to convert the range using the map function so we could write the correct values to the ESC:

Using angles:
map(RCVal1, 1900, 1108, 0, 180)

Using microseconds:
map(RCVal1, 1900, 1108, 1000, 2000)



Second step:
Connect the ESC to the digital pin 11 and write the correct values to it according to the input from the R/C control.

There are 2 ways of writing the values to the ESC. First I used the servo angles, using:
0 - as the minimum speed, and
180 - as the maximum speed

servo1.write(map(RCVal1, 1900, 1108, 0, 180));

It works, but after testing by writing the microseconds, I had the impression that this way is more accurate (better response). So, this is the code that is being used:

servo1.attach(11);
servo1.writeMicroseconds(map(RCVal1, 1900, 1108, 1000, 2000));


The Hardware config was:
R/C    >>>    R/C Receiver  ---> Arduino Digital Pin 2 as input --> Software --> Arduino Digital Pin 11 as output (PWM) --> ESC --> Motor


Here is the result:





Getting Started

Ok... The first version of our hexacopter will not have accelerometer and gyro for flight stabilization. Those components will be added once the first version is up and running... or up and flying?  :)

First thing was to figure what parts we needed to buy to start to build the structure.... and the electronics. Also, the most expensive part of the project: the R/C.

First list of parts and components:

- Futaba 6 Channels 2.4GHz  R/C   (one for each engineer)
- Carbon fiber square tubes
- Wood
- Screws and nuts
- The amazing Dremel tool
- 9 x 4.7 Propellers (CW and CCW)


- Turnigy Park480 Brushless Outrunner 850kv
- Turnigy Plush 30amp Speed Controllers AT






For the electronics, we are currently using the arduino uno for the tests, but the arduino board will not be used. The ATMEGA328 chip will be removed from the board and put in the pcb that we are going to build. For that, we will need some additional electronic components, such as:

- PCB
- PCB Ferric Chloride
- ATMEGA328 chip
- ATMEGA328 chip socket (28 pins)
- 16 MHz Crystal (clock for the ATMEGA chip)
- 22pF ceramic capacitors
- Pin headers for connecting the Rx Channels and ESCs  (regular and 90°)
- 12 gauge cables for the power (the first version will have a power distribution made of cables)