ich versteh nicht ganz, warum du immer die grenzen über und unterschreitest (2200 und 800 als posit)?
Hallo!
Ich hab das Servomodul SD21 und wollte Funktionstests machen. Dazu hab ich folgendes Programm in Bascom geschrieben:
Beim Servo 1 macht er das auch manchmal. Manchmal stellt er mir das Servo aber auf eine Fixposition (nicht die Mitte) und dort bleibt er dann. Beim Einschalten fährt er auf die Mittelstellung, und nach ca. einer sekunde dann entweder ganz nach rechts und will immer weiter drehen, oder auf irgendeine position, die er aber auch halten will.Code:$regfile = "m32def.dat" $crystal = 8000000 'Quarzfrequenz $baud = 9600 Config Scl = Portc.0 'Ports fuer IIC-Bus Config Sda = Portc.1 Const Servo_adr = &HC2 'I2C Adress Servo Controller Dim Tnr As Byte Dim Lsb As Byte Dim Msb As Byte Dim Posit As Word I2cinit Tnr = 1 ' number of servo (0-x) Do Posit = 2200 ' position (1000 - 2000) Lsb = Low(posit) Msb = High(posit) I2cstart I2cwbyte Servo_adr ' serv CTRL I2C Addr I2cwbyte Tnr ' servo nr I2cwbyte Lsb ' lsb of position I2cwbyte Msb ' Msb of position I2cstop Waitms 3000 Posit = 800 ' position (1000 - 2000) I2cstart I2cwbyte Servo_adr ' serv CTRL I2C Addr I2cwbyte Tnr ' servo nr I2cwbyte Lsb ' lsb of position I2cwbyte Msb ' Msb of position I2cstop Waitms 3000 Loop End
Verstehe das einer...
Wenn ich in dem Programm allerdings das Servo auf Nr. 2 oder 3 oder.... usw. ändere passiert garnix.
Wer weiß rat?
mfg, Dave
ich versteh nicht ganz, warum du immer die grenzen über und unterschreitest (2200 und 800 als posit)?
Linus Torvalds, Entwickler von LinuxIch will Microsoft wirklich nicht zerstören. Das wird nur ein gänzlich unbeabsichtigter Nebeneffekt sein.
ich hatte auch die werte 1100 und 1900
von dem her ist es egal. das servo macht diese werte mit, es ist bei 2200 noch nicht am anschlag und bei 800 auch noch nicht.
(steht auch in der beschreibung vom sd21)
mfg, dave
du musst ja im prinzip in register 0 springen, spped 0 würd ich sagen, dann high byte dann low byte
also:
probier das mal das sollte funzen (als do loop schleife)Code:Do Posit = 2200 ' position (1000 - 2000) Lsb = Low(posit) Msb = High(posit) I2cstart I2cwbyte Servo_adr ' serv CTRL I2C Addr I2cwbyte 0 ' servo nr I2cwbyte 0 ' speed I2cwbyte Lsb ' lsb of position I2cwbyte Msb ' Msb of position I2cstop Waitms 3000 Posit = 800 ' position (1000 - 2000) Lsb = Low(posit) Msb = High(posit) I2cstart I2cwbyte Servo_adr ' serv CTRL I2C Addr I2cwbyte 0 ' servo nr I2cwbyte 0 ' speed I2cwbyte Lsb ' lsb of position I2cwbyte Msb ' Msb of position I2cstop Waitms 3000 Loop
Linus Torvalds, Entwickler von LinuxIch will Microsoft wirklich nicht zerstören. Das wird nur ein gänzlich unbeabsichtigter Nebeneffekt sein.
ja, das funktioniert, aber nur bei servo 1
wenn ich das auf servo 2, 3 usw. ändere, gehts nicht mehr. da tut sich nix...
bei servo2 wär das ja:
bei 3:Code:Do Posit = 2200 ' position (1000 - 2000) Lsb = Low(posit) Msb = High(posit) I2cstart I2cwbyte Servo_adr ' serv CTRL I2C Addr I2cwbyte 3 ' servo nr I2cwbyte 0 ' speed I2cwbyte Lsb ' lsb of position I2cwbyte Msb ' Msb of position I2cstop Waitms 3000 Posit = 800 ' position (1000 - 2000) Lsb = Low(posit) Msb = High(posit) I2cstart I2cwbyte Servo_adr ' serv CTRL I2C Addr I2cwbyte 3 ' servo nr I2cwbyte 0 ' speed I2cwbyte Lsb ' lsb of position I2cwbyte Msb ' Msb of position I2cstop Waitms 3000 Loop
Do
Posit = 2200 ' position (1000 - 2000)
Lsb = Low(posit)
Msb = High(posit)
I2cstart
I2cwbyte Servo_adr ' serv CTRL I2C Addr
I2cwbyte 6 ' servo nr
I2cwbyte 0 ' speed
I2cwbyte Lsb ' lsb of position
I2cwbyte Msb ' Msb of position
I2cstop
Waitms 3000
Posit = 800 ' position (1000 - 2000)
Lsb = Low(posit)
Msb = High(posit)
I2cstart
I2cwbyte Servo_adr ' serv CTRL I2C Addr
I2cwbyte 6 ' servo nr
I2cwbyte 0 ' speed
I2cwbyte Lsb ' lsb of position
I2cwbyte Msb ' Msb of position
I2cstop
Waitms 3000
Loop
Linus Torvalds, Entwickler von LinuxIch will Microsoft wirklich nicht zerstören. Das wird nur ein gänzlich unbeabsichtigter Nebeneffekt sein.
oh mann .... es ist so einfach und ich sehs nicht![]()
ich hab einfach nur 1,2,3 eingegeben, dabei ist 3 ja servo 2 und ich hab aber das servo auf platz 3 gesteckt und da tut sich natürlich nix![]()
ok, jetzt hab ich es aber verstanden![]()
vielen dank, mfg, dave
Lesezeichen