Espritmodel.com Telemetry Radio
Reply
Thread Tools
Old Sep 29, 2011, 07:11 PM
Registered User
rimshotcopter's Avatar
United States, CA, Los Angeles
Joined Aug 2009
11,576 Posts
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.
rimshotcopter is online now Find More Posts by rimshotcopter
Reply With Quote
Sign up now
to remove ads between posts
Old Sep 29, 2011, 07:55 PM
Just another user
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
741 Posts
Quote:
Originally Posted by rimshotcopter View Post
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.
Dennis Frie is online now Find More Posts by Dennis Frie
Reply With Quote
Old Sep 29, 2011, 08:05 PM
Registered User
rimshotcopter's Avatar
United States, CA, Los Angeles
Joined Aug 2009
11,576 Posts
Quote:
Originally Posted by Dennis Frie View Post
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.
rimshotcopter is online now Find More Posts by rimshotcopter
Reply With Quote
Old Sep 29, 2011, 08:10 PM
Just another user
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
741 Posts
- 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
Dennis Frie is online now Find More Posts by Dennis Frie
Reply With Quote
Old Sep 29, 2011, 09:03 PM
Registered User
rimshotcopter's Avatar
United States, CA, Los Angeles
Joined Aug 2009
11,576 Posts
THANK YOU DENNIS!!!

This is the information that I need!!!
rimshotcopter is online now Find More Posts by rimshotcopter
Reply With Quote
Old Sep 30, 2011, 04:34 PM
Hamburger
hamburger's Avatar
Joined Jan 2010
809 Posts
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
hamburger is online now Find More Posts by hamburger
Reply With Quote
Old Sep 30, 2011, 05:21 PM
Registered User
Joined Sep 2010
2,400 Posts
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 ..
msev is online now Find More Posts by msev
Reply With Quote
Old Oct 01, 2011, 01:16 AM
MelihK's Avatar
Istanbul/Turkey
Joined May 2008
1,364 Posts
SimpleOSD OPEN Schematic ready!!

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

Cheers
Melih
MelihK is offline Find More Posts by MelihK
Site Sponsor
Reply With Quote
Old Oct 01, 2011, 03:48 AM
Just another user
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
741 Posts
Quote:
Originally Posted by MelihK View Post
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?
Dennis Frie is online now Find More Posts by Dennis Frie
Last edited by Dennis Frie; Oct 01, 2011 at 04:01 AM.
Reply With Quote
Old Oct 01, 2011, 07:53 AM
Just another user
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
741 Posts
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.
Dennis Frie is online now Find More Posts by Dennis Frie
Last edited by Dennis Frie; Oct 01, 2011 at 11:39 AM.
Reply With Quote
Old Oct 01, 2011, 11:59 AM
Just another user
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
741 Posts
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)
Dennis Frie is online now Find More Posts by Dennis Frie
Last edited by Dennis Frie; Oct 01, 2011 at 12:20 PM.
Reply With Quote
Old Oct 01, 2011, 12:07 PM
Registered User
rimshotcopter's Avatar
United States, CA, Los Angeles
Joined Aug 2009
11,576 Posts
that is an awesome display Dennis, I hope mines performs this good.

Question, what is the number above the MAH display?

rimshotcopter is online now Find More Posts by rimshotcopter
Reply With Quote
Old Oct 01, 2011, 12:14 PM
Just another user
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
741 Posts
Quote:
Originally Posted by rimshotcopter View Post
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.
Dennis Frie is online now Find More Posts by Dennis Frie
Last edited by Dennis Frie; Oct 01, 2011 at 07:14 PM.
Reply With Quote
Old Oct 01, 2011, 12:54 PM
MelihK's Avatar
Istanbul/Turkey
Joined May 2008
1,364 Posts
Quote:
Originally Posted by Dennis Frie View Post
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 View Post
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?
MelihK is offline Find More Posts by MelihK
Site Sponsor
Reply With Quote
Old Oct 01, 2011, 01:59 PM
Just another user
Dennis Frie's Avatar
Denmark, Capital Region of Denmark, Naerum
Joined Feb 2011
741 Posts
Quote:
Originally Posted by MelihK View Post
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
Dennis Frie is online now Find More Posts by Dennis Frie
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Diy osd karl k FPV Talk 2 May 03, 2011 12:31 AM
Idea New DIY OSD? atari7202 FPV Talk 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 FPV Talk 8 Jun 29, 2009 06:52 PM
Discussion picoOSD DIY PIC12F683 based OSD in C kbosak FPV Talk 6 Jan 31, 2008 07:47 AM