Ich kenne das RN-Control-Ding nicht, wenn das noch externe Pull-Ups nach 5V hat, müssten die weg. Ich meinte die Pull-Ups im AVR die mit dem PORT-Register gesteuert werden.
Druckbare Version
Ich kenne das RN-Control-Ding nicht, wenn das noch externe Pull-Ups nach 5V hat, müssten die weg. Ich meinte die Pull-Ups im AVR die mit dem PORT-Register gesteuert werden.
Und wie mache ich das mit Bascom ?Zitat:
Ich meinte die Pull-Ups im AVR die mit dem PORT-Register gesteuert werden.
Sei mir nicht böse, aber ein klein wenig Eigeninitiative ist doch nicht zu viel verlangt. Du kannst es zB hier ff. nachlesen.
Mit der Eigeninitiative hast du ja recht :)
Das mit dem Port register war mir schon bekannt, doch hatte ich bis eben nicht verstanden, was du damit gemeint hattest...
Kann ich also jetzt ja loslegen und den Sensor anschließen. Kann ich dafür das Programm nutzen ?? : https://www.roboternetz.de/community...hlight=mpu6050
Hat einer von euch mal ein kleines Testprogramm für Bascom ??
Leute ,ich habe keine Ahnung, wie das Programm aussehen soll...
Hier habe ich einfach alles zusammengeschrieben, was ich in dem Link gefunden hatte : Da sind aber einige Fehler drin: Es wäre sehr schön, wenn einer von euch ein fertiges Prog zum testen hätte, anhand ich dann weiterentwickeln kann ...
Code:$regfile = "m32def.dat"
$crystal = 16000000
$baud = 9600
$hwstack = 200
$swstack = 200
$framesize = 400
Config Portd.7 = Output
Config Sda = Portc.1
Config Scl = Portc.0
Config Twi = 100000
Declare Sub Init_mpu
Declare Sub Read_gyro
Declare Sub Read_acc
Dim Tmp_gyrox(2) As Byte
Dim Tmp_gyroy(2) As Byte
Dim Tmp_gyroz(2) As Byte
Dim Tmp_accx(2) As Byte
Dim Tmp_accy(2) As Byte
Dim Tmp_accz(2) As Byte
Sound Portd.7 , 400 , 450
Sound Portd.7 , 400 , 250
Sound Portd.7 , 400 , 450
Wait 2
I2cinit
Call Init_mpu
Do
Call Read_gyro
Print "Tmp_gyrox(2) :" ; Tmp_gyrox(2)
Print "Tmp_gyrox(1) :" ; Tmp_gyrox(1)
Waitms 20
Print "Tmp_gyroy(2) :" ; Tmp_gyroy(2)
Print "Tmp_gyroy(1) :" ; Tmp_gyroy(1)
Waitms 20
Print "Tmp_gyroz(2) :" ; Tmp_gyroz(2)
Print "Tmp_gyroz(1) :" ; Tmp_gyroz(1)
Waitms 100
Call Read_acc
Print "Tmp_accx(2) :" ; Tmp_accx(2)
Print "Tmp_accx(1) :" ; Tmp_accx(1)
Waitms 20
Print "Tmp_accy(2) :" ; Tmp_accy(2)
Print "Tmp_accy(1) :" ; Tmp_accy(1)
Waitms 20
Print "Tmp_accz(2) :" ; Tmp_accz(2)
Print "Tmp_accz(1) :" ; Tmp_accz(1)
Wait 1
Loop
End
Sub Init_mpu()
'--- (25) Sample Rate Divider = 1 ---
I2cstart #2 'start condition
I2cwbyte &HD0 , #2 'write adress of MPU-6050
I2cwbyte 25 , #2 'Register 25 Sample Rate Divider (1..8 kHz)
I2cwbyte &B00000000 , #2 'Divider set to 1 (soll)
I2cstop #2 'stop condition
'--- (26) DLPF = 42/44 Hz ---
I2cstart #2 'start condition
I2cwbyte &HD0 , #2 'write adress of MPU-6050
I2cwbyte 26 , #2 'Register 26 DLPF_CFG (digital lowpass filter) Configuration
I2cwbyte &B00000011 , #2 'Bits 0..2 = 011 (3) - ACC:44Hz, 4.9ms; Gyro:42Hz, 4.8ms
I2cstop #2 'stop condition
'--- (27) Gyro Full Range = +-2000°/s ---
I2cstart #2 'start condition
I2cwbyte &HD0 , #2 'write adress of MPU-6050
I2cwbyte 27 , #2 'Register 27 Gyro Configuration
I2cwbyte &B00011000 , #2 'Bits 3+4 = 11 - Full Scale Range: +/-2000°/s
I2cstop #2 'stop condition
'--- (28) ACC Full Range = +-2g ---
I2cstart #2 'start condition
I2cwbyte &HD0 , #2 'write adress of MPU-6050
I2cwbyte 28 , #2 'Register 28 ACC Configuration
I2cwbyte &B00000000 , #2 'Bits 3+4 = 00 - Full Scale Range: +/-2g / No High Pass Filter
I2cstop #2 'stop condition
'--- (107) Power Management 1 ---
I2cstart #2 'start condition
I2cwbyte &HD0 , #2 'write adress of MPU-6050
I2cwbyte 107 , #2 'Register 107 Power Management 1
I2cwbyte &B00001011 , #2 'No Reset / No Sleep / No Cycle / Temp_Sens: Dis / Clock Source: Z-Gyro
I2cstop #2
End Sub
Sub Read_gyro()
I2cstart #2
I2cwbyte &HD0 , #2
I2cwbyte 67 , #2
I2crepstart #2
I2cwbyte &HD1 , #2
I2crbyte Tmp_gyrox(2) , Ack , #2
I2crbyte Tmp_gyrox(1) , Ack , #2
I2crbyte Tmp_gyroy(2) , Ack , #2
I2crbyte Tmp_gyroy(1) , Ack , #2
I2crbyte Tmp_gyroz(2) , Ack , #2
I2crbyte Tmp_gyroz(1) , Nack , #2
I2cstop #2
'Gyrox = Gx
'Gyroy = 0 - Gy
'Gyroz = 0 - Gz
End Sub
Sub Read_acc()
I2cstart #2
I2cwbyte &HD0 , #2
I2cwbyte 59 , #2
I2crepstart #2
I2cwbyte &HD1 , #2
I2crbyte Tmp_accx(2) , Ack , #2
I2crbyte Tmp_accx(1) , Ack , #2
I2crbyte Tmp_accy(2) , Ack , #2
I2crbyte Tmp_accy(1) , Ack , #2
I2crbyte Tmp_accz(2) , Ack , #2
I2crbyte Tmp_accz(1) , Nack , #2
I2cstop #2
'Accx = Ax
'Accy = Ay
'Accz = Az
End Sub
Hi,
also der Code ist, soweit ich das sehen kann zumindest teilweise von mir ;)
Leider kannst du ihn nicht verwenden, weil du einen ATMega32 hast, d.h. es gibt nur eine TWI-Schnittstelle. Außerdem hast du die Tmp-Variablen falsch definiert.
Niemand wird dir hier einen fertigen Code präsentieren, wir sind hier in einem Forum wo es um Hilfestellung geht. Außer natürlich du postet dein Anliegen im Suche Serviceleistung Forum und hoffst, dass dir jemand da weiterhilft.
Aber wenn du dich nur mal ne Std. einlesen würdest, hättest du wohl schon ein funktionsfähiges Programm (zumindest in Bascom).
Gruß
Chris
Hallo Che Guevara,
Danke dass du dich gemeldet hast :) (darauf habe ich schon gehofft, weil ja das Prog von dir ist )
Ja, darauf habe ich ja in Post 14 hingewiesen (Link)Zitat:
also der Code ist, soweit ich das sehen kann zumindest teilweise von mir
Warum kann ich ihn nicht verwenden ?? Es reicht doch auch ein TWI, oder nicht ??Zitat:
Leider kannst du ihn nicht verwenden, weil du einen ATMega32 hast, d.h. es gibt nur eine TWI-Schnittstelle. Außerdem hast du die Tmp-Variablen falsch definiert.
Mit dem ersten Teil hast du recht. Mit dem zweiten (1Stunde ) nicht !! Dafür bräuchte ich Wochen....Zitat:
Niemand wird dir hier einen fertigen Code präsentieren, wir sind hier in einem Forum wo es um Hilfestellung geht. Außer natürlich du postet dein Anliegen im Suche Serviceleistung Forum und hoffst, dass dir jemand da weiterhilft.
Aber wenn du dich nur mal ne Std. einlesen würdest, hättest du wohl schon ein funktionsfähiges Programm (zumindest in Bascom).
So, da du ja sagtest dies ist ein Hilfeforum stell ich gleich mal zwei Fragen an dich : 1: was sollen die #2 bedeuten (dzu konnt ich nichts in der Bascom-Hilfe finden)
1: Ist das Grundprogramm schon mal richtig oder fehlt noch was wichtiges ??
Guck doch einfach mal in die Bascom Hilfe! http://avrhelp.mcselec.com/index.htm...__i2cwbyte.htm
Zitat:
Syntax
I2CSTART
I2CREPSTART
I2CSTOP
I2CRBYTE var, ack/nack
I2CWBYTE val
Syntax Xmega
I2CSTART #const
I2CREPSTART #const
I2CSTOP #const
I2CRBYTE var, ack/nack , #const
I2CWBYTE val , #const
Remarks
Var A variable that receives the value from the I2C-device. ack/nack Specify ACK if there are more bytes to read.
Specify NACK if it is the last byte to read.Val A variable or constant to write to the I2C-device. #const For the Xmega, a channel constant that was specified with OPEN.
Ich habe in die Bascom Hilfe geschaut, doch habe ich nach # gesucht und nicht in i2cwbyte gesucht.
Dann werde ich mal morgen ein kleines Prog schreiben....
Vielen Dank für eure Hilfe. Entschuldigung, dass ich euch mit meinen dummen Fragen nerve.