HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old May 30, 2008, 10:57 PM
David1
bmw330i's Avatar
USA
Joined Mar 2007
1,478 Posts
Hi Chris,

Well, this is from the person who designed the Tiny2.11:
"Hello guys,

Please, don't change the resistors : it's useless because you can easily compute the "coefficient" used in "tiny_2_1.h" and
it's dangerous because if you use a wrong value, you can DESTROY the ADC input !!!

In " #define VoltageOfAdc(adc) ( coeff *adc) " let :

* adc = raw value of the ADC input measuring battery voltage. LPC2148 are 10bits ADCs, so the raw value in software always between 0 and 2^10 (=1023)
* Vref = LPC2148 ADCs ref voltage = LPC2148 main power supply = 3.3v
* R1, R2 = resistors made up the bridge of the battery voltage measurement system (see schematic)
o R1 between Vbattery & ADC input
o R2 between ADC input & ground

The general formula to compute the coefficient is :

coeff = ( Vref / ( 2^10 - 1 ) ) x (1 + R1/R2)

coeff = ( 3.3 / ( 1024 - 1 ) ) x (1 + R1/R2)

coeff = 0,0032258 x (1 + R1/R2)

For example :

Tiny 1.1 : R7 = 15k, R15 = 3.3k => coeff = 0,0178885630
Tiny 2.1 : R1 = 15k, R2 = 3.3k => coeff = 0,0178885630
Tiny 2.11 : R1 = 10k, R2 = 1.5k => coeff = 0,0247311828

But, it's an approximate value because of the dispersions of the components :

* resistors values (+/-1% or 5%)
* power supply (not exactly 3.3v)
* etc."

I'm at a loss what is all means specifically but in layman's terms I think it's just related to the volage on the pins on the ADC connectors. So if you have a 3.3v Gyro or sensor you want to be sure you have the correct resistor for R2 (actually none 0k). If you have a 5v Gyro you want the right resistor for that (1.8k)...by using the "default" I can use a 5v Gyro on the ADC without having to do that "resistor bridge" modification described on the Wiki. I kinda like that.

Honestly, I'd like a more simple explanation. No math just what does it mean . That you'll see a lower voltage in the GUI display? It will burst into flames mid-flight? Somewhere in between?
bmw330i is offline Find More Posts by bmw330i
Last edited by bmw330i; May 30, 2008 at 11:27 PM.
Reply With Quote
Sign up now
to remove ads between posts
Old May 31, 2008, 03:27 AM
Registered User
Greece, Attica, Piraeus
Joined Jun 2004
1,133 Posts
Hi David.
I also computed the coefficient in my previous post and actually your post and my post say the same things.
It is very simple actually.
Since the adc has 10 bits(my mistake on my previous post, i meant 10 bits not 12) then it can count up to 1024 different voltage levels 0 included.
(I intensionally used 1024 not 1023 to avoid confusion)
The adc when it measures the voltage it compares it with its internal reference which is 3.3 volt in our case.
If the input voltage is say 3.3/2= 1.65v the adc will count 511, if it is 3.3v it will count 1023, if it is 3.2mv will count 1 and in other words each count of the adc counter corresponds
to 3.3Volt / 1023 ~= 3.2 mv
The adc input voltage cannot be more than the reference voltage because the adc cannot count more than 1023 and a bigger input voltage will burn the adc input.
That's where the resistor divider come in.
If we don't use a resistor divider we can only measure up to 3.3 volts and a higher voltage not only cannot be counted but it will burn the adc input and probably the whole adc.
With a resistor divider we can measure higher than 3.3 volts but we have to make sure that the voltage at the adc input pin (at the chip) will never exceed 3.3 volts by selecting a division ratio high enough that the output of the voltage divider with the max expected input will never exceed 3.3 volts
For example a 5v gyro will be able to vary its output voltage from 0 to 5 volts
but 5 volts at the adc input pin is not acceptable so we have to use a voltage divider with a division ratio of 5/3.3=1.5151515 or higher thus
1.515515 = R1/R2 +1 => 0,515515= R1/R2 => R1=0.515515*R2
We choose R2 first and then we compute R1 and if the value of R1 is not commercially available we choose the next higher value R1 and recalculate the
division ratio or we choose a different R2 so we can find close enough
commercially available resistor values and recalculate.
The value of R1+R2 should be high enough not to load the source's (Gyro output) internal resistance much which should be given from the Gyro manufacturer's datasheet (usually a R2 between 1 and 10 Kohm is acceptable).
The Gyro datasheet should state something like "max output voltage @ 1Kohm"
or state at which load resistance the output voltage was measured or calibrated. This resistance is the value of R1+R2.
With the use of a voltage divider at the adc input, each adc count will represent
3.2mv * the voltage division ratio which is R1/R2 + 1.
R1 is the resistor of the voltage divide that is connected to the + side and R2 is the resistor that is grounded.

