The PiWeather main architecture

PiWeather weather station : introduction

The weather station project (codename : PiWeather)

It's been quite a while we haven't posted anything here, but it doesn't mean we're not working on cool things !

A few months ago, I thought it would be cool and useful if I could monitor temperatures inside and outside of my apartment. This way I could know when to open the windows or close them in summer when it gets warmer outside than inside, and the other way around. Then I figured that I might as well add other data, such as pressure, humidity, maybe wind speed and others if I gather the time and the energy to go through with my project, which I admit, rarely happens :D

Anyway, things are now moving with the project so now is the time to write here. The idea for this first article is to introduce briefly what I will do and how I am planning to do it. I will update this article in the future with links to the latest articles I post about the PiWeather project.

Architecture

The PiWeather main architecture
The PiWeather main architecture

As you probably guessed from the project's codename, the central unit is a Raspberry Pi. The Pi itself does not host any sensor. It will instead be connected wirelessly to them, or more precisely, to what I will call from now on “sensor units”. These sensor units will be Arduino based (what a surprise!) sensor platforms. I mean by this that a sensor unit can host more than one sensor on board, like both a pressure sensor and a temperature sensor for example.

Goals

My goals are :

  • No wires : While the Pi will be connected both to a power source and through Ethernet, the sensor units must be wireless.
  • Plug and play sensors. Just put a battery inside a sensor unit, and you're done. No complicated setup on the computer, through switches, nor command lines.
  •  Longest possible battery life for the sensor units. If you have to change batteries every other week, then being wireless has in fact no point.
  •  Web interface to monitor and access all the logged data
  •  Use cheap parts

There are probably tons and tons of similar projects on the Internet, and I don't really care. The point is as always to have fun, learn, design, and do something useful...Okay, it's not always useful :)

Technical topics

On a technical side, the topics I will try to approach during this long journey are:

  • The sensors I used or plan to use
  • Low power Arduino design
  • Arduino development in Eclipse
  • Raspberry Pi program cross compilation
  • Communicate wirelessly between an Arduino and a raspberry Pi
  • Google protocol buffers
  • Symfony 2 PHP framework
  • Create a daemon for Linux
  • Interrupts on Raspberry Pi
  • PCB design
  • Case design (if I make to this stage obviously :D)
  • Twitter Bootstrap
  • Javascript
  • jQuery
  • mySQL
  • phpmyadmin

This list is not exhaustive, but it shows that this project approaches a very broad range of domains and languages .

The articles won't be a series of tutorials. Nothing I will do is new, I will instead focus more on how  all of these things work together, and how the design evolves through time.

And this ends this introduction post :)

Follow our RSS feed if you want to hear more about the PiWeather project !

The tricopter

The tricopter

The tricopter
The tricopter

Hi everyone!

We have been pretty busy since we got our Ardupilot and setting it up was so easy and fun that we decided that it could be fun to get another multicopter with a  "ready to fly" flight controller, so we would just have to take care of building the frame ! We decided to build a multicopter and use it with a cheap multiwii board from hobbyking :)

As great as the Ardupilot is, we didn't want to pay 180$ again for a flight controller, and we thought that this time we didn't need a full fledge controller, with GPS and telemetry; just something to have fun with. So we started to look for a cheap multiwii board, and we found "the one" on hobbyking: the Multiwii 328P flight controller.

Our Multiwii flight controller

The price of this thing (28$...) is actually pretty insane, and I would recommend this board to anyone who would like to work with IMUs, to track motion and position, not just to power a multicopter! Just plug it into your computer, launch the Arduino IDE, select Arduino Duelmilanove 328 in the board list and you're ready to go! We definitely should have bought something like this when we started to work on our quadcopter, it woud have been so much cheaper than buying the sensors separately and would have avoided so much troubles with soldering/ fitting everyhting on a tiny PCB !

