Altimeter and LCD+ example code

Started by greatwitenorth March 30, 2004
Does anyone know of a web site with code for building and altimeter
with the lcd+ and bx-24? Also if i needed to enter in new numbers
to my program thorugh a keypad hooked up to the lcd+ what would be
the easiest way to do that? One digit is easy, just wait for it and
assign it to a variable. But what if i have three or four digit
numbers?
thanks
nick



--- In , "greatwitenorth" <greatwitenorth@y...>
wrote:
> [I]f i needed to enter in new numbers to my program thorugh a
> keypad hooked up to the lcd+ what would be the easiest way to
> do that? One digit is easy, just wait for it and assign it
? to a variable. But what if i have three or four digit
> numbers?

Two strategies come to mind: require the user to enter a specified
number of digits OR allow them to enter a number of digits followed
by and "Enter" key.

In one of my apps, I implemented the latter strategy. Below is some
code that retrieves an unsigned long value from the keypad. It
relies on a function called waitKey() that returns an ASCII key
value; the digits 0 to 9 wil be values &H30 to &H39. It also
displays the characters as they are entered using the function
DisplayChar(). Invalid characters are not accepted nor displayed and
an annoying sound is emitted using the Beep() function.

You could embellish this function by allowing for an escape key or a
backspace key. You can also make the obvious changes to support
signed integers and add a state machine or similar logic to support
floating point numbers.

'---------------------------------
----------
'
'' GetUVal
'
' Get an unsigned integer value from the keyboard terminated by an
Enter key. If
' no value is entered before the Enter key is pressed, ignore the
Enter key.
'
Function GetUVal() as UNSIGNEDLONG
Set GetUVal = New UNSIGNEDLONG
Dim key as Byte
Dim Val as Long
Dim ValChars as Integer

Val = 0
ValChars = 0

Do
key = waitKey()
If (Key <> 0) Then
If (Key = ENTER_KEY) Then
' "Enter" was pressed
If (ValChars > 0) Then
Exit Do
Else
' no value characters entered
yet
Key = 0
End If
ElseIf ((key >= &H30) And (key <= &H39)) Then
' digit key was pressed
If ((Key <> &H30) Or (Val <> 0)) Then
' add to value
Val = (Val * 10) + CLng(Key -
&H30)
End If
ValChars = ValChars + 1
Else
Call Beep()
key = 0
End If
If (Key <> 0) then
DisplayChar(Key)
End If
End If
Loop
GetUVal = CULng(Val)
End Function


--- greatwitenorth <> wrote:
> Does anyone know of a web site with code for
> building and altimeter
> with the lcd+ and bx-24? Also if i needed to enter
> in new numbers
> to my program thorugh a keypad hooked up to the lcd+
> what would be
> the easiest way to do that? One digit is easy, just
> wait for it and
> assign it to a variable. But what if i have three
> or four digit
> numbers?
> thanks
> nick
> Nick I have done this for a mode -c output of a
blind encoder which puts out 100 foot increments by
a grey code parallel 10 bit method sometime ago
easily using a lookup table. But you could use a
solid state pressure sensor and a piecewise
approximation for the altitude versus barometric
pressure at segments of its output. This would envolve
calculating the slope and intercept for the nonlinear
portions of the altitude versus pressure. The
compensation for the barometric window would be using
a potentiometer read by a analog input as well. This
would allow a zero offset for the changes in the daily
changes in weather.
> This would be a piece of cake with the BX24's math
capability which reduces the lookup table memory
requirements. If the onboard analog input isn't high
enough resolution use one of the inexpensive serial
input analog to digital converters. I have run my
own aircraft instrument shop before retiring and
can provide you with the pressure versus altitude
table if you are without. A company called Sandia labs
makes a blind encoder that puts out serial data
for aircraft GPS receivers in 10 foot increments if
you want a easier way but it costs around 250 dollars.

I hope you can use this information for a guide.

Thanks Bill

__________________________________




Bill
I've often wondered if the correction for QNH is done in the Mode
C encoder, or at the SSR interrogating station. Commonsense tells me it
must be done at the ground station. Do you know ?

Neil.




--- Neil Jepsen <> wrote:
> Bill
> I've often wondered if the correction for QNH
> is done in the Mode
> C encoder, or at the SSR interrogating station.
> Commonsense tells me it
> must be done at the ground station. Do you know ?
>
> Neil.
>
Neil as I understand it the correction in a small
aircraft is done by the ground station as the mode-c
encoder is left always reporting relative to 29.92 or
1013 mbs. I'm not sure now whether this might be
automatically broadcast to the commercial airlines
digitally to self correct it. Maybe someone knows
whether they are still cranking it in manually. They
are using air data computers for several complex
pieces of information including true airspeed. I
very seldom see anyone ask about aircraft applications
with the BX24 and I found the math capabilities
out weigh most of the other small basic programs.