Finally we have that each adc count will represent a voltage at
the resistor divider input of:
3.3v / 1023 multipled by R1/R2 +1 and the result is the adc coefficient.
Chris
hendrix is offline Find More Posts by hendrix
Last edited by hendrix; May 31, 2008 at 05:17 AM.
Reply With Quote
Old May 31, 2008, 10:49 PM
David1
bmw330i's Avatar
USA
Joined Mar 2007
1,478 Posts
...lol...that's awesome. Really. You did try. But that's still a lot of Math. Not that it's past me. I just am missing the black and white part of this.
My immediate issue is: Does something need to change with the Tiny2.11 to correct using the default resistors or not? If so I wish someone would correct it and post the new values to the Wiki.
When I send the parts to get them assembled I make no modifications. Whatever the Wiki and design states is what gets assembled. So, if the design has a flaw so will the finished assemblies. Our company simply provides the service of taking the design and having it assembled. So, I'm concerned not for just me but everyone.
Please, no Math. Just does the design need to be modified or no? If so please email the list so the designer can modify his design.
-BMW
bmw330i is offline Find More Posts by bmw330i
Reply With Quote
Old Jun 01, 2008, 12:55 AM
Registered User
Greece, Attica, Piraeus
Joined Jun 2004
1,133 Posts
No David don't worry, you don't need to change anything since we can tweak the coefficient in tiny_2_1.h and get the correct result.
It works very well this way so you don't need to change anything.
I am very pleased by the quality of the tiny 2.11 board and i find it very reliable.
At last there is an autopilot that works and it doesn't cost a fortune...
Of course this is my opinion.
Chris
hendrix is offline Find More Posts by hendrix
Last edited by hendrix; Jun 01, 2008 at 01:36 AM.
Reply With Quote
Old Jun 01, 2008, 02:16 PM
David1
bmw330i's Avatar
USA
Joined Mar 2007
1,478 Posts
Ok, cool, thanks. I know how to do that edit to the library file. I will post the specific edit for my project when I get around to editing it. Would be interesting if everyone posted their value so we could see the range of values. Maybe there is a "default" value that could be used.
Well, today is Sunday and I vowed to get some building done. I need to take some new photos as well of the FunJet as it is. I'll do that then post up an update.
-BMW
bmw330i is offline Find More Posts by bmw330i
Reply With Quote
Old Jun 05, 2008, 07:42 PM View Post
jszeto
A moderator felt this post violated the following rule: Excessive Advertising (Over-competition). It is temporarily hidden while jszeto edits it. Show it to me anyway.
Old Jun 05, 2008, 08:51 PM
David1
bmw330i's Avatar
USA
Joined Mar 2007
1,478 Posts
<snip>
bmw330i is offline Find More Posts by bmw330i
Last edited by bmw330i; Jan 15, 2009 at 05:31 PM. Reason: deleted
Reply With Quote
Old Jun 06, 2008, 12:08 AM
David1
bmw330i's Avatar
USA
Joined Mar 2007
1,478 Posts
Update:

I owe this thread an update. I spent the last week simply trying to get the next order for 100 of the Tiny2.11 placed.

The whole reason for my opening a business was to help people get Paparazzi hardware so that takes a priority to my own Hobby/Build of our Funjet. Soon as everyone is taken care of then I get back to the build. Just want to make sure everyone gets treated like I would want to be treated.

Tomorrow AM I promise to take the FunJet out and snap some photos though. I'm also notified that the LEA_5H may not work with the default Paparazzi code so I'm looking into that. The LEA-5H is so sensitive it gets a fix indoors before I even put the antenna on...for comparison an LEA-4P will not get a fix even with an antenna. So, I'd like to only use the LEA-5H if possible...so tracking down that info now. I will update as I learn about this.
bmw330i is offline Find More Posts by bmw330i
Reply With Quote
Old Jun 06, 2008, 01:57 AM
David1
bmw330i's Avatar
USA
Joined Mar 2007
1,478 Posts
More on the LEA-5H

Ok,

