Monday, April 15, 2013

Minimosd hack for OpenPilot

 The problem with OpenPilot project is the really slow process between announced prototypes and released hardware.

They have a really nice OSD board incoming, but there's still no released date anounced yet.
And I need a good OSD now, so let's build a "temporary" solution.

JR63 & Amedee from OpenPilot forum ported the minimosd from Ardupilot to OpenPilot:
Thanks to them for that work.

Here is a video of what it gives on your video output:

On the other side, Team KV made the same thing for Multiwii project:

But I'll talk only about OpenPilot one for the moment. Things works the same for Multiwii project anyway.

Booth can works on the same board you can buy it at APM store, or some cheap chinese clones that popped around everywhere ( Rctimer, GoodluckBuy, HobbyKing, Ebay )

This is nothing more than an Atmega328P with arduino bootloader & a MAX7456 chip for overlaying text on a video stream.

It doesn't has any current/voltage sensor embedded, and ADC pins are not mapped on the board.

We will need to hack it a bit to suit our needs.

There's many available ADC pins on the Atmega 328P. We just have to wire directly on the chip pins.

We need 3 adc input here. I've choose thoses:
- ADC1 ( pin 24 ) for RSSI
- ADC7 ( pin 22 ) for Current sensor
- ADC6 ( pin 19 ) for Voltage sensor.

To make the thing easier, I choose to use the Attopilot 90A current/voltage sensor.
Like the minimosd, you have the official choice from APM store, Sparkfun one, or some chinese clones ( from rctimer ).

It outputs voltage & current  to a 0-3.3V range.

On MinOPosd wiki, they advice to use some voltage divider to reduce input range to 0-1.1v.
Original code use 1.1v internal atmega voltage reference.

Because I'm lazy, I've decided to use the default 5V voltage reference instead.
We will loose a bit of resolution ( 1024 steps on 0-5v range , so this give us 675 steps for  our 3.3v output. ), but considering the usage, this will be far sufficient.
Just be sure you have a stable 5V input.

Solder 3 wire on the 3 adc pins you want to use.
Don't drink too much coffee before, take a little soldering iron, breathe a bit, and let's go.

 Attopilot already has a 1K resistor on the voltage output, so you don't need to add one ( I've removed it after I took the pic below )
You still should add a low impendance resistor to the current pin. Attopilot already has a capacitor on current output. Adding a resistor will act as an RC filter.
I've added a 470 Ohm resistor to RSSI wire too to limit current.

Here is the board ready with Attopilot sensor:

Attopilot 90A/50v current sensor specs:

 - 63.69 mv/v for voltage sensor
 - 0-3.3v output range for 0-51V input
- 36.6 mv/A for current sensor
- 0-3.3v output range for 0-90A input.

Now we need to change few stuff on minoposd code.

edit the OSD_Config.h to suit your needs :

in my case;
#define ANALOG_RSSI_ON_MINIMOSD  ( I use RangeLink analog rssi output , 0-3.3v range )


#define VOLTAGE_PIN            6
 #define CURRENT_PIN            7
#define REF_VOLTAGE            5            // DEFAULT: a built-in reference, equal to 5 volts on the ATmega328
#define LOW_VOLTAGE            13.2            // filter start value for 4s LiPo
#define VOLT_DIV_RATIO            15.70            // Attopilot 90A/50v sensor Vref 5V based
 #define CURR_AMP_PER_VOLT        27.32            // Vref 5V based: This is the start value for calibrating a +-90A Current Sensor(AC/DC)Attopilot  Sensitivity: 36.6mV/A
#define CURR_AMPS_OFFSET        0.0000          

change analogReference from Internal to Default:



#define RSSI_PIN            1           // A1 is pin 24
#define REF_VOLTAGE            5            // DEFAULT: a built-in reference, equal to 5 volts on the ATmega328

change analogReference from Internal to Default:

After that we just have to compile, & load  minimosd with Arduino software.

Now you can follow the minoposd wiki to finish configuration from the software & osd menu.

With just few easy trick we now have a cheap & working well osd