lundi 4 juin 2012

RRD data in gnuplot

RRD to gnuplot

At work we collect monitoring data and store them in rrd format. To plot them one can use rrdtool. However, as we plan to write a paper with data coming from different sources it was decided to use gnuplot.

I use a perl script that you can download directly here. It is an adaptation of a script designed to convert RRD data to CSV. The original script is available here.

Usage

usage: rrd2csv [args] some.rrd
  -a          autoscale DS values (also --autoscale)
  -c num      convert DS values by "num" (also --conversion)
  -e end      report ending at time "end" (also --end)
  -l label    label DS values with "label" (also --label)
  -m          only report the maximum value (also --max)
  -n          only report values around now (--now)
  -s start    report starting at time "start" (also --start)
  -v          print the start and end times (also --verbose)


Example

./rrd2gnuplot.pl -s 1  input.rrd > output.dat

Plotting

The important thing is the time format:
  set xdata time
  set timefmt "%m/%d/%Y-%H:%M:%S"
  plot 'output.dat' using 1:2

lundi 21 mai 2012

Quadcopter - Part 3

Motors testing

Introduction

I have received most of the parts I need. I still miss the frames but I have what is needed to play with motors and sensors. I'll describe my first tests with the motors in this article.

Items

You don't control a "brushless" motor directly. Instead, an Electronic Speed Controller (ESC) receives an input, from a receiver or an Arduino per instance, and takes care of sending a signal to the motor (more details in the next section).

On the picture below, the motor is already attached to an arm. We can see the 3 wires that have to be plugged in the ESC. The ESC (yellow thing) receives power on the thick black and red cables ending with a Deans connector. The power comes either from a battery (not shown) or from a power supply.

The ESC finally has 3 thin wires to power a receiver or controller (black and red) and to receive the control signal (white). For test purpose the signal will come from the arduino and not a radio receiver.


All the plugs you see (banana on the motor, banana and Deans on the ESC, Deans to jack) had to be soldered and of course the power plugs all differed forcing to build adapters for them. I was pretty excited about soldering stuff as I had never done it before. Believe me, it is a lot more difficult than one could think ! 

ESC and power

Several important points about the ESC and the power:
  • Input comes from the Arduino through the white thin wire and is controlled with the class Servo.
  • The thin black wire (ground) must be connected to the ground of the Arduino
  • The 3 cables to the motor can be randomly connected. If the motor turns in the wrong direction, swap two, and only two, cables. 
  • Battery power is counted by "cell". 3 cells is 11.2 V. Basically you have 3.5 per cell.
  • The power supply is useful for the tests and debugging because the battery won't last very long. Be careful however not to pull too much power. My supply only gives 2 A max whereas the battery goes up to 20 or 25 amps. The supply will shutdown if it goes to high and you will wonder why the motors stop all of a sudden.
  • The ESC I chose are programmable and communicate with us humans by beeping. It is a pain to follow what they "say" using the little instructions shipped with them.

Arduino Control

Code for calibration and for run

Test and ... failures !

Eager to see my motors run I launched the calibration code but the ESCs kept beeping (1-2-3) as expected once at startup. After some investigations, I realized that my battery was of only 1 cell whereas I needed 3 cells. As a consequence the ESC was starting and shutting down continuously.

After buying a new battery and a power supply I tried again but the motor only chattered and staggered continuously even after the calibration. The forum of DIYDrones has been of great help. See here the thread. 

Test again and ... (partial) success !

The problem appeared to be my poor soldering skills. The 3 wires between the ESC and the motor are very sensitive to bad soldering.
After I removed the plugs and soldered the cables directly together the motors finally ran !
Well, they don't accept to go above a certain limit but still it is a first step !

mercredi 9 mai 2012

Getting XOrg statistics remotely

I noticed, and most importantly got complains, that the user interface of our Data Quality Monitoring (DQM) software was slow. The DQM tools in ALICE at CERN are developed in C++ on top of the framework ROOT which is used amongst other things to implement the GUI.

Checking on the production stations I saw that XOrg was eating more than 30% of the memory. To know what processes is provoking the problem, the best is to use xrestop, an equivalent of top for X11.

My problem was that the control room is kilometers away from my office and i was too lazy to go there. I tried to run the xrestop through ssh but got statistics of my own, local computer.

As pointed out by someone here, the trick was to use the option -display :
xrestop -display :0