We decided to build a tricopter because we always thought that their flight behavior seemed really nice and we wanted something a bit smaller and a bit more nervous than our quadcopter. Our quadcopter was a pretty standard one, with arms 25 centimers wide, a good size to get stability and space to carry a GoPro and a FPV setup. We decided to make the tricopter is a bit smaller, with motors 20 centimeters away from the center of the tricopter triangle and to use the same Turnigy SK3 1130kv motors as on our quad. They work great and we had 3 motors left, so no need to buy new ones ! And with these motors, the tricopter would have enough power to carry a GoPro :)

While we took the "hardcore" approach with our full carbon quadcopter, designing it with CATIA, cutting it with a CNC mill, the tricopter construction was quite the opposite. It took us just a couple of hours to build it from scratch with no real plans. The hardest part was the rear servo mecanism, as it always is with tricopters.

Tricopter
The rear motor of the tricopter
Tricopter
The rear part is made of an aluminum part and a Meccano part screwed together and attached to the servo on one side, and to bearings on the other side.
Tricopter
The rear digital servo is a Turnigy TGY-2216MG.

Everything is made of carbon fiber, so it's pretty lightweight and power efficient. We get more than 11 minutes of flight with a 2200 mAh 3S LiPo battery.And it flies very, very well. Tricopters are very fun to pilot, there behavior is really close to an Heli behavior, it kinds of floats in the air and vertical descents can be very fast and stable. The yaw control is obviously much stronger than on a quadcopter so it can be maneuvered easily in very small areas. It carries a GoPro and its case without any problems, so we think it's the perfect toy to play with if you want to film withou stabilization nor FPV!

Tricopter
The zip-tied multiwii, a receiver, a 3S battery, and you're good to go :)
Tricopter
The bottom part fo the tricopter, with space for FPV equipment.

If you are considering building a drone, you should really consider building a tricopter. It may be harder to figure out how to handle the yaw servo, but it's so fun to play with! Go for it :)

A little video where we used the tricopter (80% of the footage)

Stay tuned for more fun with drones and other things :)

Animal motion detection : an Arduino project for photography

Hungry (angry?) pigeon
A real angry bird.

I'm going to talk to you about a simple, yet fun project I did last year : an animal detection device that could control my DSLR and take pictures.

I thought that it would be a fairly simple thing to do with Arduino and a motion sensor. I chose to use an IR sensor because they are very cheap and efficient, and bought the PIR sensor from parallax. It just has a single bit output, so it's super simple to use with an Arduino. It is very sensitive and fits well this application. The only bad thing about it is that it has an incorporated LED that turns red every time a motion is detected, which is probably useful for most use cases, but not in my situation :D I just cut the circuit track leading to the LED so it wouldn't turn red anymore.

Motion detection on Arduino
The motion sensor and its 3 pins : The one bit output, VCC, and GND.

Once we have the information about whether  a living thing is in front of the sensor or not, we need to control the camera to trigger it. This part really depends on what kind of camera you own, if it can accept a remote control or not. If it doesn't, one way to trigger it is to use a servo motor to press the shutter button (with the Arduino Servo library), but the problem might be the noise it generates when moving, which could scare the animals. My DSLR ( a  Canon 550D) has a jack input for remote control which makes it really easy to command. What you will need is a standard 2.5mm stereo male jack, some wires and that's it!

Canon Remote Controller Wiring (2.5mm mini-plug and N3 plug)

You just need to solder the 3 wires to the jack connector. One for the ground, one for the focus command, and one for the trigger command. To focus, just put the focus contact to the ground; and it works the same way to take a picture.

So how to control the camera with an Arduino?

We will use two digital ports of the Arduino to control trigger and focus of the camera. When these outputs will be set LOW, they will fire the action they are supposed to create (focus or trigger). When set HIGH, nothing will happen. To protect the camera, you should put a resistor between the outputs and the camera (I used 2.2K resistor) just to make sure no current goes into the DSLR.

The final schematics look like this:

