HobbyKing.com New Products Flash Sale
Forgot your password? Create a new account
Reply
Thread Tools
Old Jul 18, 2011, 09:24 AM
Registered User
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Espergærde
Joined Feb 2011
1,669 Posts
Dennis Frie is offline Find More Posts by Dennis Frie  
Diy osd (Arduino and opensource)

As this project is almost finish, I think it's time for a little update/summary here in post #1.

Lets start with a little video-clip showing the OSD in action
DIY OSD flight test (software v 0.14) (3 min 5 sec)


The main purpose of this project was to make a DIY OSD that can be made with;
  • Opensource software
  • Simple and cheap hardware
  • Only little technical knowledge required

It's not intended to be a graphic-heavy OSD, but an easy readable OSD with the most important info. But it's opensource and you can do whatever you want with it.

Quite a few updates and features have been added by request from users - and I hope to continue this. Feel free to post suggestions - but be reasonable. I don't mind to implement a feature - but I'm not gonna rewrite it all for another purpose etc.

I decided to make this project freely available and opensource - and I don't plan to earn anything on my work. Neither do I intend to sell or produce anything - but others are welcome to use it as they want.

If you don't want to make the hardware yourself the software also supports SimpleOSD OPEN (16 mhz with arduino bootloader and LM1881 sync seperator). It's should be available from here:
http://flytron.com/osd-headtrackers/...uino-boot.html

The OSD support theses features at the moment:
  • Easy hardware design with Arduino
  • Easy setup section added to code
  • Speed from GPS
  • Altitude from GPS
  • Flight timer from GPS
  • Position from GPS
  • Heading from GPS
  • Current from current sensor
  • mAh used
  • Auto set home position
  • Calculate Line of sight
  • dimming of text background
  • Arrow pointing home
  • Speed in km/h
  • Flight summary (max altitude, max speed, max LOS, total distance traveled and average speed)
  • Support NTSC and PAL
  • Support SimpleOSD open 16 mhz version with arduino bootloader

This is the schematic I use at the moment (Please note, AIN0 and AIN1 is NOT pin A0 and A1 on Arduino).


Same schematic but with a bit further explanation/text by Enthlapy (Dimming/brightness resistor value is a bit different, but you can just change these to what you prefer).


Fritzing-drawing, made by thnilsen


Old first post:
A work in progress. This post will be updated with more pictures text etc. Please be patient

A few weeks ago i started to play with a DIY-OSD. There is a lot of commercial OSD's available, but I figured it would be fun to make one myself. I wanted to make the hardware as simple and cheap as possible, so everything has been made using only an atmega micro-controller and a few standard components (resistors, capacitors and diodes). This makes it possible, to build an OSD for less than 10 $ (without GPS and current sensor).

I have chosen to make it all compatible with Arduino – so the code can be used directly with a simple arduino board, atmega with bootloader etc. This makes it pretty easy and cheap for everyone who wants to try it out. No SMD components or extra chips are needed.
At the moment it works just fine, and only LOS and an arrow home needs to be added (this is now done).

So far it has been made for a PAL video signal, but it shouldn’t be very difficult to make it compatible with NTFS.

In general;
A normal analog video-signal can be seen here;

The start indicates that a new line is starting and the variation in voltage is simply a way to express the color. A high voltage (about 1 volt) equals white and lower voltage is darker. Please see Wikipedia for further info on PAL/NTSC video signal.
http://en.wikipedia.org/wiki/PAL

The trick is to detect a new line, count the lines and show the pixels at the right time.
And off course reset the linecount when a new frame is detected.

The hardware:
The hardware is based on an atmega micro-controller and only a few normal components. New line and frames are detected with the analog comparator in the atmega mikro-controller.
As the sync pulse in the video-signal can have a little DC-offset, a few components is needed. To control this offset, the video-signal is AC-coupled. The sync-pulse will then be a negative voltage. To change this, you can add some DC-offset with a positive biased clamping circuit;
http://en.wikipedia.org/wiki/Clamper_%28electronics%29
It's now possible to get a positive video-signal where the sync-pulse is very close to ground. The voltage reference should match the biased video-signal’s synch pulse.
In theory you can bias the video-signal so the sync-pulse goes a bit below ground. This makes it possible to use ground as reference voltage. I have tried and it seems to work fine, but I wouldn’t recommend it.
To show the pixels you can use SPI or USART to shift out pixels very fast. The USART in SPI mode works perfect as it is double buffered. The problem is that you probably want to use the USART for communication with a GPS module. I don’t think the USART pixel generation is of any interest, but I have the code if anyone wants to see it. The SPI is only single buffered (8 bit) so you will have about 2 clock cycles (1 ekstra pixel) that will be the same as the last one, but this is only a minor issue.

