HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old Dec 01, 2012, 06:32 PM
Registered User
Joined Aug 2012
114 Posts
Quote:
Originally Posted by pawelsky View Post
Did a quick test on other Arduino Nano:
1) with this sketch everything works fine, I'm getting correct readings (unit not broken, hurrah!)
2) with happul3 sketch the readings seem to be incorrect (although unit reacts to changes of press/temp). I guess there must be some overflow during conversion (temp gets negative)
Just to make sure, I've reflashed code I posted and it works properly in setup, displaying correct pressure and temperature. So there is no chance of incorrect math.

The most likely scenario of why you are getting wrong readings with my code is that bmp085 does not get sufficient time to sample values. The Miru's setup code has some difficult-to-follow flow logic implemented with goto's. It is related to gps, which I do not have. Try to disable/disconnect gps. Incidentally, the regular (non-setup) loop might be unaffected as it is free of pesky goto's.
happul3 is offline Find More Posts by happul3
Reply With Quote
Sign up now
to remove ads between posts
Old Dec 01, 2012, 06:35 PM
Registered User
Vista, CA
Joined Feb 2008
1,182 Posts
Quote:
Originally Posted by happul3 View Post
Just to make sure, I've reflashed code I posted and it works properly in setup, displaying correct pressure and temperature. So there is no chance of incorrect math.

The most likely scenario of why you are getting wrong readings with my code is that bmp085 does not get sufficient time to sample values. The Miru's setup code has some difficult-to-follow flow logic implemented with goto's. It is related to gps, which I do not have. Try to disable/disconnect gps. Incidentally, the regular (non-setup) loop might be unaffected as it is free of pesky goto's.
Don't worry about the goto's, they are not used unless you hit another CTRL-B or the GPS baudrate changes.
miru is offline Find More Posts by miru
Reply With Quote
Old Dec 01, 2012, 06:54 PM
MiruMod supporter
pawelsky's Avatar
Polska
Joined Jan 2012
1,280 Posts
Quote:
Originally Posted by happul3 View Post
Just to make sure, I've reflashed code I posted and it works properly in setup, displaying correct pressure and temperature. So there is no chance of incorrect math.

The most likely scenario of why you are getting wrong readings with my code is that bmp085 does not get sufficient time to sample values. The Miru's setup code has some difficult-to-follow flow logic implemented with goto's. It is related to gps, which I do not have. Try to disable/disconnect gps. Incidentally, the regular (non-setup) loop might be unaffected as it is free of pesky goto's.
I did test without GPS - same effect
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Dec 01, 2012, 07:11 PM
Registered User
Joined Aug 2012
114 Posts
Quote:
Originally Posted by pawelsky View Post
I did test without GPS - same effect
Hmm. Try printing out internal variables I mentioned before. Let's see if the sketch is getting any proper values out of bmp085.
happul3 is offline Find More Posts by happul3
Reply With Quote
Old Dec 01, 2012, 07:29 PM
Registered User
Joined Aug 2012
114 Posts
Quote:
Originally Posted by pawelsky View Post
I did test without GPS - same effect
I checked out the sketch you posted. It uses wire library, which supposedly enables arduino I2C pullups by default. My sketch does not rely on that library and, as I recall, does not enable pullups because I use sparkfun level shifter that has permanent hardware pullups on both sides anyway. Perhaps your board requires arduino pullups to communicate properly.
happul3 is offline Find More Posts by happul3
Reply With Quote
Old Dec 01, 2012, 07:42 PM
Registered User
Joined Aug 2012
114 Posts
Quote:
Originally Posted by happul3 View Post
I checked out the sketch you posted. It uses wire library, which supposedly enables arduino I2C pullups by default. My sketch does not rely on that library and, as I recall, does not enable pullups because I use sparkfun level shifter that has permanent hardware pullups on both sides anyway. Perhaps your board requires arduino pullups to communicate properly.
Google search yields the following recipe to enable pullups:

sbi(PORTC, 4);
sbi(PORTC, 5);