The very simple schematics of the breadboard circuit. The LED is simply there to control if everything is working (on when something is detected). You can click for the full size image.
The very simple schematics of the breadboard circuit. The LED is simply there to control if everything is working (on when something is detected). You can click for the full size image.
Motion detection on Arduino
The real life schematics :)

The program will be pretty simple too : if something is detected, take a picture and turn on the control LED :)

Here it is:


#include <Camera.h> // The Camera library makes it easier to control a DSLR

/********PINS*********/

int PIR_Pin = 3; //the digital pin connected to the PIR sensor's output
int LED_Pin = 2;
int focusPin=6;
int shutterPin=7;

/********VARIABLES****/

int idletime =0; // The time since last picture
int lastshot=0; // The millis() when the last picture was taken
int burstInterval=5000; //The time between pictures when motion is on
int calibrationTime = 30; // The sensor calibration time (so we don't get false positives when we start the Arduino up)
long unsigned int lowIn;//the time when the sensor outputs a low impulse
long unsigned int pause = 2000;// The time necessary for the motion to be gone after the sensor has gone to a LOW state
boolean lockLow = true; // goes to false when a motion is detected
boolean takeLowTime;
boolean burst=false;// burst mode indicator
Camera* eos; // a pointer to our DSLR

void setup()
{
 eos =new Camera(focusPin,shutterPin);
 Serial.begin(9600);
 pinMode(PIR_Pin, INPUT);
 pinMode(LED_Pin, OUTPUT);
 digitalWrite(PIR_Pin, LOW);

 //Sensor calibration
 Serial.print("Calibrating sensor ");
 for(int i = 0; i < calibrationTime; i++){
 Serial.print(".");
 delay(1000);
 }
 Serial.println("SENSOR READY");
 delay(50);
}

void loop()
{

 if(digitalRead(PIR_Pin) == HIGH){ //If a motion is detected
 if(idletime>30000){ // If the camera is in sleep mode
 (*eos).TriggerFocus(); // wake up the camera
 idletime=0;
 }

 digitalWrite(LED_Pin, HIGH); //signal that a motion is detected
 if (burst){ //Once the motion has been detected and a picture taken, we go into this mode to keep taking pictures every 5s until the motion ends
 delay (burstInterval);
 (*eos).TriggerShutter();
 lastshot=millis();
 idletime=0;
 }
 if(lockLow){
 lockLow = false;// We enter in "motion" mode
 (*eos).TriggerShutter();// We take a picture right away
 delay(1000);
 (*eos).TriggerShutter();// We take a second picture 1s later
 delay(2000);
 lastshot=millis();
 idletime=0;
 burst=true; //Now we go in burst mode,ie picture will be taken every 5S
 }
 takeLowTime = true;
 }
 if(digitalRead(PIR_Pin) == LOW){ //If mothing is detected
 digitalWrite(LED_Pin, LOW); //Turn off the LED
 if(takeLowTime){
 lowIn = millis(); //save the time of the transition from high to LOW
 takeLowTime = false; //make sure this is only done at the start of a LOW phase
 }
 idletime=millis()-lastshot;
 burst=false;

 if(!lockLow && millis() - lowIn > pause){ // If there has been more than 2000ms inactivity, we exit the motion mode
 lockLow = true;
 }
 }

}

The Camera library is included in the project. It is a very simple library that avoids you to code the boring stuff (like setting LOW the trigger output, then HIGH again etc :) )

To host the electronics and the camera, I built a wooden box big enough to put everything in easily, with a lid so It could be weather resistant. Here are the pictures