The brightness is simply adjusted with a resistor. To avoid the pin from draining a simple diode should be used as well.

Test-video
OSD test (0 min 19 sec)


First test with Arduino duemilanove


A breadboard test;


Simple print-test;


An early test from the breadboard;


Another example. Can't decide if I want to use small or large numbers. Any preferences?
Might add a smaller resistor to make the text brighter.


Later breadboard version.


I plan to use this little arduino pro board. That should make a really small and simple OSD.


Prototype finished;




The circuit at the moment;
C1 = 0.1 uF
R1 = 50 K pot
It might be a good idea to lower R2.


Made so far:
  • In general the hardware is finish and works
  • Working OSD
  • Small ASCII table
  • Communication with GPS
  • "Extracting" data from GPS strings
  • Speed from GPS
  • Altitude from GPS
  • Time from GPS
  • Position from GPS
  • Heading from GPS
  • Current from current sensor
  • mAh used
  • Set home position
  • Calculate Line of sight
  • dimming of text background
  • Arrow pointing home
  • Speed changed from knots to km/h
  • Flight summary added (max altitude, max speed, max LOS, total distance traveled and average speed)
  • Support for NTSC and PAL
  • Support SimpleOSD open 16 mhz version with arduino bootloader

Should be finish soon
  • ...

Ideas for improvement:
Notes to the code;
The code for writing characters, numbers etc. is currently not very flexible if you want to re-arrange the text, numbers etc. As I don't plan to re-arrange the text I don't really care, but a "cleaner" solution could probably be implemented.
The main problem is, that timing is very critical. Even the use of while-loops instead of repeating makes a big difference. While-loops takes quite a few clock-cycles, which is clearly visible.

The code can be opened with notepad++ or Arduino IDE. Please rename to .pde instead of .txt when using with Arduino.

use of the code;
The code can be used as you want. Feel free to change, update delete etc.
Use of the code in a commercial product is welcome as well - but it would be great to know.

GPS:
The software have been written and tested with a MTK GPS and 2 GPS-simulation programs. The software should more or less work with all GPS'es, but I don't guarantee anything. It's recommended not to use lower than 1 hz update rate, and it's preferable to configure the GPS to only send RMC and GGA NMEA strings.







version 0.04;
  • Speed changed to km/h
  • Number of satellites added
  • Now only "active numbers" will show. This means 5.5 meter altitude will show as 5.5 and not 0005.5. Speed will show as 10.5 instead of 010.5. Done with speed, LOS, altitude, current and mah consumed.
  • Altitudes higher than 999 meters will now show as xxxx.x instead of xxxx.

Version 0.05
  • Support for SimpleOSD 16 mhz
  • Voltage and current input can be choosen in beginning
  • Battery voltage added
  • A few danish comments translated/removed
  • Few minor changes/cleaning in code

Version 0.06
  • Flight summary added with:
  • Max altitude
  • Max Speed
  • Max LOS
  • Total distance traveled.
  • Flight time
  • Wrong baud-rate settings will no longer crash the controller

Version 0.07
"look" changed - and some minor changes.

Version 0.08
Small bug fixes from version 0.07
  • Black line removed
  • total distance up to 99 km supported
  • Error in total distance calculation corrected

Version 0.09
  • GPS code updated
  • LOS and heading should work for everyone (no matter location)
  • Alarm function added on LOS, altitude, battery-voltage and mah used
  • Avg speed added to flight summary
  • Baud rate can be set in the setup-section (by just writing 9600 etc)
  • The line where analog-readings and current calculation is done have been added to #define line section
  • corrupt serial data will no more "fill the buffer" and block valid data
  • Topline moved a bit, might help NTSC users.

Version 0.10
  • NTSC support (line numbers from Melih used)
  • mah code updated to support timing in NTSC video signal
  • In setup it's only necessary to choose controller and video system (PAL or NTSC)
  • The input used for current-sensor and voltage-divider can be set by just writing the pin-number
  • Calibration for voltage-divider added to setup-section
  • Dimming added to SimpleOSD version (thanks Melih)

Version 0.11:
  • Auto altitude offset added
  • No altitude info from GPS (with altitude offset on) will no more show as 6220 meter (thanks to mrfliboy - noticed this on his movie)
  • Maximum speed in summary should be fixed (showed a weird string now and then)
  • Parameters added to flight summary, it's now possible to choose when flight summary is displayed
  • Couple of small changes
  • CUR and VLT replaced with A and V. What do you prefer?

