Der TMC222 kann einen Schalter (Referenzpunkt) verarbeiten,
und dessen Status (offen oder Vcc/GND = egal) wird dann im I2C Protokoll übermittelt.

  • SWI hat den einen Status (1) bei LOW (GND) oder HI (VCC) und den anderen Status (0) bei OPEN!


Dies hat jedoch keinen Einfluss auf den Motor sondern ist für die Weiterverarbeitung im uC vorgesehen.


  • Um eines klar zu stellen:
    der TMC222 ist für Positionierungsaufgaben entwickelt worden.
    Ein permanentes (ständiges) drehen des Motors ist nicht vorgesehen.
    Der TMC222 optimiert auch die Strecke zu den angegebenen Positionen.
    Wenn die Richtung von der aktuelle Position zur neuen Position links herum kürzer ist als rechts herum dann drehrt der Motor eben anders herum als beabsichtigt. (Man muss dies bei der Programmierung berücksichtigen ggf akt. Pos. neu setzten.)
    Möglich wäre eine pseudo kontinuierliche drehung, indem man immer wieder abfragt, in welcher Position sich der Motor gerade befindet und bei überschreiten einer "Zwischenposition" dann eine neue Zielposition senden.


[highlight=yellow:3ed0598469]WICHTIG:[/highlight:3ed0598469]
  • Please check that the correct supply voltage is applied to the circuit before zapping the OTP
    (See: Table 39: DC Parameters Supply and Voltage regulator on page 38 ),
    otherwise the circuit will be destroyed.




Wichtig ist es auch die richtigen Motorparameter einzustellen.

[highlight=red:3ed0598469]GANZ WICHTIG:[/highlight:3ed0598469]
Der TMC arbeitet nicht mit 5V sondern benötigt mindestens 8V sonst geht da garnix.
Ich habe es auch zunächt mit der VCC (5V) vom Controller probiert aber so funktioniert er eben nicht!

Wenn dann der TMC erst mal antwortet,
einfach eine neue Motor-Position senden und er legt los.


Hier mal die einfachste Einstellung der

  • Motorparameter:
    ------------------------------------------
    Irun [0..15 = max] = 15
    Ihold [15..0 = max] = 13
    Vmax [0..15 = max] = 15
    Vmin [Vmax =0..15 1/32 Vmax] = 0
    Shaft Richtung d. Achse[0/1] = 0
    Acceleration [0..15 = max] = 1
    Sichere Position [0..2047] = 0
    Acc Form [0/1] = 0
    Step Mode ( 1/2 Step ) = 0
    ------------------------------------------