Motion detection on Arduino
You can see the PIR sensor, and a layer of tape around it. The goal is to make its FOV a bit narrower, so it only fires when the animal is in the camera frame.
Motion detection on Arduino
I used an old remote control from a broken RC helicopter (RIP :( ) to power the Arduino. You can obviously put anything you want in here ( staying in the 7-12V range is recommended )
Motion detection on Arduino
Top view of this masterpiece of engineering.
Motion detection on Arduino
The camera is held here with its tripod mounting hole. You can also see the stereo jack.
Motion detection on Arduino
The lid. The foam layer is there to protect from the rain.
Motion detection on Arduino
The whole thing, with the 550D and the Sigma 10-20mm. The bungee cords can be used to set the device in a tree.

This is obviously far from being perfect, the DSLR shutter noise scaring most of the animals away after the first picture, and the size and weight of this thing making it hard to place anywhere you'd want :D

On the other hand, it does work pretty well and can take some fun pictures.

Cat eating a pizza

Hungry birds.

Hope this can give little help to those of you looking for ways to photograph animals :)

The octocopter

One of the first flights
One of the first flights

We recently built a brushless gimball for our Gopro but our quadcopter became too heavy to fligh safely, so it was time to get something bigger. We first thought about a nice hexa, but we couldn't resist to the appeal the octocopter. We wanted to get enough power to carry a lightweight DSLR such as my 550D, or simply all the FPV equipment we have, plus our Gopro on its brushless gimbal; all of this with a 10 minutes autonomy.

It all went so fast. Add to cart. Pay. Bam, it's delivered. We chose this time not to build the frame ourselves, just to put everything together, and have fun.

The Hobbyking X930 895mm glass fiber frame.

We bought this big and cheap octocopter frame from Hobbyking, the X930. The arms are in aluminum and the rest of the frame is made with pretty thick glass fiber.

[notice]THE MOTOR MOUNTS ARE VERY WEAK.[/notice]

If you look at the comments on Hobbyking's website for this frame, you will see that many people (including us) broke several of them while flying. So don't even try to fly with them, they will eventually break. We reproduced these motor mounts in aluminum with our CNC and mounted them under the original ones to get  rock solid motor mounts.

Turnigy 3536 910kV
The Turnigy 3536 910kV motors mounted with 12x4.5 props. You can see the CNC milled aluminum motor mount under the original one.

The Turnigy 910kV motors provide plenty of power to lift anything you'll throw at the octocopter. They are controlled by 40A controllers (Turnigy Plush 40A), which are fed by an octocopter power board.We use two 3S 5000mAh batteries in parallel to reach our desired autonomy.

Our octocopter power stage
The power board and the 8 ESCs.

Be careful with this board, it is only certified to deliver 8x10A, which is really low (our motors can take up to 35A). We chose to add a lot of solder on the PCB in order to increase the amount of current it could deliver and it seems to be working fine so far.

We flashed our Ardupilot with the latest octocopter firmware and tried to find the best PID values for the octocopter. It does fly pretty well now but there is definitely room for improvement.

Our octocopter
The "command" part of the system.
Our octocopter
Ready to fly. (Yes, we broke one prop so we replaced it with a 9x4.7 :D)

We'll try to fly FPV with it as soon as we can with our new new brushless gimbal (article to come :) ) and we will obviously post videos of it here and on YouTube on our channel. 

We'll be back soon :)

The Mediatek GPS,  current sensor and APM2.5

The Ardupilot Mega 2.5 : why it's awesome.

After a good run, we decided it was time for our homemade quadcopter controller board to go. Actually, it had to. It started to wobble in the air pretty violently for no reason while flying. We made no change to the program, nor touched the hardware, and since it was working fine before, we figured that it probably came from an electronic problem somewhere in the tons of wires and soldering we made. Pretty hard to "debug"...

So here we were, on 3D Robotics website, ready to click the famous "Add to cart" button. And we finally did click, after a long time of hesitation. It was not that long, in fact. It was a no-brainer. For 180$, you get a tiny assembled PCB with an accelerometer, gyroscope, magnetic sensor, pressure sensor, GPS, current sensor, with completely open-source software that will let you do basically anything you could want to do with any kind of RC model. Not only this works with quadcopters in + or X configurations, it's also made for RC cars, planes,hexacopters, Y6 copters, octocopters, tricopters, and even helicopters! 180$ seems pretty cheap now, doesn't it? ;)

