-
Data: 2013-08-08 12:36:29
Temat: Re: atmega i lcd + pamiec
Od: wchpikus <w...@w...wp.pl> szukaj wiadomości tego autora
[ pokaż wszystkie nagłówki ]W dniu 2013-08-08 12:18, Grzegorz Niemirowski pisze:
> wchpikus <w...@w...wp.pl> napisał(a):
>> Ma ktos lub zna jakas prosta obsluge BMP085 w Bascomie?
>> 20k samej obslugi tego czujika...to jakas paranoja:(
>
> Gdzie jest paranoja? Wszystko masz jasno opisane w datasheecie,
> zaimplementuj to, co tam piszą. Komunikacja jest po I2C, Bascom na pewno
> to obsługuje. Potem zostaje Ci kalibracja, obliczenie temperatury i
> ciśnienia. Najpierw opanuj odczyt i zapis rejestrów czujnika po I2C.
>
Mam kilka przykladow, ale nie ogarniam za bardzo...
mozesz podac mi jakis prosty przyklad?
mam taki, ale troche za duzo wazy jak dla mnie, tem moge usunac,
wysokosc tez...
Niestety po niemiecku bazgrane:)
'---------------------------------------------------
-----------------------------
'ďđîăđŕěěŕ äë˙ îďđîńŕ äŕň÷čęŕ BMP085
'ń äŕň÷čęŕ ďđčíčěŕĺňń˙ çíŕ÷ĺíčĺ ňĺěďĺđŕňóđű, ŕáńîëţňíîăî äŕâëĺíč˙ č
âűńîňű íŕä óđîâíĺě ěîđ˙
'äŕííűĺ ďîëó÷ĺííűĺ ń ńĺíńîđŕ îňďđŕâë˙ţňń˙ â ňĺđěčíŕë
'AVRproject.ru 2012
'---------------------------------------------------
-----------------------------
$regfile = "m32def.dat"
$crystal = 1000000
Config Graphlcd = 240 * 64 , Dataport = Portc , Controlport = Portd , Ce
= 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6
Cls
Cursor Off
'ęîíôčăóđŕöč˙ I2C
Config Sda = Portb.6
Config Scl = Portb.7
I2cinit
Config Porta.2 = Output 'podswietlenie
Podsw Alias Porta.2
Podsw = 0
Dim Ac1 As Integer
Dim Ac1a As Long
Dim Ac2 As Integer
Dim Ac3 As Integer
Dim Ac4 As Word
Dim Ac5 As Word
Dim Ac5a As Single
Dim Ac6 As Word
Dim B1 As Integer
Dim B2 As Integer
Dim B3 As Long
Dim B3a As Long
Dim B4 As Long
Dim B5 As Long
Dim B6 As Integer
Dim B6a As Long
Dim B7 As Long
Dim Mb As Integer
Dim Mc As Integer
Dim Mc2 As Long
Dim Md As Integer
Dim Adres As Byte
Dim Wert As Byte
Dim Ut As Long
Dim X1 As Long
Dim X1t As Single
Dim X2 As Long
Dim X3 As Long
Dim T As Single
Dim T2 As Long
Dim Temperatur As String * 6
Dim Luftdruck As String * 8
Dim Druck As Single
Dim P As Long
Dim P2 As Long
Dim 2potenz15 As Long
Dim 2potenz11 As Integer
Dim 2potenz13 As Integer
Dim 2potenz8 As Integer
Dim 2potenz4 As Integer
Dim 2potenz2 As Integer
Dim 2potenz16 As Long
Dim 2potenz12 As Integer
Dim Potenz5255 As Single
Dim Altitude As Single
Dim Altitudes As String * 8
Dim Msb As Long
Dim Lsb As Long
Dim Up As Long
Dim Druckvar As Byte
Declare Sub Berechne_temp
Declare Sub Berechne_druck
Declare Sub Schreibe_bmp085(byval Adres As Byte , Byval Wert As Byte)
Declare Sub Lese_bmp085(byval Adres As Byte , Wert As Byte)
Declare Sub Lese_roh_daten
Declare Sub Messen
Declare Sub Lese_kalib_data
Const Addr_schreiben = &B11101110 'ŕäđĺń
ěčęđîńőĺěű + çŕďčńü
Const Addr_lesen = &B11101111 'ŕäđĺń
ěčęđîńőĺěű + ÷ňĺíčĺ
Call Lese_kalib_data
Do
Call Messen
T = T / 10
Temperatur = Fusing(t , "###.##")
Potenz5255 = 1 / 5.255
Altitude = P / 101325
Altitude = Altitude ^ Potenz5255
Altitude = 1 - Altitude
Altitude = Altitude * 44330
Druck = P
Druck = Druck / 100
Luftdruck = Fusing(druck , "####.##")
Altitudes = Fusing(altitude , "#####.##")
Locate 1 , 1
Lcd "Temp " ; Temperatur ; " C,"
Locate 2 , 1
Lcd " Pressure " ; Luftdruck ; " Pa,"
Locate 3 , 1
Lcd ; " Altitude " ; Altitudes ; " m."
Wait 1
Loop
Sub Messen
Locate 2 , 1
Lcd "Messen"
'Čçěĺđĺíčĺ ňĺěďĺđŕňóđű
Call Schreibe_bmp085(&Hf4 , &H2E)
Adres = &HF6
Call Lese_roh_daten
'Print "msb " ; Msb
'Print "lsb " ; Lsb
Shift Msb , Left , 8
'Print "msb shift " ; Msb
Ut = Msb + Lsb
Call Berechne_temp
'Čçěĺđĺíčĺ äŕâëĺíč˙
Call Schreibe_bmp085(&Hf4 , &H74 )
Adres = &HF6
Call Lese_roh_daten
Shift Msb , Left , 16
Shift Lsb , Left , 8
Up = Msb + Lsb
Shift Up , Right , 6
'Print "msb " ; Msb ; "lsb " ; Lsb ; "up " ; Up
Call Berechne_druck
End Sub
Sub Berechne_temp
'X1
Ut = Ut - Ac6
2potenz15 = 2 ^ 15
Ac5a = Ac5 / 2potenz15
X1t = Ut * Ac5a
'Print "X1 " ; X1t
'X2
2potenz11 = 2 ^ 11
Mc2 = Mc * 2potenz11
X3 = X1t + Md
X2 = Mc2 / X3
'Print "X2 " ; X2
'B5
B5 = X1t + X2
'Print "B5 " ; B5
'T
2potenz4 = 2 ^ 4
T2 = B5 + 8
T = T2 / 2potenz4
End Sub
Sub Berechne_druck
'B6
B6 = B5 - 4000
'X1
2potenz12 = 2 ^ 12
B6a = B6 * B6
B6a = B6a / 2potenz12
X1 = B2 * B6a
X1 = X1 / 2potenz11
'X2
X2 = Ac2 * B6
X2 = X2 / 2potenz11
'X3
X3 = X1 + X2
'B3
Ac1a = Ac1 * 4
Ac1a = Ac1a + X3
Shift Ac1a , Left , 2
Ac1a = Ac1a + 2
B3 = Ac1a / 4
'X1 die zweite
2potenz13 = 2 ^ 13
B6a = B6 / 2potenz13
X1 = Ac3 * B6a
'X2 die zweite
B6a = B6 * B6
B6a = B6a / 2potenz12
X2 = B1 * B6a
2potenz16 = 2 ^ 16
X2 = X2 / 2potenz16
'X3 die zweite
X3 = X1 + X2
X3 = X3 + 2
2potenz2 = 2 ^ 2
X3 = X3 / 2potenz2
'B4
B4 = X3 + 32768
B4 = B4 * Ac4
B4 = B4 / 2potenz15
If B4 <= 0 Then B4 = B4 * -1
'Print B4
'B7
B7 = Up - B3
B3a = 50000
Shift B3a , Right , 2 '
B7 = B7 * B3a
If B7 <= 0 Then B7 = B7 * -1
'Print B7
If B7 < &H80000000 Then
P = B7 * 2
'Print "p1 " ; P
P = P / B4
'Print "p1 " ; P
Else
P = B7 / B4
'Print "p2 " ; P
P = P * 2
'Print "p2 " ; P
End If
'Print P
'nochmal X1
2potenz8 = 2 ^ 8
P2 = P / 2potenz8
X1 = P2 * P2
'Print X1
X1 = X1 * 3038
X1 = X1 / 2potenz16
'Print X1
' nochmal X2
X2 = -7357 * P
X2 = X2 / 2potenz16
'Print X2
P2 = P
P = X2 + 3791
P = P + X1
P = P / 2potenz4
P = P + P2
End Sub
Sub Lese_kalib_data
Locate 1 , 1
Lcd "Lese_kalib_data "
Adres = &HAA
'Ac1 lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
Ac1 = Msb + Lsb
Adres = Adres + 1
'Ac2 lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
Ac2 = Msb + Lsb
Adres = Adres + 1
'Ac3 lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
Ac3 = Msb + Lsb
Adres = Adres + 1
'Ac4 lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
Ac4 = Msb + Lsb
Adres = Adres + 1
'Ac5 lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
Ac5 = Msb + Lsb
Adres = Adres + 1
'Ac6 lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
Ac6 = Msb + Lsb
Adres = Adres + 1
'B1 lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
B1 = Msb + Lsb
Adres = Adres + 1
'B2 lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
B2 = Msb + Lsb
Adres = Adres + 1
'MB lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
Mb = Msb + Lsb
Adres = Adres + 1
'MB lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
Mc = Msb + Lsb
Adres = Adres + 1
'Md lesen
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
Shift Msb , Left , 8
Md = Msb + Lsb
Adres = Adres + 1
End Sub
Sub Lese_roh_daten
Call Lese_bmp085(adres , Wert)
Msb = Wert
Adres = Adres + 1
Call Lese_bmp085(adres , Wert)
Lsb = Wert
End Sub
Sub Schreibe_bmp085(byval Adres As Byte , Byval Wert As Byte)
I2cstart
I2cwbyte Addr_schreiben
I2cwbyte Adres
I2cwbyte Wert
I2cstop
Waitms 10
End Sub
Sub Lese_bmp085(byval Adres As Byte , Wert As Byte)
I2cstart
I2cwbyte Addr_schreiben
I2cwbyte Adres
I2cstart
I2cwbyte Addr_lesen
I2crbyte Wert , Nack
I2cstop
Waitms 10
End Sub
Następne wpisy z tego wątku
- 08.08.13 13:06 Grzegorz Niemirowski
- 09.08.13 08:36 wchpikus
- 09.08.13 09:16 RoMan Mandziejewicz
Najnowsze wątki z tej grupy
- Światłowód między budynkami
- POtrzebny bufor 3.3<>5V, jedonkieruowy, trójstanowy, wąski
- retro
- Bezprzewodowe polączenie Windows z projektorem
- rozklejanie obudowy
- Prośba o identyfikację komponentu
- Smart gniazdko straciło na zasięgu wifi?
- Smart gniazdko straciło zasięg wifi?
- nurtuje mnie
- dziwna sprawa...
- Laptop MSI się nie uruchamia.
- Dobra listwa LED (CRI 90-95, bez migotania)
- masowe programowanie AVR
- Fajny pomysł na monitor z klawiaturą
- Sprzedawanie zaszyfrowanych filmów na płytach Blu-Ray bez kluczy deszyfrujących
Najnowsze wątki
- 2024-11-02 piszę list do św Mikołaja
- 2024-11-01 karta SIM nie działa w konkretnym smartfonie.
- 2024-11-01 Mamy WZROST! O 50% wzrosła ilość kredytów gotówkowych
- 2024-11-01 Warszawa => Expert Recruiter 360 <=
- 2024-11-01 Warszawa => Technical Leader (Java Background) <=
- 2024-11-01 Warszawa => Account Manager - Usługi rekrutacyjne <=
- 2024-11-01 Warszawa => Head of International Freight Forwarding Department <=
- 2024-11-01 Warszawa => Programista Dynamics 365 CRM <=
- 2024-11-01 Warszawa => Dynamics 365 CRM Developer <=
- 2024-11-01 Warszawa => Junior Rekruter <=
- 2024-11-01 Chrzanów => Specjalista ds. PR Produktowego <=
- 2024-11-01 Białystok => Full Stack web developer (obszar .Net Core, Angular6+) <
- 2024-11-01 Łódź => Frontend Engineer (Three.js) <=
- 2024-11-01 Warszawa => Junior Rekruter <=
- 2024-11-01 Gdańsk => Programista Full Stack .Net <=