Forum: Mikrocontroller und Digitale Elektronik Bascom CMPS09 Kalibrierung


von fd (Gast)


Lesenswert?

Hallo,

ich versuche den CMPS09 Kompass in Bascom zu kalibrieren:

Calibration the CMPS09
I would recommend evaluating the CMPS09 performance first before 
implementing this function. Its purpose is to remove offsets caused by 
constant magnetic sources around the CMPS09. First of all you need to 
determine North and align the CMPS09 with it, then enter the calibration 
mode by writing 0xF0 to the command register (22). To calibrate the 
first point write 0xF5 to the command register, this should also light 
the LED, then move the object through 90° and write 0xF5 to the command 
register. Repeat this twice more so four points are calibrated and the 
LED should also turn off to confirm calibration completion.

Ich habe ein kurzes Programm geschrieben, was bei Tasterdruck die Punkte 
speichern soll. Jedoch geht die Konfig-LED nicht wie beschrieben an. 
Habe ich einen Fehler?
1
Declare Function Store_point() As Byte
2
Declare Function Init_config() As Byte
3
4
5
$regfile = "m8def.dat"
6
$crystal = 16000000
7
$baud = 9600
8
Config Scl = Portc.5
9
Config Sda = Portc.4
10
 Config I2cdelay = 100
11
12
13
Taster1 Alias Pind.4
14
Config Taster1 = Input
15
Dim Count As Integer
16
17
18
Dim Himmelsrichtung As Word
19
Dim Grad As Single
20
21
   Wait 3
22
   I2cinit
23
24
25
   Do
26
     Debounce Taster1 , 1 , On_taster1 , Sub
27
     Waitms 100
28
   Loop
29
30
End
31
32
33
34
Function Init_config() As Byte
35
Local Cmps_slaveid As Byte
36
37
   Cmps_slaveid = &HC0
38
39
   I2cstart
40
   I2cwbyte Cmps_slaveid
41
   I2cwbyte 22
42
   I2cstop
43
44
   I2cstart
45
   I2cwbyte &HF0
46
   I2cstop
47
48
End Function
49
50
Function Store_point() As Byte
51
Local Cmps_slaveid As Byte
52
53
   Cmps_slaveid = &HC0
54
55
   I2cstart
56
   I2cwbyte Cmps_slaveid
57
   I2cwbyte 22
58
   I2cstop
59
60
   I2cstart
61
   I2cwbyte &HF5
62
   I2cstop
63
64
End Function
65
66
67
68
On_taster1:
69
Dim Bla As Byte
70
71
   If Count = 0 Then
72
      Print "starting calibration"
73
      Bla = Init_config()
74
      Print "config done..:"
75
   End If
76
77
   If Count > 0 Then
78
      Print "setting point " ; Count
79
      Bla = Store_point()
80
      Print "point set"
81
   End If
82
83
   Count = Count + 1
84
85
Return

Danke

von Cheffe2 (Gast)


Lesenswert?

Kalibrierung .... wohl eher Justage!

Cheffe2

von fd (Gast)


Lesenswert?

Naja wie auch immer man es nennen will...

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.