All the firmwares you can upload to the onboard Arduino mega
All the firmwares you can upload to the onboard Arduino mega
We don't regret having spent so much time on our controller board at all. It was a great experience, it worked pretty well and got us to understand pretty much everything about how these drones fly. We just couldn't make something so small and so well designed ourselves in our garage. Plus, the huge community working on the Ardupilot's software came to something close to perfection, with a dedicated windows program (APM mission planner) that can control every single parameter of the drone, communicate with it in flight via a telemetry module, prepare mission scripts with GPS waypoints and actions to take, read flights logs and export them into Google earth-friendly KML files (and more)!

What comes with the Ardupilot
What comes with the Ardupilot
We ordered the fully assembled APM 2.5 with a Mediatek GPS, and a current sensor. It also delivers with a USB to micro USB cable so you have everything you need to start playing :)

The Mediatek GPS,  current sensor and APM2.5
The Mediatek GPS, current sensor and APM2.5
It turned out very easy to setup on our existing quadcopter frame. We followed the instructions given on the arducopter google code project and everything went smooth and fast! The steps are the following:

  1. Download mission planner and install it (it will also install the Arduino mega drivers on your computer)
  2. Plug-in your APM
  3. Start mission planner
  4. Choose from the drop-down list the COM port you APM has (check Windows Device manager to find which one)
  5. Go on the firmware tab, select the one you want to use, upload it!
  6. Press connect and you're ready to configure everything!

The default parameters should be fine for an average quadcopter frame (50cm wide, ~1200kv motors, 1kg). At least they are okay for flying. We lowered a bit the PIDs on ours because it was a bit too nervous but the first flight was still pretty good and the stability in the air was quite amazing, even with high winds!

A log from the the Ardupilot
A log from the the Ardupilot
You can assign any action you want on your radio extra switches and knobs. The most impressive one obviously being the "Auto" mode, where the quadcopter will follow a script of actions the user can write with the mission planer software. Just flick a switch, sit down and let the drone take off, fly to the waypoints you told him at the altitude you told him, and then land where you told him.

Casual flight around the Eiffel tower...
Flying has never been so easy! :D Also, it is really, really nice to have the return to launch (RTL) feature, which will bring back the drone where your armed the motors. It is a life saving feature, for those of us who put expensive cameras on their drones and don't want to crash them in case they lose the orientation or the video signal when doing FPV. It actually happened to us in one of our first flights. We were about to test the RTL feature when the drone was so far that we couldn't see its orientation anymore. We were already thinking about the "walk of shame" we would have to take with the broken pieces of our beloved quadcopter. But none of that happened. We flicked the RTL switch, and the drone came back home :D This feature really is a must-have! It's awesome and works great. We've only played with it last weekend, and even though it was a pretty windy weekend here, we managed to fly up to 80 meters with no problem whatsoever for the drone!

OMG, we see that the earth is round! No. It's the Gopro fisheye that does that. But everything seems pretty tiny at 80 meters of altitude.
"OMG, we see that the earth is round!" No. It's the Gopro fisheye that does that. But everything seems pretty tiny at 80 meters of altitude.
If there should be a conclusion to this article, it would be : buy the Ardupilot. It's great, works with everything, has a big developer community around it, and is actually not that expensive when you think about all the electronics it contains.
We just ordered the telemetry and OSD module so we can go all FPV on it ;) We are definitely going to play our quadcopter in the weeks to come, and will try to add a nice video to this article (or to a new one) to show you what you can do which such a powerful tool :)

raspberry-whole

Getting started with the Raspberry Pi : From the box to SSH

Guess what's in the box ?
Guess what's in the box ?
Hi there !

In this article, we'll discuss about the famous Raspberry Pi, a tiny and cheap computer. You can get one for around $30 and it has a credit card size. The whole thing is run by a 700MHz ARM-based SoC ,assisted by 256MB of RAM (512MB on recent models), 2 USB ports, an ethernet port, both HDMI and composite video output and a SDcard slot where you basically put your OS. It's powered via a micro-USB input (5V @~700mA).