Version 0.12:
  • Start-up screen added. Shows number of satellites, sat-fix, delay (from sat-fix to set-home) and the time (this can be used to check if the gps update-rate is right)
  • Possible to hide GPS-coordinates if altitude > x (but can be set to show every x second anyway)

Version 0.13
  • Some of the code changed a bit and re-arranged to be more efficient.
  • Option added to "align" text - all the text can be moved left and right to fit/center perfect
  • Summary centered

Version 0.14
  • Now possible to show mah / km - can be used to find optimal cruise speed etc. (need to be turned on under setup)
  • Speed/altitude decimals can be turned off in setup
  • Minor fix with GPS-coordinates that was alligned wrong (when using hide when over x meter and only show every x second - guess no one have discovered this yet)
  • Example added to config "show summary" for plane and quad
  • Dimming added to text
  • Delay for align screen moved - gives quite a few more clock cycles for every line for anything else

Version 0.15
  • Menu added (configuration also saved when power-off)
  • Support for US units (altitude offset must be on)
  • Dimming removed from top characters (when showing decimals)
  • Version-number added on startup-screen
  • Plane-position can be shown (in degrees)

The menu will allow you to change these settings:
  • Show mah/km (on/off)
  • Show decimals (on/off)
  • Text alignment to center text
  • Show plane position (on/off)
  • Altitude alarm (set value)
  • LOS alarm (set value)
  • Volt alarm (set value)
  • mAh alarm (set value)
  • Arrows updated a bit
  • The word "max" was bugged in summary - now fixed
  • Menu and start-up screen fixed a bit (only look)
  • A little more free space available.

Version 0.16
  • Arrows updated a bit
  • The word "max" was bugged in summary - now fixed
  • Menu and start-up screen fixed a bit (only look)
  • A little more free space available.

Exit must be chosen to save data. All data will be saved to eeprom, so they will stay until new data is written.
First time you load the new firmware the settings will be saved to the eeprom.
Even if you reload/flash the software the old values will be saved. If you want to update the values there is an option in the file to overwrite previously data. Just be sure to change the value back to 0, otherwise settings will be reloaded everytime.

Version 0.17
  • RSSI support added (can also be used to read voltage on second battery etc)
  • If alarms are set to 0, they will be off
  • Bug with negative altitude showing an arrow instead of minus is fixed

Version 0.18
  • Updated for Arduino IDE v 1.0
  • Splitted into multiple files and cleaned a bit
Attached Thumbnails
  • Name: pal_signal.png
Views: 11400
Size: 10.9 KB
Description: 10.9 KB · Views: 11400

  • Name: Breadboard.jpg
Views: 11580
Size: 107.2 KB
Description: 107.2 KB · Views: 11580

  • Name: Test_print.jpg
Views: 11694
Size: 138.3 KB
Description: 138.3 KB · Views: 11694

  • Name: Example_1.jpg
Views: 11432
Size: 80.6 KB
Description: 80.6 KB · Views: 11432

  • Name: Arduino_pro.jpg
Views: 11255
Size: 111.9 KB
Description: 111.9 KB · Views: 11255

  • Name: First_test.jpg
Views: 11578
Size: 121.1 KB
Description: 121.1 KB · Views: 11578

  • Name: Example_2.jpg
Views: 11570
Size: 91.3 KB
Description: 91.3 KB · Views: 11570

  • Name: Breadboard_v2.jpg
Views: 11305
Size: 131.0 KB
Description: 131.0 KB · Views: 11305

  • Name: V11.png
Views: 10118
Size: 24.7 KB
Description: 24.7 KB · Views: 10118

Attached Files

Last edited by Dennis Frie; Apr 20, 2012 at 02:55 AM.
Reply With Quote
Old Jul 18, 2011, 09:28 AM
Don't leave it Stock
mrfliboy's Avatar
USA, IL, Round Lake
Joined Feb 2004
2,292 Posts
mrfliboy is offline Find More Posts by mrfliboy  
Very nice!!
Reply With Quote
Old Jul 18, 2011, 09:28 AM
Registered User
cactus's Avatar
Durango Colorado
Joined Sep 2001
4,831 Posts
cactus is online now Find More Posts by cactus  
Subscribed.
Reply With Quote
Old Jul 18, 2011, 09:29 AM
Registered User
GregSilver's Avatar
United States, FL, Plantation
Joined Nov 2005
595 Posts
GregSilver is offline Find More Posts by GregSilver  
awesome.... please keep this project updated. I have a little exp. with arduino and would love to follow your steps!
Reply With Quote
Old Jul 18, 2011, 09:49 AM
Registered User
Greenland, Tunu
Joined Aug 2007
287 Posts
mark the shark is offline Find More Posts by mark the shark  
Very nice..
Reply With Quote
Old Jul 18, 2011, 10:07 AM
Registered User
Österreich, Burgenland, Eisenstadt
Joined Aug 2010
35 Posts
maexx is offline Find More Posts by maexx  
Cool, I'm in! Seems to be the perfect project after MultiWiiCopter
Reply With Quote
Old Jul 18, 2011, 10:15 AM
Bugs!!!!!!!
viper6549's Avatar
USA, OK, Wayne
Joined Sep 2009
205 Posts
viper6549 is offline Find More Posts by viper6549  
Sweet, I would love to have a peak at the code.
Reply With Quote
Old Jul 18, 2011, 10:56 AM
Registered User
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Espergærde
Joined Feb 2011
1,669 Posts
Dennis Frie is offline Find More Posts by Dennis Frie  
There seems to be quite a few interested, great