add this two lines at the end of i2cInit() function.
happul3 is offline Find More Posts by happul3
Reply With Quote
Old Dec 01, 2012, 08:01 PM
MiruMod supporter
pawelsky's Avatar
Polska
Joined Jan 2012
1,280 Posts
Quote:
Originally Posted by happul3 View Post
Google search yields the following recipe to enable pullups:

sbi(PORTC, 4);
sbi(PORTC, 5);

add this two lines at the end of i2cInit() function.
Thanks, but that didn't help. Clearly something must be wrong on my side. I'll do some more investigation of the raw values. Don't waste more time on me for now
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Dec 01, 2012, 09:04 PM
MiruMod supporter
pawelsky's Avatar
Polska
Joined Jan 2012
1,280 Posts
Quote:
Originally Posted by pawelsky View Post
Thanks, but that didn't help. Clearly something must be wrong on my side. I'll do some more investigation of the raw values. Don't waste more time on me for now
I think I've found the problem. When temperature is read, although it should be of type long (according to Bosch's spec) it is read using bmp085ReadInt which returns signed int. For big values of the temperature's MSB it jumps into negative. As a quick and dirty solution I've created bmp085ReadLong2 that puts temperature's MSB and LSB together and returns long. Now everything works perfectly

Now time to bed
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Dec 02, 2012, 08:44 AM
Registered User
Joined Aug 2012
114 Posts
Quote:
Originally Posted by pawelsky View Post
I think I've found the problem. When temperature is read, although it should be of type long (according to Bosch's spec) it is read using bmp085ReadInt which returns signed int. For big values of the temperature's MSB it jumps into negative. As a quick and dirty solution I've created bmp085ReadLong2 that puts temperature's MSB and LSB together and returns long. Now everything works perfectly
)
Gratz! Your explanation makes good sense. But now I baffled as to why do _I_ get proper reading with that code. Could it be that calibration constants are such that my uncorrected temperature is always below 0x7fff and yours isn't? If you don't mind, please post uncorrected values of temperature, pressure, and calibration constants you are reading.
happul3 is offline Find More Posts by happul3
Reply With Quote
Old Dec 02, 2012, 08:59 AM
MiruMod supporter
pawelsky's Avatar
Polska
Joined Jan 2012
1,280 Posts
Quote:
Originally Posted by happul3 View Post
Gratz! Your explanation makes good sense. But now I baffled as to why do _I_ get proper reading with that code. Could it be that calibration constants are such that my uncorrected temperature is always below 0x7fff and yours isn't? If you don't mind, please post uncorrected values of temperature, pressure, and calibration constants you are reading.
uncorrected temp = 33100 (so above 0x7FFF) once that is wrong, then everything goes bad (as pressure calculation take temp into consideration)

uncorrected pressure = 334025

Need to leave now so will send you the calibration data later.
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Dec 02, 2012, 10:53 AM
Registered User
Joined Aug 2012
114 Posts
Quote:
Originally Posted by pawelsky View Post
uncorrected temp = 33100 (so above 0x7FFF) once that is wrong, then everything goes bad (as pressure calculation take temp into consideration)

uncorrected pressure = 334025

Need to leave now so will send you the calibration data later.
I've confirmed that there is a nasty bug discovered by Pawelsky. The nasty part is it will appear only on some bmp085 units under normal circumstances. For instance, my bmp085 gets ~29000 uncorrected temperature at room temperature, which is positive int and when typecast to long, remains positive. Pawelsky's unit gets uncorrected temperature around 33000 (unsigned), which is negative int and negative long after typecast. So the code fails on Pawelsky's unit at room temperature. Incidentally, I can make code fail on my unit around 41C temperature. Sneaky, nasty bug!

Anyways, once it is understood - credit goes to Pawelsky - the fix is very simple. All that's needed is to change typecast from

uncor_temp = (long)bmp085ReadInt(0xF6);

to

uncor_temp = (unsigned int)bmp085ReadInt(0xF6);