Danach muss eine Status1 ([highlight=green:3ed0598469]getFullStatus1[/highlight:3ed0598469]) Abfrage durchgeführt werden,
damit der TMC die Parameter "frisst", sonst tut sich da nicht viel.

  • GetFullStatus1 Code 0x81 (= 129 dez)
    (daraufhin erhält man eine 8-Byte Antwort wie im Datenblatt unter 6.8.1 GetFullStatus1 erläutert (Byte 0 ist in Bascom nicht relevant)



Erst danach kannst Du eine neue Motorposition anfahren.

Jetzt sollte der Motor bestromt zu werden (Haltemoment).
Ist dies der Fall hats du schon gewonnen.

Nicht ganz so einfach ist die zerlegung bzw. die Zusammenstellung der Bitmuster
um die Parameter / Befehle an den TMC zu senden.

Schau Dir hierzu am besten meine Beispiel-Sources (in Bascom) an:

Beispielprogramm Downloaden

Informelle Links:




Code:
' Original TMC222 Command Set                               ' Folgend der komplette Befehlssatz des TMC 222
' ------------------------------------------                 ----------------------------------------------------
Const Tmc222_getfullstatus1 = &H81                          ' Returns complete status of the chip 0x81
Const Tmc222_getfullstatus2 = &HFC                          ' Returns actual, target and secure position 0xFC
Const Tmc222_getotpparam = &H82                             ' Returns OTP parameter 0x82
Const Tmc222_gotosecureposition = &H84                      ' Drives motor to secure position 0x84
Const Tmc222_hardstop = &H85                                ' Immediate full stop 0x85
Const Tmc222_resetposition = &H86                           ' Sets actual position to zero 0x86
Const Tmc222_resettodefault = &H87                          ' Overwrites the chip RAM with OTP contents 0x87
Const Tmc222_runinit = &H88                                 ' Reference Search 0x88
Const Tmc222_setmotorparam = &H89                           ' Sets motor parameter 0x89
Const Tmc222_setotpparam = &H90                             ' Zaps the OTP memory 0x90
Const Tmc222_setposition = &H8B                             ' Programmers a target and secure position 0x8B
Const Tmc222_softstop = &H8F                                ' Motor stopping with deceleration phase 0x8F

Const Tmc222_factory_adr_hwl = &HC0                         ' Adresse im Auslieferzustand bei HW = LOW
Const Tmc222_factory_adr_hwh = &HC2                         ' Adresse im Auslieferzustand bei HW = HI
Const Tmc222_general_adr = &H00                             ' General Adresse zur Ermittlung der 'realen' Adresse
Auszug aus meinem TMC222 Projekt : https://www.roboternetz.de/phpBB2/ze...ag.php?t=21730


Code:
Sub Getstatus1(byval Tmc_index As Byte)
   Local W_adresse As Byte
   Local R_adresse As Byte

   R_adresse = Bar_ad(tmc_index) Or &B00000001                                  ' R/W - Bit setzten (lesen)
   W_adresse = R_adresse And &B11111110                                         ' R/W - Bit löschen (schreiben)

   Call Clear_tmp_rw()                                                          ' Array löschen

   ' Befehl an den TMC senden
   I2csend W_adresse , Cst_getfullstatus1                                       ' Befehl an TMC senden
   ' Daten vom TMC empfangen
   I2creceive R_adresse , Bar_tmp_rw(1) , 0 , 8                                 ' Empfange 8 Bytes von Adresse

   ' Empfange Daten auswerten
   ' --- Byte 1 ---
   Bar_st1adr(tmc_index) = Bar_tmp_rw(1) And &B00011111                         ' maskieren

   ' --- Byte 2 ---

   ' > Irun
   Bar_irun(tmc_index) = Bar_tmp_rw(2) And &B11110000                           ' oberes Nibble maskieren
   Shift Bar_irun(tmc_index) , Right , 4                                        ' und nach rechts schieben

   ' > Ihold
   Bar_ihold(tmc_index) = Bar_tmp_rw(2) And &B00001111                          ' unteres Nibble maskieren

   ' --- Byte 3 ---

   ' > Vmax
   Bar_vmax(tmc_index) = Bar_tmp_rw(3) And &B11110000                           ' oberes Nibble maskieren
   Shift Bar_vmax(tmc_index) , Right , 4                                        ' und nach rechts schieben

   ' > Vmin
   Bar_vmin(tmc_index) = Bar_tmp_rw(3) And &B00001111                           ' unteres Nibble maskieren

   ' --- Byte 4 ---

   ' > AccShape
   Bar_accshape(tmc_index) = Bar_tmp_rw(4) And &B10000000                       ' maskieren
   Shift Bar_accshape(tmc_index) , Right , 7                                    ' und nach rechts schieben

   ' > StepMode
   Bar_stepmode(tmc_index) = Bar_tmp_rw(4) And &B01100000                       ' maskieren
   Shift Bar_stepmode(tmc_index) , Right , 5                                    ' und nach rechts schieben

   ' > Shaft
   Bar_shaft(tmc_index) = Bar_tmp_rw(4) And &B00010000                          ' maskieren
   Shift Bar_shaft(tmc_index) , Right , 4                                       ' und nach rechts schieben

   ' > ACC
   Bar_acc(tmc_index) = Bar_tmp_rw(4) And &B00001111                            ' maskieren

   ' --- Byte 5 ---

   ' > VddReset
   Bar_vddreset(tmc_index) = Bar_tmp_rw(5) And &B10000000                       ' maskieren
   Shift Bar_vddreset(tmc_index) , Right , 7                                    ' und nach rechts schieben

   ' > StepLoss
   Bar_steploss(tmc_index) = Bar_tmp_rw(5) And &B01000000                       ' maskieren
   Shift Bar_steploss(tmc_index) , Right , 6                                    ' und nach rechts schieben

   ' > ElDef
   Bar_eldef(tmc_index) = Bar_tmp_rw(5) And &B00100000                          ' maskieren
   Shift Bar_eldef(tmc_index) , Right , 5                                       ' und nach rechts schieben

   ' > UV2
   Bar_uv2(tmc_index) = Bar_tmp_rw(5) And &B00010000                            ' maskieren
   Shift Bar_uv2(tmc_index) , Right , 4                                         ' und nach rechts schieben

   ' > TSD
   Bar_tsd(tmc_index) = Bar_tmp_rw(5) And &B00001000                            ' maskieren
   Shift Bar_tsd(tmc_index) , Right , 3                                         ' und nach rechts schieben

   ' > TW
   Bar_tw(tmc_index) = Bar_tmp_rw(5) And &B00000100                             ' maskieren
   Shift Bar_tw(tmc_index) , Right , 2                                          ' und nach rechts schieben

   ' > Tinfo(1:0)
   Bar_tinfo(tmc_index) = Bar_tmp_rw(5) And &B00000011                          ' maskieren


   ' --- Byte 6 ---

   ' > Motion(2:0)
   Bar_motion(tmc_index) = Bar_tmp_rw(6) And &B11100000                         ' maskieren
   Shift Bar_motion(tmc_index) , Right , 5                                      ' und nach rechts schieben
   ' > ESW
   Bar_esw(tmc_index) = Bar_tmp_rw(6) And &B00010000                            ' maskieren
   Shift Bar_esw(tmc_index) , Right , 4                                         ' und nach rechts schieben

   ' > OVC1
   Bar_ovc1(tmc_index) = Bar_tmp_rw(6) And &B00001000                           ' maskieren
   Shift Bar_ovc1(tmc_index) , Right , 3                                        ' und nach rechts schieben

   ' > OVC2
   Bar_ovc2(tmc_index) = Bar_tmp_rw(6) And &B00000100                           ' maskieren
   Shift Bar_ovc2(tmc_index) , Right , 2                                        ' und nach rechts schieben

   ' 1                                      &B00000010                          ' nichts zum auswerten

   ' > CPFail
   Bar_cpfail(tmc_index) = Bar_tmp_rw(6) And &B00000001                         ' maskieren

   ' --- Byte 7 ---
   ' &B11111111

   ' --- Byte 8 ---
   ' &B11111111

End Sub
End
Code:
Sub Showstatus1(byval Tmc_index As Byte)
   Local Txt As String * 8
   Txt = Str_stepmode(bar_stepmode(tmc_index) )
   Print " Adress (ST1) : " ; Bin(bar_st1adr(tmc_index) )
   Print " Irun         : " ; Bin(bar_irun(tmc_index))
   Print " Ihold        : " ; Bin(bar_ihold(tmc_index))
   Print " Vmax         : " ; Bin(bar_vmax(tmc_index) )
   Print " Vmin         : " ; Bin(bar_vmin(tmc_index) )
   Print " AccShape     : " ; Bin(bar_accshape(tmc_index))
   Print " StepMode     : " ; Bin(bar_stepmode(tmc_index) );
   Print " (" ; Txt;
   Print ")"
   Print " Shaft        : " ; Bin(bar_shaft(tmc_index) )
   Print " ACC          : " ; Bin(bar_acc(tmc_index) )
   Print " VddReset     : " ; Bin(bar_vddreset(tmc_index) )
   Print " StepLoss     : " ; Bin(bar_steploss(tmc_index) )
   Print " ElDef        : " ; Bin(bar_eldef(tmc_index) )
   Print " UV2          : " ; Bin(bar_uv2(tmc_index) )
   Print " TSD          : " ; Bin(bar_tsd(tmc_index) )
   Print " TW           : " ; Bin(bar_tw(tmc_index) )
   Print " Tinfo        : " ; Bin(bar_tinfo(tmc_index) )
   Print " Motion       : " ; Bin(bar_motion(tmc_index) )
   Print " ESW          : " ; Bin(bar_esw(tmc_index) )
   Print " OVC1         : " ; Bin(bar_ovc1(tmc_index) )
   Print " OVC2         : " ; Bin(bar_ovc2(tmc_index) )
   Print " CPFail       : " ; Bin(bar_cpfail(tmc_index) )
End Sub
End