Nice talking with you.

Bill
__________________________________




Thanks Bill. I own 3 light aircraft and all three mode C encoders are
the same, and the SSR reads my height to within 50 feet or so
irrespective of the QNH. Of course with a QNH change from 995 to 1030
mb, that represents a potential error of quite q few feet! Assumed it
must be corrected on the ground.
neil

knapp bill wrote:

> --- Neil Jepsen <> wrote:
> > Bill
> > I've often wondered if the correction for QNH
> > is done in the Mode
> > C encoder, or at the SSR interrogating station.
> > Commonsense tells me it
> > must be done at the ground station. Do you know ?
> >
> > Neil.
> >
> Neil as I understand it the correction in a small
> aircraft is done by the ground station as the mode-c
> encoder is left always reporting relative to 29.92 or
> 1013 mbs. I'm not sure now whether this might be
> automatically broadcast to the commercial airlines
> digitally to self correct it. Maybe someone knows
> whether they are still cranking it in manually. They
> are using air data computers for several complex
> pieces of information including true airspeed. I
> very seldom see anyone ask about aircraft applications
> with the BX24 and I found the math capabilities
> out weigh most of the other small basic programs.
>
> Nice talking with you.
>
> Bill >
> __________________________________ > *>.





Thanks guys I think that should get me going on my way. Oh yeah on
more thing though, I want my barometric pressure to show up to one
decimal point in kPa (as well as temperature). Is there any way to
have a number that large (20.0 to 104.0) retain decimals. After
looking at the language reference it said single variables could
only go up to 3.402..... I guess I could divide by 1000 but that
makes the code much harder to work with my equations.
thanks again
Nick
--- In , Neil Jepsen <njepsen@i...> wrote:
> Thanks Bill. I own 3 light aircraft and all three mode C encoders
are
> the same, and the SSR reads my height to within 50 feet or so
> irrespective of the QNH. Of course with a QNH change from 995 to
1030
> mb, that represents a potential error of quite q few feet!
Assumed it
> must be corrected on the ground.
> neil
>
> knapp bill wrote:
>
> > --- Neil Jepsen <njepsen@i...> wrote:
> > > Bill
> > > I've often wondered if the correction for QNH
> > > is done in the Mode
> > > C encoder, or at the SSR interrogating station.
> > > Commonsense tells me it
> > > must be done at the ground station. Do you know ?
> > >
> > > Neil.
> > >
> > Neil as I understand it the correction in a small
> > aircraft is done by the ground station as the mode-c
> > encoder is left always reporting relative to 29.92 or
> > 1013 mbs. I'm not sure now whether this might be
> > automatically broadcast to the commercial airlines
> > digitally to self correct it. Maybe someone knows
> > whether they are still cranking it in manually. They
> > are using air data computers for several complex
> > pieces of information including true airspeed. I
> > very seldom see anyone ask about aircraft applications
> > with the BX24 and I found the math capabilities
> > out weigh most of the other small basic programs.
> >
> > Nice talking with you.
> >
> > Bill
> >
> >
> >
> > __________________________________
> >
> > -----------------------------
-------
> > *>.
> >
> >





Nick
Singles will go to 3.4 x 10^38 Thats a LARGE number.
3402823000000000000000000000000000000.0
neil

greatwitenorth wrote:

> Thanks guys I think that should get me going on my way. Oh yeah on
> more thing though, I want my barometric pressure to show up to one
> decimal point in kPa (as well as temperature). Is there any way to
> have a number that large (20.0 to 104.0) retain decimals. After
> looking at the language reference it said single variables could
> only go up to 3.402..... I guess I could divide by 1000 but that
> makes the code much harder to work with my equations.
> thanks again
> Nick >
> --- In , Neil Jepsen <njepsen@i...> wrote:
> > Thanks Bill. I own 3 light aircraft and all three mode C encoders
> are
> > the same, and the SSR reads my height to within 50 feet or so
> > irrespective of the QNH. Of course with a QNH change from 995 to
> 1030
> > mb, that represents a potential error of quite q few feet!
> Assumed it
> > must be corrected on the ground.
> > neil
> >
> > knapp bill wrote:
> >
> > > --- Neil Jepsen <njepsen@i...> wrote:
> > > > Bill
> > > > I've often wondered if the correction for QNH
> > > > is done in the Mode
> > > > C encoder, or at the SSR interrogating station.
> > > > Commonsense tells me it
> > > > must be done at the ground station. Do you know ?
> > > >
> > > > Neil.
> > > >
> > > Neil as I understand it the correction in a small
> > > aircraft is done by the ground station as the mode-c
> > > encoder is left always reporting relative to 29.92 or
> > > 1013 mbs. I'm not sure now whether this might be
> > > automatically broadcast to the commercial airlines
> > > digitally to self correct it. Maybe someone knows
> > > whether they are still cranking it in manually. They
> > > are using air data computers for several complex
> > > pieces of information including true airspeed. I
> > > very seldom see anyone ask about aircraft applications
> > > with the BX24 and I found the math capabilities
> > > out weigh most of the other small basic programs.
> > >
> > > Nice talking with you.
> > >
> > > Bill
> > >
> > >
> > >
> > > __________________________________
> > >
> > > -----------------------------
> -------
> > > *>.
> > >
> > >
> *>.





