Diy osd (Arduino and opensource) - Page 43 - RC Groups
Thread Tools
Sep 29, 2011, 08:11 PM
Registered User
rimshotcopter's Avatar
I have since changed it back however I added one more to the loopcount making it 11 verse 10. in the 11th count, I wanted it to read the pulse from the Ultrasonic Echo but it appears to take too much time. So I moved the routine to the Main Loop, it works but I am not sure how it will handle a timeout. I can set the default timeout to be just below the limits of the Range but have not tried it yet.

Code:
else if (line == current_calc_line) {
        loopcount++;

// With 50 FPS, this will give an update-rate of 5 hz. (with odd/even lines 10 hz)        
        if (loopcount == 10) {
          loopcount=0;
.
.
.

        }
Code for the Range Finder.

Code:
digitalWrite(5, LOW);
  delayMicroseconds(2);
  digitalWrite(5, HIGH);
  delayMicroseconds(10);
  digitalWrite(5, LOW);
  duration = pulseIn(4,HIGH);
What I am hoping to accomplish is, when the copter is below 3 meters, then use the Ultrasonic to display altitude and the GPS when above.
Sign up now
to remove ads between posts
Sep 29, 2011, 08:55 PM
Just another user
Dennis Frie's Avatar
Quote:
Originally Posted by rimshotcopter
I have since changed it back however I added one more to the loopcount making it 11 verse 10. in the 11th count, I wanted it to read the pulse from the Ultrasonic Echo but it appears to take too much time. So I moved the routine to the Main Loop, it works but I am not sure how it will handle a timeout. I can set the default timeout to be just below the limits of the Range but have not tried it yet.

Code:
else if (line == current_calc_line) {
        loopcount++;

// With 50 FPS, this will give an update-rate of 5 hz. (with odd/even lines 10 hz)        
        if (loopcount == 10) {
          loopcount=0;
.
.
.

        }
Code for the Range Finder.

Code:
digitalWrite(5, LOW);
  delayMicroseconds(2);
  digitalWrite(5, HIGH);
  delayMicroseconds(10);
  digitalWrite(5, LOW);
  duration = pulseIn(4,HIGH);
What I am hoping to accomplish is, when the copter is below 3 meters, then use the Ultrasonic to display altitude and the GPS when above.
You have to be very careful with the timing. I would suggest to create a "test line" instead.

You can use something like this for testing (please find a "free line", I can't remember the exact line-numbers in use):

if (line > 150 && line < 160) {

Put your code here..

SPDR = 0b11111110;

}

That will output a white "box" as the last thing. When you add your code you can see how much time your code takes to execute. Hopefully you can keep it within a line.

You have to be a little careful with the code inside the interrupt. I would recommend to replace the digitalwrite command - it's very slow compared to the speed you can achieve if you write directly to the registers. I'm not familiar with PulseIn - but again I think you are better off writing the code yourself. I guess you just pulse the speaker and waits for the returning sound? You should be able to reset a timer and read the timer value with an interrupt on Int0 or Int1 to get the delay/distance.
Sep 29, 2011, 09:05 PM
Registered User
rimshotcopter's Avatar
Quote:
Originally Posted by Dennis Frie
You have to be very careful with the timing. I would suggest to create a "test line" instead.

You can use something like this for testing (please find a "free line", I can't remember the exact line-numbers in use):

if (line > 150 && line < 160) {

Put your code here..

SPDR = 0b11111110;

}

That will output a white "box" as the last thing. When you add your code you can see how much time your code takes to execute. Hopefully you can keep it within a line.

You have to be a little careful with the code inside the interrupt. I would recommend to replace the digitalwrite command - it's very slow compared to the speed you can achieve if you write directly to the registers. I'm not familiar with PulseIn - but again I think you are better off writing the code yourself. I guess you just pulse the speaker and waits for the returning sound? You should be able to reset a timer and read the timer value with an interrupt on Int0 or Int1 to get the delay/distance.
I actually did, please can you verify this for me?

Thanks

Code:
PORTD = ~(1<<5);
  delayMicroseconds(2);
  
  PORTD |= 1<<5;
  delayMicroseconds(5);
  
  PORTD = ~(1<<5);
  duration = pulseIn(4,HIGH);
However, I don't know how to substitute the pulseIn, as soon as I figure that one out, we will give her a go.
Sep 29, 2011, 09:10 PM
Just another user
Dennis Frie's Avatar
- oh, and you have to remember the law of psychics.

A single video-line is 64 us. The sound travels with 340 m/s.

In the time it takes one line to pass, the sound will travel:
340 m/s * 64 us = 2 cm.

As the sound have to travel both ways, this will result in a maximum distance-reading of 1 cm. if you expect to do everything within a line it will be pretty useless :P

You can move the code to the GPS-loop. Just be sure to check how pulseIn works. It's for sure an interrupt - so it might give visible noise on the text
Sep 29, 2011, 10:03 PM
Registered User
rimshotcopter's Avatar
THANK YOU DENNIS!!!

This is the information that I need!!!
Sep 30, 2011, 05:34 PM
Hamburger
hamburger's Avatar
dennis and msev,
Thanks for the feedback. I understand I will have to do some coding. I will try when time has come. Msev, one of the multiwii coding threads is one I started. I still have to finish that part and my wing.
Hamburger
Sep 30, 2011, 06:21 PM
Registered User
Great, I'm anxious to see some videos .. So much great development being made lately, especially it's good that it's cheap for my budget ..
Oct 01, 2011, 02:16 AM
MelihK's Avatar
SimpleOSD OPEN Schematic ready!!

You can download it from here:
http://www.flytron.com/pdf/SimpleOSD_OPEN.pdf

Cheers
Melih
Oct 01, 2011, 04:48 AM
Just another user
Dennis Frie's Avatar
Quote:
Originally Posted by MelihK
SimpleOSD OPEN Schematic ready!!

You can download it from here:
http://www.flytron.com/pdf/SimpleOSD_OPEN.pdf

Cheers
Melih
Very nice, thank you Melih.
Just one question. The button is connected to PD6 and ground. This will give logic low when putton is pushed but when the button is lifted again I would expect it to read a random/floating input?
Last edited by Dennis Frie; Oct 01, 2011 at 05:01 AM.
Oct 01, 2011, 08:53 AM
Just another user
Dennis Frie's Avatar
Finally got a chance to try the newest version on a plane. Worked perfect

I didn't noticed any problems - so hopefully it's all good

The weather is great now, so the video will be uploaded later.

By the way - i tried really hard to stall the plane to get a speed-reading below 5 km/h (to make the summary-screen show). I only succeeded to do this once, so for all normal flying 5 km/h seems to a work very well.
Last edited by Dennis Frie; Oct 01, 2011 at 12:39 PM.
Oct 01, 2011, 12:59 PM
Just another user
Dennis Frie's Avatar
A few clips from the flight done today with software-version 0.14

Things I noticed:
  • UHF very close to the OSD (like 1 meter) can mess with the sync-detection. No problem at all, just be aware if you test at home with your UHF-system laying right next to the plane/OSD.
  • Some of the arrows are not too pretty. I forgot to polish them, but that's just cosmetic
  • In my case Altitude drifted around 5 meters and home-position seemed to drift a few meters. More than plenty precision for my use, but you can try with longer delay before setting home-position if you want to get a more exact home-position.

    DIY OSD flight test (software v 0.14) (3 min 5 sec)
Last edited by Dennis Frie; Oct 01, 2011 at 01:20 PM.
Oct 01, 2011, 01:07 PM
Registered User
rimshotcopter's Avatar
that is an awesome display Dennis, I hope mines performs this good.

Question, what is the number above the MAH display?

Oct 01, 2011, 01:14 PM
Just another user
Dennis Frie's Avatar
Quote:
Originally Posted by rimshotcopter
that is an awesome display Dennis, I hope mines performs this good.

Question, what is the number above the MAH display?

Thanks
The number above mAh shows mAh/km. It can be used to find the best cruise-speed and get an idea of how long you can fly with a given speed. It should be a good tool when trying to fly long, but not very useful when you just fooling around.

It can be turned on/off in the setup section.
Last edited by Dennis Frie; Oct 01, 2011 at 08:14 PM.
Oct 01, 2011, 01:54 PM
MelihK's Avatar
Quote:
Originally Posted by Dennis Frie
Very nice, thank you Melih.
Just one question. The button is connected to PD6 and ground. This will give logic low when putton is pushed but when the button is lifted again I would expect it to read a random/floating input?
I will tell you one magic word about that "Internal Pull-Up"
You dont need any pull up resistors on modern microcontrollers. They have internal pull-ups around 10-100k ohm and you need only one extra command for running them.
- set the pin as input (this is your common code)
- set the pin to HIGH like an output pin. İnternal pull up will be ON after this point.

here is the arduino code for you
Code:
  pinMode(buttonPin, INPUT); 
  digitalWrite(buttonPin, HIGH);  // pull-up ON
Quote:
Originally Posted by Dennis Frie
A few clips from the flight done today with software-version 0.14

Things I noticed:
  • UHF very close to the OSD (like 1 meter) can mess with the sync-detection. No problem at all, just be aware if you test at home with your UHF-system laying right next to the plane/OSD.
  • Some of the arrows are not too pretty. I forgot to polish them, but that's just cosmetic
  • In my case Altitude drifted around 5 meters and home-position seemed to drift a few meters. More than plenty precision for my use, but you can try with longer delay before setting home-position if you want to get a more exact home-position.

    http://vimeo.com/29882063
Great video, can i use it on SimpleOSD OPEN's product page?
Oct 01, 2011, 02:59 PM
Just another user
Dennis Frie's Avatar
Quote:
Originally Posted by MelihK
I will tell you one magic word about that "Internal Pull-Up"
You dont need any pull up resistors on modern microcontrollers. They have internal pull-ups around 10-100k ohm and you need only one extra command for running them.
- set the pin as input (this is your common code)
- set the pin to HIGH like an output pin. İnternal pull up will be ON after this point.

here is the arduino code for you
Code:
  pinMode(buttonPin, INPUT); 
  digitalWrite(buttonPin, HIGH);  // pull-up ON


Great video, can i use it on SimpleOSD OPEN's product page?
Arh internal pull up - smart

You are more than welcome to use the video


Thread Tools

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