The code is not too pretty, but it's well commented.
I will upload the current version shortly.
Reply With Quote
Old Jul 18, 2011, 11:01 AM
aka Nigel Uno
Italia, Lazio, Monterotondo
Joined Sep 2004
296 Posts
gtrick90 is offline Find More Posts by gtrick90  
Nice work!!

Ciao

Luca
Reply With Quote
Old Jul 18, 2011, 11:22 AM
Registered User
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Espergærde
Joined Feb 2011
1,669 Posts
Dennis Frie is offline Find More Posts by Dennis Frie  
Code has been attached. I haven't done any cleaning yet, but feel free to take a look

New image attached as well.
Should I go for small or large numbers?

Last edited by Dennis Frie; Jul 18, 2011 at 11:33 AM.
Reply With Quote
Old Jul 18, 2011, 01:15 PM
Registered User
charlienofun's Avatar
United States, CA, Alameda
Joined Mar 2008
295 Posts
charlienofun is offline Find More Posts by charlienofun  
Subscribed.
Reply With Quote
Old Jul 18, 2011, 01:30 PM
Registered User
cactus's Avatar
Durango Colorado
Joined Sep 2001
4,831 Posts
cactus is online now Find More Posts by cactus  
Quote:
Originally Posted by maexx View Post
Cool, I'm in! Seems to be the perfect project after MultiWiiCopter
+1. There is currently only one OSD using the Gyro and ACC data from the MultiWiicopter to show an Artificial Horizon. That one is closed source and there is not much documentation on it and it's very pricey.
Tom66 is working on an OSD as well and I started working on some sudo code to take the IMU data from the IC2 on a MultiWii and generate a AHI line for his code base.

What I like about the OP's solution is that it's Arduino based and so is MultiWii. So, we might finally have an open source AHI OSD solution for Wii based flight controllers!
Reply With Quote
Old Jul 18, 2011, 03:13 PM
RC = FUN
Fort Wayne, Indiana
Joined Aug 2008
3,501 Posts
flyboy321 is offline Find More Posts by flyboy321  
This is pretty awesome!

I'd say go for the big text, but that's just me. And, put an arrow pointing home! -Tyler
Reply With Quote
Old Jul 18, 2011, 03:14 PM
Registered User
SW England
Joined Aug 2009
728 Posts
Devonboy is offline Find More Posts by Devonboy  
Maybe you would also be interested in this opensource, Arduino RC hardware
http://www.rcgroups.com/forums/showthread.php?t=1446653

Hardware:
http://www.flytron.com/16-openlrs
Forum:
http://forum.flytron.com/viewforum.php?f=7

Nigel.

Last edited by Devonboy; Jul 18, 2011 at 03:27 PM.
Reply With Quote
Old Jul 18, 2011, 03:22 PM
Registered User
Italia, Lombardia, Milano
Joined Jun 2010
74 Posts
carlonb is offline Find More Posts by carlonb  
Hi dennis,
please continue, I like this idea to built my own OSD as i like fly , programming and electronics.
Please submit a schematic.
Ciao, Carlo
Reply With Quote
Reply

Castle Creations      DRIVE / FLY / SUPPORT  


Similar Threads
Thread Thread Starter Forum Replies Last Post
Discussion Diy osd karl k Video Piloting (FPV/RPV) 2 May 03, 2011 12:31 AM
Idea New DIY OSD? atari7202 Video Piloting (FPV/RPV) 1 Mar 25, 2011 12:08 AM
Discussion see my own diy OSD video Passion Aerial Photography 7 May 27, 2010 01:28 AM
Discussion REAL homebrew DIY OSD - Check it out! jafoca Video Piloting (FPV/RPV) 8 Jun 29, 2009 06:52 PM
Discussion picoOSD DIY PIC12F683 based OSD in C kbosak Video Piloting (FPV/RPV) 6 Jan 31, 2008 07:47 AM