Hallo,
ich könnte die ein beispiel geben wie man es bei der CControl 2 macht...kannst du ja in basic umwandeln...
mfg uwe
Hallo!
Ich würd ja echt gern die Suche verwenden, aber das Forum geht schon seit gestern nicht merh so gut
Und wo anders als im Forum hab ich nichts Brauchbares gefunden.
Ich würd gern die Ultraschallentfernungssensoren SRF08 adressieren. Dazu hab ich mir Datenblatt durchgelesen. Aber ich fürchte ich bin komplett auf dem falschen Weg
mehr nicht...Code:I2cinit I2cstart I2cwbyte 224 I2cwbyte 160 I2cwbyte 170 I2cwbyte 165 I2cwbyte 242 I2cstop
Es wär recht dringend, wär mir eine große Hilfe, wenn das morgen schon läuft (sprich... heute noch)
mfg
Hallo,
ich könnte die ein beispiel geben wie man es bei der CControl 2 macht...kannst du ja in basic umwandeln...
mfg uwe
ja, das wär nett, aber ob ich es in basic umwandeln kann....
mal schaun, vielleicht schaff is es (mein basic ist nicht das beste)
mfg
Hi...
Hier ist die Funktion
function SetAddress (byte addrSrc, byte addrTarg)
{
i2c.cstart (addrSrc);
i2c.write (0); // Register 0 Command Register
i2c.write (0xa0); // 1. Byte Sequ.
i2c.start (addrSrc);
i2c.write (0); // Register 0 Command Register
i2c.write (0xaa); // 2. Byte Sequ.
i2c.start (addrSrc);
i2c.write (0); // Register 0 Command Register
i2c.write (0xa5); // 3. Byte Sequ.
i2c.start (addrSrc);
i2c.write (0); // Register 0 Command Register
i2c.write (addrTarg);
i2c.stop();
}
hoffe es hilft dir...
mfg uwe
noch ein frage:
es heißt, dass nur ein einziges gerät am I2C bus hängen darf, wenn man ein modul neu addressiert. muss ich dann den cocontroller, die pcfs, usw. alles aus dem rnbfra1.2 rausnehmen bevor ich das mach?
hier übrigens der code. ich hoff das stimmt.
mfgCode:$regfile = "m32def.dat" $crystal = 8000000 $baud = 9600 Config Scl = Portc.0 Config Sda = Portc.1 I2cstart I2cwbyte 0 'Register 0 Command Register I2cwbyte &HA0 '1. Byte Sequ. I2cstart I2cwbyte 0 'Register 0 Command Register I2cwbyte &HAA '2. Byte Sequ. I2cstart I2cwbyte 0 'Register 0 Command Register I2cwbyte &HA5 '3. Byte Sequ. I2cstart I2cwbyte 0 'Register 0 Command Register I2cwbyte &HF2 'new address I2cstop
nagut, ich hab jetzt mal meinen code geladen aber es hat sich nix getan
wer kann helfen?
mfg, dave
So gehts, so läuft auch mein roboter rumZitat von Daveler
Dim Sonardistance As Word 'entfernung vom objekt 3-10965cm
Sonardistance = Sonarread(sonaraddr , 2)
Declare Function Sonarread(byval I2cnode As Byte , Byval Loc As Byte) As Word ' sonar auslesen
Declare Sub Sonarping(byval I2cnode As Byte , Byval Loc As Byte , Byval Value As Byte) 'echo aussenden
'#################### sonarsteuerung ###########################################
Sub Sonarinit
I2cwbyte &HE0
I2cwbyte 1 'verstärkungsregister
I2cwbyte 1 'unempfindlich
I2cstop
Waitms 65
End Sub Sonarinit
Sub Sonarping(byval I2cnode As Byte , Loc As Byte , Value As Byte)
Waitms 25
I2cstart
I2cwbyte 0
I2cwbyte 0
I2cwbyte 81
I2cstop
Waitms 55
End Sub Sonarping
Function Sonarread(byval I2cnode As Byte , Loc As Byte) As Word
Waitms 25
Local Lsb As Byte
Local Msb As Byte
I2cstart
I2cwbyte I2cnode
I2cwbyte Loc
I2cstart
Incr I2cnode 'lesen immer eine adresse höher wie schreiben
I2cwbyte I2cnode
I2crbyte Msb , Ack
I2crbyte Lsb , Nack
I2cstop
Waitms 25
Sonarread = Makeint(lsb , Msb)
End Function
sodale, ich habs jetzt so gemacht:
so funktioniertsCode:$regfile = "m32def.dat" $Crystal = 8000000 $baud = 9600 Config Scl = Portc.0 Config Sda = Portc.1 ' Command # 1 I2cstart I2cwbyte &HE0 I2cwbyte 0 'Register 0 Command Register I2cwbyte &HA0 '1. Byte Sequ. I2cstop ' Command # 2 I2cstart I2cwbyte &HE0 I2cwbyte 0 'Register 0 Command Register I2cwbyte &HAA '2. Byte Sequ. I2cstop ' Command # 3 I2cstart I2cwbyte &HE0 I2cwbyte 0 'Register 0 Command Register I2cwbyte &HA5 '3. Byte Sequ. I2cstop ' Command # 4 I2cstart I2cwbyte &HE0 I2cwbyte 0 'Register 0 Command Register I2cwbyte &HF2 'new address I2cstop![]()
sorry gast, du warst um eine minute zu langsamaber trotzdem danke
nochmals der gast ! ich finde keinen i2cread, wei kommst du so an das ergebnis der messung ?
hallo, am 25.11 steht hier ein programm in Bascom für den srf08. läuft bei mir wunderbar.
mfg pebisoft
Lesezeichen