I did a "grep" for POSLLH in the code...I found only one file with reference to it: gps_ubx.c
I belive this is the code:
Code:
void parse_gps_msg( void ) {
  if (ubx_class == UBX_NAV_ID) {
    if (ubx_id == UBX_NAV_STATUS_ID) {
      gps_mode = UBX_NAV_STATUS_GPSfix(ubx_msg_buf);
#ifdef GPS_USE_LATLONG
  /* Computes from (lat, long) in the referenced UTM zone */
} else if (ubx_id == UBX_NAV_POSLLH_ID) {
      gps_lat = UBX_NAV_POSLLH_LAT(ubx_msg_buf);
      gps_lon = UBX_NAV_POSLLH_LON(ubx_msg_buf);
      latlong_utm_of(RadOfDeg(gps_lat/1e7), RadOfDeg(gps_lon/1e7), nav_utm_zone0);
      gps_utm_east = latlong_utm_x * 100;
      gps_utm_north = latlong_utm_y * 100;
      gps_alt = UBX_NAV_POSLLH_HMSL(ubx_msg_buf) / 10;
      gps_utm_zone = nav_utm_zone0;
#else
    } else if (ubx_id == UBX_NAV_POSUTM_ID) {
      gps_utm_east = UBX_NAV_POSUTM_EAST(ubx_msg_buf);
      gps_utm_north = UBX_NAV_POSUTM_NORTH(ubx_msg_buf);
      uint8_t hem = UBX_NAV_POSUTM_HEM(ubx_msg_buf);
      if (hem == UTM_HEM_SOUTH)
        gps_utm_north -= 1000000000; /* Subtract false northing: -10000km */
      gps_alt = UBX_NAV_POSUTM_ALT(ubx_msg_buf);
      gps_utm_zone = UBX_NAV_POSUTM_ZONE(ubx_msg_buf);
#endif
Shouldn't be too difficult. I'm hoping Anton or someone from Paparazzi can chime in here. I think since the LEA-4P will EOL (End of Life) at some point why not at least get the LEA-5H working right? I know the LEA-5H module is popular and I have requests for LEA-5H Tiny2.11.

I will try enabling it myself...as always will report what I find.
bmw330i is offline Find More Posts by bmw330i
Reply With Quote
Old Jun 06, 2008, 02:26 PM
Registered User
Canada, NS, Halifax
Joined Dec 2005
279 Posts
Code option

The code appears to check for the ID string of the GPS data stream. Once you find the version of data stream, and / or set the LEA-5H to a specific data string format permanently, it appears that much of that whole subroutine could be eliminated.

To maintain compatibility across multiple GPS data types this appears to identify the type of data string and then return the results of parsing that string. ( or set the values up in variables that are used elsewhere.) If it was mine I would lock the GPS in a specific mode and delete all the code that references alternate data string types. I am not keen on redundant code that does not get accessed.

Possibly a header file or compile time option could be used to specify the GPS type so only the code for the specific data string parsing would be compiled into the finished code. Doing this throughout the code for various options such as FMA co-pilot Yes or No, and other optional components could make smaller and tighter executable.

Just a consideration.

Jim H
small_rcer is offline Find More Posts by small_rcer
Reply With Quote
Old Jun 06, 2008, 04:45 PM
Registered User
United States, AZ, Yuma
Joined Jun 2007
174 Posts
I believe the LEA-5H works with PPRZ by default you just cannot use the LEA-4P configuration file on the wiki. You need to follow the directions on the wiki and do the settings manually. I distinctly remember reading this in the mailing list
danstah is offline Find More Posts by danstah
Reply With Quote
Old Jun 06, 2008, 05:40 PM
David1
bmw330i's Avatar
USA
Joined Mar 2007
1,478 Posts
Quote:
Originally Posted by danstah
I believe the LEA-5H works with PPRZ by default you just cannot use the LEA-4P configuration file on the wiki. You need to follow the directions on the wiki and do the settings manually. I distinctly remember reading this in the mailing list
Well, yes, true, that is my experience. I did a manual config then saved it so for LEA-5H boards I just upload that LEA-5H file. When I flash in the funjet1.xml file/program and cycle the power the red-led does flash as usual...but that's as far as I have gone.

I suppose I need to just pug in an XBee Module, fire up GPS and see what shows in the display don't I? Ok, I have an LEA-5H Tiny2.11 now in the shop...I have some new v2 (200mW) XBeePro modules I need to test out anyhow...

Now if GCS shows GPS info then can I assume it does work? Is there some other test(s) to run?

-BMW
bmw330i is offline Find More Posts by bmw330i
Reply With Quote
Old Jun 06, 2008, 06:37 PM
Registered User
Joined Jun 2006
12 Posts
Quote:
Originally Posted by bmw330i
This is my build thread. Please advertise your site in your own thread or the vendor forum.

Explanation: Jeffrey owns that site in that URL so basically his contribution here is trying to make a buck.
Sorry man, No offense! I should not be posting the link then! Also, buck doesn't goes into anyones pocket. Fund are setting up a project learning charity, for everyone, especially youngster! If you care to know.

For Papa Project: the more hardware availability, the better, mature & stronger this development will go, If you agree with me.

I will try to put contribution rather, links ! ok

Nice talking to you! have a rewarding day!

Jeffrey
jszeto is offline Find More Posts by jszeto
Reply With Quote
Old Jun 06, 2008, 06:52 PM
Registered User
United States, AZ, Yuma
Joined Jun 2007
174 Posts
Yes if you connect it via the xbee modem and its gets gps and everything is good then it should be fine... Also you could use the ftdi cable to look and see if the gps is good
danstah is offline Find More Posts by danstah
Reply With Quote
Old Jun 06, 2008, 09:04 PM
David1
bmw330i's Avatar
USA
Joined Mar 2007
1,478 Posts
Quote:
Originally Posted by danstah
Yes if you connect it via the xbee modem and its gets gps and everything is good then it should be fine... Also you could use the ftdi cable to look and see if the gps is good
Cool, you mean FTDI to one XBee then plug the other into the Tiny2.11. I have this dongle that lets me plug an XBee into it then I plug that into a free USB port...same thing really. I was going to see about getting more to put on the web store but I doubt anyone would be interested. Surveyor is the source.
bmw330i is offline Find More Posts by bmw330i
Reply With Quote
Reply


Thread Tools