Hi!
Also das ANX-S20 ist ein Slave-Board.
An den Pins 5,7 und 9 des I2C Anschlusses vom ANX-S20 Board liegt Spannung an.
An dem I2C Anschluss des RN-Control Boards liegt keine Spannung an, da ich alle 3 Jumper vom JP6 vorher schon alle rausgezogen hatte.
Die PullUp Widerstände sind dann schon zu SCL und SDA am RN-Control geschaltet? Oder muss man die dann noch mit einem Befehl aktivieren?
Ich habe den Hersteller kontaktiert der hat mir folgenden Beispielcode zugesendet der mit dem Mega8 getestet worden ist:
Code:
'--------------------------------------------------------------
' I2C-Example1 for communication with anx-S20 servo controller
'
' don't forget to set the I2C-Pin options in Options / Compiler / I2C
'--------------------------------------------------------------
Declare Sub Write_i2c_b(byval Command As Byte , Byval Value As Byte)
Declare Sub Write_i2c_w(byval Command As Byte , Byval Value As Integer)
Declare Sub Write_i2c_b4(byval Command As Byte , Byval V1 As Byte , Byval V2 As Byte , Byval V3 As Byte , Byval V4 As Byte)
Const Addressw = 194 'slave write address
Const Addressr = 195 'slave read address
Dim B1 As Byte
Dim I As Integer
B1 = 5
Do
' set servo1+2+3 at once
Call Write_i2c_b4(107 , 1 , B1 , B1 , B1)
' set servo4
Call Write_i2c_b(66 , B1)
I = 0 ' PWMtime=0 means constant low
If B1 > 120 Then I = 5000 ' PWMtime=5000 means constant high
' set servo9 to high/low (output-pin)
Call Write_i2c_w(9 , I)
B1 = B1 + 10
Waitms 300
Loop
End
'writing a byte to I2C-chip
Sub Write_i2c_b(byval Command As Byte , Byval Value As Byte)
I2cstart 'start condition
I2cwbyte Addressw 'slave address
I2cwbyte Command 'command
I2cwbyte Value 'value to write
I2cstop 'stop condition
Waitms 2 'wait a short moment
End Sub
' writing a Integer to I2C-chip
Sub Write_i2c_w(byval Command As Byte , Byval Value As Integer)
Dim H As Byte
Dim L As Byte
H = High(value)
L = Low(value)
I2cstart 'start condition
I2cwbyte Addressw 'slave address
I2cwbyte Command 'command
I2cwbyte H 'high-byte first
I2cwbyte L 'low-byte last
I2cstop 'stop condition
Waitms 2 'wait a short moment
End Sub
'writing 4 byte-command to I2C-chip
Sub Write_i2c_b4(byval Command As Byte , Byval V1 As Byte , Byval V2 As Byte , Byval V3 As Byte , Byval V4 As Byte)
I2cstart 'start condition
I2cwbyte Addressw 'slave address
I2cwbyte Command 'command
I2cwbyte V1 'value to write
I2cwbyte V2 'value to write
I2cwbyte V3 'value to write
I2cwbyte V4 'value to write
I2cstop 'stop condition
Waitms 2 'wait a short moment
End Sub
Kann mir noch einer sagen das &HC2 beudeutet in meinem Code:
Danke!
Gruß
Dennis[/code]
Lesezeichen