The Raspberry Pi PCB
The Raspberry Pi PCB

When you receive your Pi, first thing that comes in mind is "gosh it's tiny !". Indeed, this credit card size is quite astonishing for a computer, even if you are used to deal with Arduino and other PCBs of the same size. Fact is that you have here a fully capable computer on which you can put a Linux distribution, decode 1080p videos and run "reasonably powerful" programs. Let's try this little piece of silicon.

Global purpose I-O pins, allowing hardware to be connected to the Raspberry
Global purpose I-O pins, allowing hardware to be connected to the Raspberry
Basically, all the information you'll need are gathered here : http://www.raspberrypi.org/. You'll only need a SD card (4go is fine, 8Go is good), and an other computer with a SD card slot to burn your OS.

First thing to do is to download the burner : Win32 Disk Imager. Then download an OS that is compatible with your Raspberry. I strongly encourage you to choose Raspbian “wheezy” if you never experienced Raspberry before. It's a Linux OS based on the Debian distribution.

Then you'll have to burn this. Open Win3D Disk Imager, select your distribution, and write it to the SD card. The process can take several minutes. When it's done, just insert it into your Rasp slot, and it should do the trick.

diskImager

To start using your Pi without a display, you can use putty and SSH to remotely take control over your Rasp. All you have to do is connect your Rasp to your local network, download PuTTY and connect to the default name of the Raspberry : raspberrypi (or its IP address).

putty_connect

If you see (after  a possible warning message ) a console that invites you to enter a login, your Raspberry is OK and connected ! If not, check again if you're connected to the network.

command_invit

Enter the default user : "pi" with password "raspberry" (without double quotes). You'll have a prompt that indicates you are now able to type commands over your raspberry. Before doing anything, type the following command :

sudo raspi-config

Select expand_rootfs so your raspberry will use your whole SD card memory. You can also overclock it up to 1000Mhz (I did it without a problem). Reboot your raspberry as asked.

raspi-config

Now, want to see more ? You can use a protocol named VNC that allows you to launch a desktop interface on your Raspberry over the network. Reconnect to your Pi and use this command to download a vnc server :

sudo apt-get install tightvncserver

then launch a server with the command

vncserver

You'll be prompt to enter a password.

If you're on Windows, download VNC Viewer. Once you get it, launch it and select as VNC server "raspberrypi:1". Then hit the connect button and see the magic!

vnc_connect

vnc-connected

From now on, you are able to remotely use your Raspberry and start thinking about all the applications it has! For example, you can use it as a file server by installing a samba server (which is really easy), as a media center with the well known XBMC... This is totally up to you!

Flashing a Turnigy 9x with an Arduino

Don't you think those programmable transmitters are really expensive ? Well here is one solution to this problem : If you already have an Arduino, some wire, a soldering iron and a litle bit of dexterity, you can have a complete, highly customizable transmitter !

Indeed, some awesome guys made new firmwares for the "well known" Turnigy 9x (a low cost 9 channels transmitter, about $60). Even better, those projects are opensource and free. What else ? Ok lets start this little hack.

Turnigy 9x

There are numerous projects (TH9X, ER9X, GRUVIN9X, ERSKY9X,..) and the choice is up to you. I personnaly used Open9X because it seems to be the better easy-to-use/fonctiunalities ratio. But before talking about software, lets discuss the hardware. The problem is, how to send the new firmware to the radio ? Actually this is where you'll need to solder a little. It can be pretty scary, but it's not that hard if you have a good iron ;-).

Lets add a programming port to your 9X !

[important]If you purchased a "9XR" version, there is no need to to this hack since it's already done in factory ![/important]

The Freshly bought Turnigy 9X

