PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : ADNS2610 mit Bascom



hacker
09.04.2007, 17:49
hi,

es gab ja doch ab und zu mal ein paar Fragen nach der Ansteuerung für den ADNS2610 mit BASCOM.
Ich hab mich die Tage mal dran gemacht und das realisiert.

Anschluss ist der übliche, steht auch im DB des Chips.

Code:

$regfile = "m8def.dat"
$crystal = 16000000
$baud = 19200

Ddr_sck Alias Ddrd.6
Ddr_sdio Alias Ddrd.7

Port_sck Alias Portd.6
Port_sdio Alias Portd.7
Pin_sdio Alias Pind.7

Declare Sub Adns2610_init()
Declare Sub Adns2610_write_byte(byval Write_byte As Byte)
Declare Function Adns2610_read_byte() As Byte
Declare Sub Adns2610_write_operation(byval Address_byte As Byte , Byval Data_byte As Byte)
Declare Function Adns2610_read_operation(byval Address_byte As Byte) As Byte

Call Adns2610_init()

Dim X As Integer
Dim Y As Integer

X = 0
Y = 0

Dim X_cm As Single
Dim Y_cm As Single

Dim Read_data As Byte

Read_data = 0

Dim Tmp As Byte

Tmp = 0



Do


Read_data = Adns2610_read_operation(&H03)

If Read_data > &H7F Then

Tmp = &HFF - Read_data

Incr Tmp

X = X - Tmp

Else

X = X + Read_data

End If

X_cm = X * 0.00635

Print " X: " ; X_cm;



Read_data = Adns2610_read_operation(&H02)

If Read_data > &H7F Then

Tmp = &HFF - Read_data

Incr Tmp

Y = Y - Tmp

Else

Y = Y + Read_data

End If

Y_cm = Y * 0.00635

Print " Y: " ; Y_cm;



Waitms 500



Loop
End


Sub Adns2610_init:

Ddr_sck = 1
Ddr_sdio = 1

Port_sck = 1
Port_sdio = 1

Call Adns2610_write_operation(&H00 , &H80)
Call Adns2610_write_operation(&H00 , &H01)

End Sub

Sub Adns2610_write_byte(byval Write_byte As Byte)

Local I As Byte

Ddr_sdio = 1

For I = 7 To 0 Step -1

Port_sck = 0

Port_sdio = Write_byte.i

Waitus 1

Port_sck = 1

Waitus 1

Next I

Ddr_sdio = 0
Port_sdio = 0

End Sub

Function Adns2610_read_byte() As Byte

Local I As Byte

Local Data_byte As Byte

Waitus 250

For I = 7 To 0 Step -1

Port_sck = 0

Waitus 1

Port_sck = 1

Data_byte.i = Pin_sdio

Next I

Adns2610_read_byte = Data_byte

End Function

Sub Adns2610_write_operation(byval Address_byte As Byte , Byval Data_byte As Byte)

Address_byte = Address_byte Or &B10000000

Call Adns2610_write_byte(address_byte)
Call Adns2610_write_byte(data_byte)

End Sub

Function Adns2610_read_operation(byval Address_byte As Byte) As Byte

Call Adns2610_write_byte(address_byte)

Adns2610_read_operation = Adns2610_read_byte()

End Function

Vllt. kann der ein oder andere damit was anfangen. Ich stell ihn auch noch gleich ins Wiki dazu. zu dem PAN Bsp in C.

/Edit Ich seh grad, dass man da angemeldet sein muss....Ich muss jetzt los. Das mit dem Wiki schau ich mir die Tage an, oder einer von euch ist so nett, und machts da rein.

Gruß Hacker

hacker
04.07.2007, 16:59
Aufgrund des Wunsches über PM, hier der Schaltplan:

Jörg9
14.07.2007, 07:33
Hallo Hacker,

Du nimmst einen Kondensator mit 1uF an REFA. Im Datenblatt des Herstellers wird an dieser Stelle einer mit 2,2uF vorgeschlagen. Hat Deine Änderung einen besonderen Grund?

Grüße,
Jörg

hacker
14.07.2007, 08:15
Nein, die Änderung ist irrelevant. Du kannst genaus gut den im DB vorgeschlagenen Kondensator nehmen.

Jörg9
15.07.2007, 18:36
Hallo Hacker,

hast Du zwischen dem ADNS und dem Controller noch irgendwelche Bauteile geschaltet (Widerstände etc.)?

hacker
15.07.2007, 19:21
Nein. Die Leitungen hängen direkt an Pins.

oceans94
05.05.2008, 18:37
kleine dumme Zwischenfrage:

WO bekommt man den ADNS2610 möglichst BILLIG her ???
Das einzige was ich gefunden hab:

12 Euro (mit Versand)

ist jetzt nicht (obwohl für nen Schüler vielleicht doch) die Welt aber geht bestimmt auch billiger??