Hi!
Wenn ich nun noch die Servogeschwindigkeit mit in den Call Aufruf einbinden will, muss der Code dann so aussehen?:
Ich glaube Du hattest einen Fehler in Deinem Code. Die Servo_adr ist die I2C Adresse von dem Controller.Code:$regfile = "m32def.dat" 'Die Anweisung bestimmt Ccntrollertyp, hier AVR Mega 32 $crystal = 16000000 'Die Frequenz des verwendeten Quarzes $baud = 9600 'Die Baudrate für RS232 Ausgabe. 'Sie muss auch bei PC Terminalprogramm identisch sein '$lib "i2c_twi.lbx" ' we do not use software emulated I2C but the TWI 'Config Twi = 100000 ' wanted clock frequency Config Scl = Portc.0 'Ports fuer IIC-Bus Config Sda = Portc.1 ' wanted clock frequency Config Twi = 100000 Const Servo_adr = &HC2 'I2C Adress Servo Controller Declare Sub Servo(posit As Word , Servo_adr As Byte , Servo_spd As Byte) 'Im Kopf der Soft Call Servo(1500 , 12 , 10) 'so rufst Du auf Sub Servo(posit As Word , Servo_nr As Byte , Servo_spd As Byte) 'das wird aufgerufen 'Posit = 2320 position (1000 - 2000) Lsb = Low(posit) Msb = High(posit) I2cstart I2cwbyte Servo_adr ' serv CTRL I2C Addr I2cwbyte Servo_nr ' servo nr I2cwbyte Servo_spd ' speed I2cwbyte Lsb ' lsb of position I2cwbyte Msb ' Msb of position I2cstop Print "Servo " + Servo_nr + " auf Position " + Posit + " mit einer Geschwindigkeit von " + Servo_spd + " End Sub
Ist mein Code so richtig?
Gruß
Dennis







					
					
					
						
Zitieren

Lesezeichen