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

Friday, April 8, 2011

Measure network speed between 2 machines

install

sudo apt-get install iperf


run on machine A
iperf -s

run on machine B
iperf -c IP_OF_MACHINE_A

Tuesday, March 15, 2011

Android LG optimus v factory reset

NOTE: didn't worked for me, I returned the phone in the end.

Android LG optimus v factory reset
1. Turn off your LG Optimus V.

2. Press and hold the following keys for over 5 seconds: Down volume key + Home + Power

3. When the power turns on, release these keys.

3G Drops & Standby Battery Drain (Solutions)

The steps were as follows:

* Check "Time Without a Signal": Home, Menu, Settings, About Phone, Battery Use, click "Cell Standby" and not the value. It should be close to 0% if you've been in 3G range. 50% indicates a definite problem.

To "Fix" - Note the original poster says this change will reset if you reboot the phone and need to be redone:

* Dial *#*#4636#*#* which will go to the phone's "Testing" menu.
* Click "Phone Information", then Menu, then click "Select radio band".
* Click "Force Close" and return back to "Phone Information"
* Scroll down to "Set preferred network type:"
* Click the "Set preferred network type:" button and select "CDMA only".
* Click the "Set preferred network type:" button again and reselect "CDMA auto (PRL)".

As mentioned in the link, now charge your phone to reset the battery usage statistics and after an hour or so monitor the "Time without a signal" value. The problem seems to be from an incorrect network type value that is originally set/saved despite it showing the correct value.

Some people also note that they get better battery usage with WiFi left on vs 3G. I'm not sure if this is due to this issue or not, but I'll do further tests leaving WiFi on tonight after a full recharge.

The default WiFi "Sleep Policy" on the Optimus V is set to turn WiFi off "When screen turns off". If WiFi is truely better, then one would need to set this to "Never". (Note on some other phones WiFi defaults to "Never" sleep.) To change the setting:

* Home, Menu, Settings, Wireless & Network, Wi-Fi Settings
* Click the Menu button and select "Advanced"
* Select "Wi-Fi sleep policy" and change to the desired value


Note: this information was copied from the links below for personal reference.


3G Drops & Standby Battery Drain (Solutions)
http://androidforums.com/lg-optimus-v/293583-3g-drops-standby-battery-drain-solutions.html

LG Optimus V Factory Reset
http://www.lg-phones.org/lg-optimus-v-factory-reset.html

Wednesday, February 9, 2011

TMobile network speed using HTC G2 tethered to my old R50p

Here are a couple of TMobile network speed tests servers using my G2 and tethering to my old thinkpad R50p.


Sunday, February 6, 2011

Reporting appliance power consumption over powerline


Here is a idea I had for appliances resource consumption reporting (ARC).

This post describes an appliance standard for energy consumption reporting, with extensions to report consumption of other resources. (Powerline products extend Internet access to any existing power outlet. Netgear and other brands sell devices with this techonology).

Below a a description of a method of producing and distributing this information in a home network environment with support for powerline networking:
  • Add built-in powerline (network using the electrical cables) support to a fridge, toaster, microwave, tv, ps3, xbox etc. This would allow all appliances to be connect to a in home network. I'm assuming this would add 10-50$ extra to the cost of producing the appliances.
  • Add power-line support to home routers (dlink, netgear and all other brands of wireless routers should come with power-line support by default).
  • Create a standard for the appliances to find the home routers using the powerline connection, without configuration. Appliances would publish the energy consumption to the router. This would be done using a HTTPS PUT request with the appliance name, appliance unique ID, appliance TYPE (kind of like mime type, but for appliances), the period in minutes (5,15,30 minutes), and the number of watts spent in that amount of time, other types of consumption would also apply. Date and time are marked on the router, to avoid requiring that all appliances have a built in synchronized clock. All arguments are be passed in json format and included on the body of the HTTP message.

Example of the JSON for a fridge composed of 2 devices

{
     "devices": 
     [     
         {     
             "name": "Samsung Fridge",
             "id": "Samsung Fridge M-2345 SERIAL5-23234-8765",
"type": "refrigeration/fridge",
             "data":              
             [
                 {
                    "resource": "energy",
                    "unit": "watt",
                    "minutes": 15, 
                    "consumption": 400,
},
                 {
                    "resource": "water",
                    "unit": "mL",
                    "minutes": 15, 
"consumption": 550,
                 },
             ]
         }
         {     
             "name": "Samsung Ice Maker",
             "id": "Samsung Ice Maker M-2345 SERIAL5-23234-8765",
"type": "refrigeration/icemaker",
             "data":
             [ 
                 {
                    "resource": "water",
                    "unit": "mL",
                    "minutes": 15, 
"consumption": 100,
                 }
             ]
         }  
]
 }

Example for a TV composed of 2 devices

{
     "devices": 
     [     
         {     
             "name": "Sony Plasma TV",
             "id": "Sony Plasma TV M-2SDF5 SN HGJF72635-987-P,
"type": "entertainment/tv",
             "data":
             [
                 {
                    "resource": "energy",
                    "unit": "watt",
                    "minutes": 15,
                    "consumption": 300,
},
                 {
                    "resource": "data",
                    "unit": "KiB",
                    "minutes": 15, 
"consumption": 134235,
                 },
             ]
         }
         {     
             "name": "Sony Plasma TV - Google TV",
             "id": "Sony Plasma TV - Google TV M-2SDF5 SN HGJF72635-987-P,
             "type": "entertainment/webtv",
             "data":
             [ 
                 {
                    "resource": "data",
                    "unit": "KiB",
                    "minutes": 15, 
"consumption": 1983335,
                 },
             ]
         }  
]
 }


  • The wireless router receives the request from the appliance and timestamps the request and caches it. At a certain specific interval the cached requests are uploaded to a pre configured wed site, selected by the user.
  • This setup allows the user to use the router interface to configure where all appliances ARC messages should be delivered.
  • The wireless router needs to allow the user to forward all messages to a third party webservice (this service would be able to provide reports and display monthly aggregated data).
  • The router can have built-in data aggregation and reporting for ARC. But the option to forward ARC messages still needs to be available to the user, to allow for a open standard.
This is just an idea, would be great if a standards body could come up with a patent free and open standard that implements ARC.


It would be great to have the appliance, electronics and "wifi/powerline routers" manufacturers supporting a standard like ARC with their devices.


This is just an idea I wanted to put out there. This document was created on 6 Feb 2011.




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...