Skip to main content

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/

Popular posts from this blog

Ubuntu 17.10 review. Running with hidpi, touch screen and wayland support

Ubuntu GNOME 17.10

I think Ubuntu GNOME is the best flavor of Ubuntu if you are running in HiDPI mode 3200x1800 with a touchscreen. All screen captured images are at HiDPI resolution.

Since I prefer the standard gnome-session experience, I installed the "gnome-session" package and rebooted the system. And on the cog icon next to the sign in button, select the "GNOME" instead of ''Ubuntu" option before clicking the sign in button.

sudo apt install gnome-session

Touchpad
I increased the speed, enabled "tap to click", "two finger scrooling". and on gnome-tweak enabled click method to "fingers".
Touch support Ubuntu gnome support for touchscreen is pretty good on the desktop.
Chromium browser supports touch screen very well and much better than Firefox without any plug-ins.
In my Yoga pro 2, the windows key on the screen panel works as the windows key on the keyboard.
Screen rotation is supported on the new gnome and disables …

Ubuntu 17.10 running on Lenovo Yoga 920 with HiDPI and touch screen support

I resized the windows partiton to the minimun necessary (100G), disabled secure boot and I also remove bitlocker key encryption on windows drive, this allows Ubuntu to see that partition and allow windows to boot with secure boot disabled, without complaning.

This makes everything go easier if you want to keep windows arround on the same disk and dual boot with Ubuntu, you should do this it helps a lot. Even after you disable this, you can re-enable it back, both secure boot and bitlocker key encryption.

Before installing on windows updates resize your windows partition, installing all windows updates will not alow you to gain as much space as possible. After resizing the windows partition to the minimium size you want, install all windows updates, bios and driver updates.

I upgraded all windows updates to the latest version and all drivers to the latest version and upgraded the bios on windows to the latest version before installing Ubuntu, I don't think this makes much differenc…

Using a socks proxy

#ssh to a machine on the network you need access and start # a local socks server ssh -D 9999 httpserver.blah.com
# setweb browser proxy to proxy: localhost:9999
# To use other apps with socks install sudo apt-get install tsocks
# Change config file to (remove everything else) /etc/tsocks.conf server = 127.0.0.1 server_port = 9999
# ssh to a machine tsocks ssh -X httpserver.blah.com
# eclipse to a machine tsocks eclipse
reference: using tsocks for tunneling cmds lines and everything else http://www.plenz.com/tunnel-everything