I am attaching the corrected code below. Per Pawelsky's suggestion, it also changes the way barometer data is shown in setup screen.
happul3 is offline Find More Posts by happul3
Reply With Quote
Old Dec 02, 2012, 04:28 PM
MiruMod supporter
pawelsky's Avatar
Polska
Joined Jan 2012
1,280 Posts
Quote:
Originally Posted by happul3 View Post
I am attaching the corrected code below. Per Pawelsky's suggestion, it also changes the way barometer data is shown in setup screen.
Nice! I guess you don't need my calibration data anymore
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Dec 02, 2012, 05:40 PM
Registered User
Joined Dec 2012
14 Posts
Quote:
Originally Posted by pawelsky View Post
Looks like the same problems others have with Arduino Nano clones (mod waits for start signal from drone), no solution to that at the moment. Things you can try:

1) Make sure the mod plug is connected firmly to the drone
2) Upgrade Drone to latest firmware 2.1.16 is a bit old
3) http://www.rcgroups.com/forums/showp...postcount=3360
Hi, I checek the plug and upgrade drone, but no answer I put in setup mod and is showing this in terminal:

rx2at 0.19 20120911, at2so attached
cpusg 1E950F fuses DA-FF-FD-CC
loop 33.3ms, dcnt=2663
gps

-RX- f[ms] p[us] value
AILE 22.0 1515 0
ELEV 22.0 1516 0
THRO 22.0 1527 0 CFG1
RUDD 22.0 1516 0
AUX1 22.0 1116 919
GEAR 22.0 1094 -1000 LAND
V 21.9 1518 0

Is correct?
Tks!
rhumba99 is offline Find More Posts by rhumba99
Reply With Quote
Old Dec 02, 2012, 06:43 PM
MiruMod supporter
pawelsky's Avatar
Polska
Joined Jan 2012
1,280 Posts
Quote:
Originally Posted by rhumba99 View Post
Hi, I checek the plug and upgrade drone, but no answer I put in setup mod and is showing this in terminal:

rx2at 0.19 20120911, at2so attached
cpusg 1E950F fuses DA-FF-FD-CC
Looks ok except the lockbits. Hmmm...another one (3rd if I remember correctly) not starting with CC lockbits. Miru, can this be any clue? Locked EEPROM?
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Dec 03, 2012, 11:52 AM
Registered User
Vista, CA
Joined Feb 2008
1,182 Posts
Quote:
Originally Posted by pawelsky View Post
Looks ok except the lockbits. Hmmm...another one (3rd if I remember correctly) not starting with CC lockbits. Miru, can this be any clue? Locked EEPROM?
The lockbits are a problem, according to the 328p manual the lockbit register has the following bits:
Code:
7 6     5     4     3     2   1   0
- - BLB12 BLB11 BLB02 BLB01 LB2 LB1
1 1     0     0     1     1   0   0   /* 0xcc setting */
In this setup the LB mode is 3 (LB2=0 LB1=0), which means:
Further programming and verification of the Flash and EEPROM is disabled in Parallel and Serial Programming mode. The Boot Lock bits and Fuse bits are locked in both Serial and Parallel Programming mode.

I am surprised you could download the sketch...
You need to find a way to erase the whole chip, put a new bootloader and the right fuse- and lock-bits in...
miru is offline Find More Posts by miru
Last edited by miru; Dec 03, 2012 at 11:57 AM.
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Mini-HowTo RC Controlled AR.Drone w/o WiFi! nosaari Multirotor Talk 116 Mar 14, 2014 02:23 PM
For Sale Parrot AR Drone w/TX/RX mod *Flies Nice* Z06 Tony Aircraft - Electric - Helis (FS/W) 4 Apr 16, 2011 09:42 PM
Discussion Wifi Boosted AR.Drone Fallengod Multirotor Talk 7 Feb 12, 2011 10:52 AM
Discussion And yet another AR drone Arial Video project taudronis Multirotor Talk 17 Dec 07, 2010 11:04 AM
Sold Parrot AR.Drone Four rotor platform control with your iPodTouch/iPhone/iPad Hoverup Aircraft - Electric - Helis (FS/W) 0 Oct 12, 2010 03:54 PM