Reading Array values into variables


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Question

    Exactly the problem.. I have 3 bytes that need to be put into one variable.. this is a 24 bit container that relates a number - the altitude in tenths of meters..

    How to get this into ONE variable I can work with is the first issue..

    Tom

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi, Tom

    Let's have another view of the problem ...

    You get an altitude measurement, ...but what is your sensor ??? and mostly what is its precision ???

    I do not know lots of altitude sensors seriously able to give 1 cm on a hundred meters ... 1/10 000 precision, you sure ??? ... !!!

    May be a little look here could reduce your number sizes ...and simplify you work.

    24 and 32 bits arithmetics can be downloded from Melabs site ... if you really want to keep "ghost" centimeters !!!

    Alain

  3. #3
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Default

    Hi Tom,

    What ranges are we talking about? Are you interested in altitudes higher than 21501 feet? If not, you can treat your input as a word(skip top 8 bits) and do your calculations on that. If you need to go higher, things will get more complicated but still possible. Higher than 65535 feet will get nasty ....

    Do you really need 0.1m(0.3feet) resolution? Will 1m(3feet) enough?

    Another thing .... you need to know how your inputdata(24bits) is formatted. My guess(based on your information) is that you are located at about 1096 feet. I'm assuming that "alt[3]" contains the most significant byte, 0,13,13 would be 000D0D in hex which is 3341 in decimal. 3341 tenths of a metre is 334.1m which is 334.1*3.28084=1096 feet.

    /Ingvar

  4. #4
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Default

    Thanks for the responses..

    The precision is only tenths of meters. I don't know *why* the data is stored in 24 bits, it just is - not under my control, I am only trying to read it.

    Regardless - the fundamental problem is that I have a 24 bit value stored in 3 bytes that I need to make into a variable I can do something with..... like read it digit by digit, and put a "." in the tenth's spot, and then multiply it by a factor to convert to feet..

    TG

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Smile

    Have a look to that thread :
    http://www.picbasic.co.uk/forum/showthread.php?t=1217

    here you have the solution to put your 24 bits into something usable ... just divide them as soon to reduce it to less than 16 bits ...

    and that's all !!!

    Alain

  6. #6
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Question

    And the answers to my questions are ...... ? Can't help if i don't know.

    /Ingvar

  7. #7
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Default

    Oh- yes, sorry.

    We are at about 300ft. Should be reading about 100meters or so. The GPS alt data 'wanders' so tenths of meters is a little silly, yes, but that is what is output.

    The full range would want to support over 100,000ft in altitude.

    TOm

Similar Threads

  1. Simple Array Demo
    By Archangel in forum Code Examples
    Replies: 5
    Last Post: - 15th February 2010, 04:46
  2. Array values changing
    By MyBuddy in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th October 2009, 23:13
  3. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 08:02
  4. Seeting array variables in For-Next loop
    By bcd in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th October 2007, 07:01
  5. Putting values into an array
    By Vince in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd December 2003, 07:22

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts