Sunday, June 19, 2011

Arduino code for Gaui 330X quad copter




I've been doing some work with arduino and GAUI 330X. In this example we controlling the throttle speed of the engines. On the 330X throttle is also used to reset and config the ESCs (4 small boards that control the power to the engines and speed).

I removed the blades and replace those with plastic circles, so I can test the code without having the 330x flying all over the place.

Since I don't own a radio/receiver, it took me a while to get the 330X configure and working.

This example, should allow you to configure the ESCs, and start the 330X, and throttle the engine up and down with the potenciometer.

One thing I didn't realize for a while is that the ESCs are the ones that beep (not the GU334), and since all four are connected to the GU3344 is difficult to configure them because they all beep at same time and are not really synchronized, so you can't really figure out what is the current state of each one.

Probably in the future, I need to figure out a easy way to configure the ESC one by one, without redoing all the wiring.

This code should be used with a potenciometer on pin analog 1.

The wires from GU334 gyroscope should connected to the arduino in the order below:
  • yellow is the rudder wire connect to pin 9
  • orange is the throttle wire connect to pin 10
  • red is the int elevator wire connect to pin 11
  • green is the gain/gear don't connect this wire
  • white is the aileron wire connect to pin 12 (this connector also has power (3 wires). Only connect the white wire to the arduino)
GU334 wires behave like servos, so you can use the servo arduino library, to control the GU334.

Just take it consideration that 90(the user is not pushing the controls) is the neutral value on the servo and 0(user pushing the controls backwards at max) is max backwards value and 180(user pushing the controls forward at max) is max forward value.




#include

int aileronPin = 12;
int rudderPin = 9;
int throttlePin = 10;
int elevatorPin = 11;
int gainPin = 8;
int potPin = 1;

Servo aileron; //White
Servo rudder; //Yellow
Servo throttle; //Orange
Servo elevator; //Red
Servo gain; //Green (Gain/Gear)

void arm(){
setSpeed(aileron, 90);
setSpeed(rudder, 90);
setSpeed(throttle, 90);
setSpeed(elevator, 90);
setSpeed(gain, 90);
delay(1000);
}

void setSpeed(Servo &s, int speed){
if (s.read() != speed) {
s.write(speed);
Serial.print(speed);
Serial.print("\n");
}
}

void setup() {
aileron.attach(aileronPin);
rudder.attach(rudderPin);
throttle.attach(throttlePin);
elevator.attach(elevatorPin);
gain.attach(gainPin);
Serial.begin(9600);
arm();
}

void loop() {
int foo = analogRead(potPin);
setSpeed(aileron,90);
setSpeed(rudder,90);
setSpeed(throttle,map(foo,0,1023,0,180));
setSpeed(rudder,90);
setSpeed(elevator,90);
setSpeed(gain,90);
delay(10);
}



NOTE: Created a library for arduino to control the Gaui 330X available here https://github.com/hagleitn/QuadCopter/

Sunday, June 5, 2011

DFU Mode Arduino UNO without soldering



I did these steps after I loaded and "empty" sketch to the board.

Code:
void setup(){}
void loop(){}
-----------------------------------------------------------------
INSTALL THE DFU PROGRAMMER (console commands)
-----------------------------------------------------------------
$ sudo aptitude install dfu-programmer

-----------------------------------------------------------------
DOWNLOAD AND VERIFY THE FIRMWARE (console commands)
-----------------------------------------------------------------
$ wget --no-check-certificate https://github.com/arduino/Arduino/raw/master/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial-uno.hex
$ md5sum Arduino-usbserial-uno.hex
8e01ee236e70bbea43f7eb4e11c9688a Arduino-usbserial-uno.hex

-----------------------------------------------------------------
PUT ARDUINO UNO IN DFU MODE (see Picture)
-----------------------------------------------------------------
0) connect your board to the pc
1) insert 2 wires in GND pins according to the picture above
2) hold the "wire 1" on the top left 8u2 ICSP pad (AREF)
3) touch the "wire 2" against the left side of the capacitor below the RX LED (leds will blink)
4) remove the "wire 2" wire
5) remove the "wire 1" wire
NOTE: in step 3, my board actually has 2 capacitors instead of one like displayed in the picture, use the capacitor below the RX LED.

-----------------------------------------------------------------
UPLOAD THE NEW FIRMWARE (console commands)
-----------------------------------------------------------------
$ sudo dfu-programmer at90usb82 erase
$ sudo dfu-programmer at90usb82 flash Arduino-usbserial-uno.hex
$ sudo dfu-programmer at90usb82 reset

-----------------------------------------------------------------
FINAL STEP
-----------------------------------------------------------------
disconnect the board from the pc
reconnect it and you are done

NOTE: when you are done remove dfu-programmer package from Ubuntu since this package require the arduino IDE and some other tools and those versions don't work with Arduino UNO board.
Most of these instructions were copied form MementoMori posts on
http://arduino.cc/forum/index.php/topic,52447.0.html

Ubuntu 25.04 desktop review and apps to install

Ubuntu 25.04 This new version of Ubuntu installs without a glitch in my ThinkPad X1 and Yoga 920, I setup this device with dual boot with wi...