samedi 5 mai 2012

Quadcopter - Part 2


Shopping list

Items

After spending quite some time thinking about it, I came up with the following list of items. I had to buy most of them and came with testing and interacting with several online shops. See the next section for details.

I ended up ordering many items part of the arducopter kit. Afterward one could wonder if it wouldn't have been cheaper and simpler to order the kit. I still think it was a tough but excellent and very educational exercise to design myself the quadcopter. Take the ESC. I would have just soldered these things without even understanding what they were for. I had to carefully choose each item and make sure it is the correct voltage/size/power (and I made several mistakes !).

Structure
Sensors
Propulsion
Power
Controller 
Remote
  • I recovered a remote control and the corresponding receiver from a broken remotely controlled plane model. I might have to buy a "real" remote control and receiver later on because this one doesn't have enough commands.
Tools & Electronics

 

Shops

I live in Switzerland, i.e. outside the European Union and outside the €-zone. The positive aspect of it is that we have a low VAT. Some online shops make the administrative work needed not to pay the foreign VAT (20% in most Europe) and just pay the Swiss one (8%). It is the case of Amazon per instance. 
The negative aspect is that the delivery is usually very long, easily 10 to 14 days, and the shipping cost can be huge. There are Swiss shops but they tend to be expensive, up to 2-3 times the prices found elsewhere. Here is a list of shops with my comment on why I did or did not use them.
  • Sparkfun - American - For electronics and sensors they design, produce and sell about anything you can think of. The problem is that it is in the US and there is an extra cost and extra delay buying directly from them. The site proposes a lot of tutorials and data sheet. It is a major source of information.
  • Selectronics - French - Very large choice of electronics and robotics stuff as well as tools. Very fast shipping. I had to pay the french VAT though.
  • Conrad - Swiss - Excellent shop for electronics, modelism and tools. It is a Swiss shop, perfect if you are swiss. They can order things that they don't sell. You can follow the expedition of your shipping.
  • Alpha-Crucis - French - A nice shop for robotics. A bit of everything. Unfortunately they rely on the producers of the components (sparkfun, diydrones) and the delays are sometimes awfully long. I am still waiting for some components more than a month after my order.

Quadcopter - Part 1

Introduction

I have decided to start a new hobby project !

By building a quadcopter I hope to learn more about hardware. I always do software and here it is a whole new kind of challenge. I don't know much about motors, controllers or sensors ; and I know nothing about soldering !

I chose not to go for a kit such as the arducopter because it seemed too much like playing Lego. I want to learn and I am ready to go the hard way. My first step will be to read as much as possible about what will be needed and come up with a shopping list. I also have to find (online) shops to order all this.

Similar projects

Tri and Quad copters:
Arducopter assembly instructions, useful to know how they do and the dimensions:
Very useful blog following the assembly of the arducopter:

dimanche 31 août 2008

iPhone apps performances


While struggling to speed up the app I am developping for the iPhone, I discovered how heavy and resources demanding the NSLog() method was. Ok, right, I know this is quite obvious, but if you forget to remove the NSLogs from your code, you will just see the responsiveness of the app drop by almost 80%. How lovely is it?
What is a pitty, is that I couldn't find any common or standard way of deactivating the NSLog() when building for Release. I had to use the infamous #define DEBUG 0 if(DEBUG) NSLog(...), like I was and its respectiveback in the nineties...

Hope this post will remind that you have to deal with this output !

C++ matrices and vectors library


The iPhone SDK is nice even if the iPhone developer program is crap (I will talk about that another time).

My main problem with it has been the external libraries I usually use, such as GSL (Gnu Scientific Library). Indeed, the software linked to it would perfectly work within the simulator but could not be used on the iPhone as the library is not compiled for ARM architecture. And I had no clue how to compile it for this platform.
I ended up looking for a simple algebra library (I just needed a few matrices and vectors manipulations), although I can't understand Apple not providing it... I also wanted to access elements easily , meaning I wanted a C++ library with operator overloading and not an Obj-C one.

I finally found the following library : C++ Grid from Kenneth Wilder
It is really straightforward to use. You just add the header which contains all the source in your project and that's it. The "gt_*" files are examples and they are very self-explaining and complete. Thanks Mr. Wilder for this lib !

However, I didn't test this library extensively and I guess the performances are not incredibely good, but it is certainly enough for simple things.