Ok you said goodbye to your beloved radio ? Let's unscrew it ! Note that on mine the screws were really hard to unscrew, and I had unfortunately to destroy one of them. Once i'ts open, you'll first be like "WTF am I doing?". Actually, it's pretty simple. First thing you have to do is disconnect the connector that goes from the front part to the back part. After this you'll be able to separate them. On the front part, locate a "big" chip. It's the heart of this radio, the ATMEGA64. Pretty simple stuff, actually. It will be easy to reflash thanks to the AVR isp (In-System Programming) protocole. You'll just have to add the wire to be able to use that protocole.

Atmega64, heart of the system

You'll need 6 wires for the isp protocole :

  1. MISO (Master In Slave Out) known as PDO (Program Data Out) on the chip
  2. Vcc (5v)
  3. SCK (clock signal)
  4. MOSI (Master Out Slave In) known as PDI (Program Data In) on the chip
  5. RST (Reset)
  6. GND

You can figure out by yourself were you should solder those signals reading the ATMEGA64 datasheet (pin n° 2,3,11,20,21/52, 22/53) but I'll give you a simpler way to solder it : Actually the designer of this board were cool guys, the little pads you can see can be easilly used as entry point to solder your own wires.2013-01-01 16.40.50+annots

Pretty easy, isn't it ? I strongly recommend you to make an interface to the outside of the radio because there are several softwares that allow you to customize your model on your computer and then transfert the result in the radio memory, using this protocole. I personnaly used a DB9 connector. but you can use whatever you want (it must have at least 6 connections). The better place to put this connector is under the radio so your hands won't be disturbed.

2013-01-01 17.08.29

2013-01-01 16.41.06

Ok you can now close your radio (don't forget to plug the 12 wires connector). Try to turn on your radio. If it works, lets go to the next step!

Turn your arduino into a AVR programmer

From here, you can use every AVR programmer you want that is compatible with AVRDude (that is, almost every programmer, actually). But I hadn't one and I knew that the Arduino could be used as one. Here is basically the schematics you want (leds are optionnal but strongly recommended. Also, the PCB should not be really hard to design and make).

Untitled Sketch_bb_corr_1.01

Note that the reset is tied to Vcc to prevent reset when connecting the Arduino.

Double-check your connections between the ISP and the ATMEGA64, if you don't want to buy another 9X :)

The Scketch to upload to the Arduino is located under the examples as "ArduinoISP". This is actually an implementation of a subset of the "STK500" protocole  (learn more here), and therefore you'll be able to use it with Avrdude (which is nice because that's what we need to easilly flash our 9x !).

Pin assigment is given in the sketch :

// pin name:     not-mega : mega(1280 and 2560)</div>
// slave reset: 10        : 53</div>
// MOSI:        11        : 51</div>
// MISO:        12        : 50</div>
// SCK:         13        : 52</div>

[notice]

Because of the ATMEGA64 EEPROM address managment, you have to make 2 modifications : when reading the EEPROM and writing the EEPROM : the code looks like it :


