- MultiPlus Wechselrichter Insel und Nulleinspeisung Conrad         
Ergebnis 1 bis 1 von 1

Thema: 3D kompass. Rechnung

  1. #1
    Benutzer Stammmitglied
    Registriert seit
    09.02.2013
    Beiträge
    51

    3D kompass. Rechnung

    Anzeige

    LiFePo4 Akku selber bauen - Video
    Hallo RN,
    ich lese so meinen 3D Kompass aus:
    Code:
    #!/usr/bin/env python3
    import time
    import random
    import smbus
    import math
    import serial
    
    
    while True:
        mitte = 0
        bus.write_byte_data(address,0,80)
        bus.write_byte_data(address,1,32)
    
        bus.write_byte_data(address,2,1)    
        time.sleep(0.01)
        x = y = z = 1.0 
        x = y = z = 1.0
        x1=bus.read_byte_data(address,3)
        x2=bus.read_byte_data(address,4)
        z1=bus.read_byte_data(address,5)
        z2=bus.read_byte_data(address,6)
        y1=bus.read_byte_data(address,7)
        y2=bus.read_byte_data(address,8)
    Jetzt möchte ich den Winkel nach Norden ausrechnen. Kann mir wer helfen :/
    Ich würde nun gerne den Winkel unabhängig von der Neigung des Modules berechnen.
    LG
    Versuch 1:
    Code:
    #!/usr/bin/env python3
    import time
    import random
    import smbus
    import math
    import serial
    
    bus = smbus.SMBus(1)
    address = 0x1e
    while True:
        mitte = 0
        bus.write_byte_data(address,0,80)
        bus.write_byte_data(address,1,32)
    
        bus.write_byte_data(address,2,1)    
        time.sleep(0.01)
        x = y = z = 1.0 
        x = y = z = 1.0
        x1=bus.read_byte_data(address,3)
        x2=bus.read_byte_data(address,4)
        x=x1*256.0+x2
    
        if x>32767:
            x-=65536
            z1=bus.read_byte_data(address,5)
            z2=bus.read_byte_data(address,6)
            z=z1*256.0+z2
     
        if z>32767:
            z-=65536
            y1=bus.read_byte_data(address,7)
            y2=bus.read_byte_data(address,8)
            y=y1*256.0+y2
     
        if y>32767:
            y-=65536
    
    
        #print"teyt",x,y,z
        ang = 180+round(math.atan2(x, y)*(180/math.pi),0)
    
        print"winkel",ang
    bringt allerdings nur werte bis 270grad...kann mir wer helfen?
    Geändert von Spacecam (12.08.2013 um 17:49 Uhr)

Ähnliche Themen

  1. Hexaservos + Rechnung
    Von Andi_K im Forum Motoren
    Antworten: 9
    Letzter Beitrag: 26.03.2013, 08:37
  2. Problem mit Rechnung
    Von Bomberpilot im Forum Elektronik
    Antworten: 4
    Letzter Beitrag: 10.02.2011, 09:39
  3. % Rechnung
    Von Marco78 im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 6
    Letzter Beitrag: 19.03.2005, 12:17
  4. Rechnung mit Bascom
    Von Spurius im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 4
    Letzter Beitrag: 31.01.2005, 07:01
  5. einfache rechnung
    Von Adam im Forum Elektronik
    Antworten: 4
    Letzter Beitrag: 06.10.2004, 21:50

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Solar Speicher und Akkus Tests