Hallo Siro,
deine Annahme war richtig. Die Poti haben einen Data-In und einen Data-Out. Es geht dabei speziell um die MCP42010.
Wie das Senden der Daten via SPI erfolgt, ist mir mittlerweile, nachdem ich das Datenblatt bestimmt 6mal gewälzt habe, nun auch geläufig ^^. Mein Englisch ist halt gerade so ausreichend für das Nötigste...
Ein Testprogramm für 2 dieser Poti habe ich eben noch geschrieben - ging sogar verdammt zügig, da ich nicht jedes Mal ein neues Array erstellen musste.
Mittlerweile werde ich mit den Arrays auch richtig warm. Habe bis Dato halt immer ohne geschrieben ^^.
Morgen probiere ich das Programm einmal aus.
Bin mir im Moment nur nicht ganz sicher, ob die Command-Variablen in der Debounce-Subroutine richtig sind. Werde ich morgen aber sehen. Wenn nicht, dann wandern die halt ins Hauptprogramm ^^.
Code:$regfile = "m8def.dat" $crystal = 1000000 $hwstack = 40 $swstack = 32 $framesize = 60 Config Portb = Output Config Portd = Input Portd = 255 Config Spi = Soft , Dout = Portb.1 , Ss = Portb.2 , Clock = Portb.3 Spiinit Dim A As Byte , Command1 As Byte , Command2 As Byte , Senddata(4) As Byte , Data1 As Byte , Data2 As Byte Dim M1 As Bit M1 = 0 Declare Sub Links Declare Sub Rechts Declare Sub Pushbutton Declare Sub Powerbutton ' ******************************** ' **** Main Program **** ' ******************************** Do ' --------------------------- ' SPI-Dataoutput for MCP42010 ' --------------------------- Senddata(1) = Command1 Senddata(2) = Data1 Senddata(3) = Command2 Senddata(4) = Data2 Spiinit Spiout Senddata(1) , 4 ' ---------------- ' Querying Encoder ' ---------------- A = Encoder(pind.2 , Pind.3 , Links , Rechts , 0) ' -------------------- ' Querying Pushbuttons ' -------------------- Debounce Pind.4 , 0 , Encoderbutton , Sub Debounce Pind.5 , 0 , Powerbutton , Sub Loop Links: If M1 = 0 Then Incr Data1 If M1 = 1 Then Incr Data2 If Data1 = 255 Then Data1 = 254 If Data2 = 255 Then Data2 = 254 Return Rechts: If M1 = 0 Then Decr Data1 If M1 = 1 Then Decr Data2 If Data1 = -1 Then Data1 = 0 If Data2 = -1 Then Data2 = 0 Return Encoderbutton: Toggle M1 If M1 = 0 Then Command1 = &B00010011 Command2 = &B00010000 Elseif M1 = 1 Then Command1 = &B00010000 Command2 = &B00010011 End If Return Powerbutton: nop Return End
MFG - Maik







Zitieren

Lesezeichen