uint8_t write_eeprom(int length) {
// here is a word address, get the byte address
int start = here * 2;

and


char eeprom_read_page(int length) {
// here again we have a word address
int start = here * 2;

You have to delete the "*2" since the address is already a byte in the ATMEGA64.

[/notice]

The Firmware

Just install the Companion9X software that will do everything for you. Just change your programmer option under Burn/Configure... and enter the following :

conf_avrdude

(The Port is the port representing your Arduino)

Ok, time to flash ! You can download whatever version you want and try all those wonderfull firmwares !

2013-01-02 15.49.34

2013-01-02 15.51.34

I hope this little tutorial has been usefull for you :) Stay tuned !

Crash T-REX 450

Hi all ! As we're enjoying a very bad weather for a few weeks now, i'll use this time to share some pictures of my first crash with the T-REX 450. This one was due to the big distance of the heli and a grey sky (I lost the orientation). The crash were pretty bad mostly because I panicked and forgot to stop the engine.. Any way 40€ latter it was back in the sky !

2012-09-27 18.06.35 2012-09-27 18.06.45

2012-09-27 20.02.17

As you can see, the main shaft was bent pretty hard..

2012-09-27 20.02.29 2012-09-27 22.09.18 2012-09-27 21.44.03

All the broken parts..2012-09-27 20.02.39

Stay tuned !

A max7456 library for Arduino

It's been a while since we published the last article.. Well we've been pretty busy those days but as a gift in this article I'll present you some of our lattest work : A library for the well known max7456 chip by Maxim.

As famous as it is, a little reminder won't be too much. max7456 is basically used to insert customized information in a given analogic video stream. This manip is called "OSD" (for On-Screen Display). A little picture to explain it :

explainationOSD

We recently bought a wireless video system in order to do FPV (First Person Flying, you only look on a video send by a camera installed on the drone/plane). And the problem is that it's quite hard to pilot this way without additional informations about the flight. So we decided to make our own OSD system.

We decided to make a library for the max7456 because we didn't found one that fitted our needs. This library is pretty simple to use and comes with a complete documentation and example programs. This has been used with a PAL system, but the differences with NTSC are not really big (you have to init it an other way, refer to the datasheed of max7456 if you need to).

Here is the Hello World ! code :

#include "SPI.h"
#include "max7456.h"

Max7456 osd;

void setup()
{
  SPI.begin(); //to be called before osd.init
  osd.init(10); //CS on port 10
  osd.setDisplayOffsets(60,18);
  osd.setBlinkParams(_8fields, _BT_BT);

  osd.activateOSD();
  osd.print("Hello world : )",1,3);
}

void loop()
{
}

In order to make easier the process of entering new characters in the NVM (non-volatile memory) of the OSD, I made an program used to transform a bmp picture representing the OSD characters table into a single array you can use with the library (there is an example that shows the use of this array). Just lauch the executable with the options :

convertOSD.exe -i ".bmp picture" -head ".h containing array"

The bmp picture looks like this :

tableOSD

This represents the 256 characters to be insered into the NVM. So here's the deal : when you want to put your customized characters table into the NVM, you must write on a register in the max7456. The values to write on this special register are directly related to the character. To be quick, each pixel of a character is 2-bits coded, and the character is 12x18 pixels you'll need 54 bytes of data. There are 256 characters in the table so the array returned by the program is 13824 bytes long (approx. 13.5k) . This is much more than the Arduino's flash memory can handle (2k). But the program memory is sufficient to store such an array. Then we used a little trick to program the max7456 in one single operation : we simple store the array in the program memory with the instruction :

const prog_uchar tableOfAllCharacters[13824] PROGMEM = {0x55,0x55,0x55,0 // ....

Nothing really hard here : character at address 0x00  is represented by the 54 first bytes, character at address i is represented by the (54*i) next 54 characters. Note that all the 0xFF value has been replaced by "0x55". This is because af a tricky bug in the Arduino bootloader that causes the Arduino to be corrupted if too many 0xFF are sent on a row to the program memory. Therefore, this is the method to get the character i in the table "table" (we fill a special type "charact" which is in fact a 54 bytes array.


//-----------------------------------------------------------------------------
// Implements Max7456::getCARACFromProgMem
//-----------------------------------------------------------------------------
void Max7456::getCARACFromProgMem(const prog_uchar *table, byte i, charact car)
{
	unsigned long index;
	byte read;
	index = i*54;
	for(unsigned long j = 0 ; j < 54 ; j++)
	{
		read = pgm_read_byte_near(table +index+j );
		car[j] = read;
		if (car[j] == 0x55)
			car[j] = 0xff;
	}
}

Note that we experienced problems with the sparkfun max7456 package. This was caused by a chip overheat dued to insuficient copper pad under it. We solved the problem by adding a tiny RAM heat dissipator on it.

Ok, most important part now : the sources !

Character array generator

Max7456 Library