yep i'm an idiot, didn't really read E+28 part in the manual. Sorry
about that. It will sure make things easier though.
Nick
--- In , Neil Jepsen <njepsen@i...> wrote:
> Nick
> Singles will go to 3.4 x 10^38 Thats a LARGE number.
> 3402823000000000000000000000000000000.0
> neil
>
> greatwitenorth wrote:
>
> > Thanks guys I think that should get me going on my way. Oh yeah
on
> > more thing though, I want my barometric pressure to show up to
one
> > decimal point in kPa (as well as temperature). Is there any way
to
> > have a number that large (20.0 to 104.0) retain decimals. After
> > looking at the language reference it said single variables could
> > only go up to 3.402..... I guess I could divide by 1000 but that
> > makes the code much harder to work with my equations.
> > thanks again
> > Nick
> >
> >
> >
> > --- In , Neil Jepsen <njepsen@i...> wrote:
> > > Thanks Bill. I own 3 light aircraft and all three mode C
encoders
> > are
> > > the same, and the SSR reads my height to within 50 feet or so
> > > irrespective of the QNH. Of course with a QNH change from 995
to
> > 1030
> > > mb, that represents a potential error of quite q few feet!
> > Assumed it
> > > must be corrected on the ground.
> > > neil
> > >
> > > knapp bill wrote:
> > >
> > > > --- Neil Jepsen <njepsen@i...> wrote:
> > > > > Bill
> > > > > I've often wondered if the correction for QNH
> > > > > is done in the Mode
> > > > > C encoder, or at the SSR interrogating station.
> > > > > Commonsense tells me it
> > > > > must be done at the ground station. Do you know ?
> > > > >
> > > > > Neil.
> > > > >
> > > > Neil as I understand it the correction in a small
> > > > aircraft is done by the ground station as the mode-c
> > > > encoder is left always reporting relative to 29.92 or
> > > > 1013 mbs. I'm not sure now whether this might be
> > > > automatically broadcast to the commercial airlines
> > > > digitally to self correct it. Maybe someone knows
> > > > whether they are still cranking it in manually. They
> > > > are using air data computers for several complex
> > > > pieces of information including true airspeed. I
> > > > very seldom see anyone ask about aircraft applications
> > > > with the BX24 and I found the math capabilities
> > > > out weigh most of the other small basic programs.
> > > >
> > > > Nice talking with you.
> > > >
> > > > Bill
> > > >
> > > >
> > > >
> > > > __________________________________
> > > >
> > > > -------------------------
----
> > -------
> > > > *>.
> > > >
> > > >
> >
> >
> > -----------------------------
-------
> > *>.
> >
> >




I have used LCD+ with an atmel atmega16 micro. I used BASCOM (basic) to
write the code.
I used a 16 key keypad connected to the lcd+. And the atmega on the serial
port.
I have code written to get the date and time from the user. Basically I just
print strings to the LCD+ to display prompts. And the keypad sends out a
char on the lcd+ serial port when you press a key. So I listen to the serial
port for the char.

I can post the code if you like.

JoeT
PS
some day I will get to basicx

-----Original Message-----
From: greatwitenorth [mailto:]
Sent: Tuesday, March 30, 2004 10:35 AM
To:
Subject: [BasicX] Altimeter and LCD+ example code Does anyone know of a web site with code for building and altimeter
with the lcd+ and bx-24? Also if i needed to enter in new numbers
to my program thorugh a keypad hooked up to the lcd+ what would be
the easiest way to do that? One digit is easy, just wait for it and
assign it to a variable. But what if i have three or four digit
numbers?
thanks
nick Yahoo! Groups Links