Testprogram for TMC2209-Library. Uses Speed-Control via VACTUAL instead of Step/Dir

Dependencies:   TMCStepper mRotaryEncoder-os

Files at this revision

API Documentation at this revision

Comitter:
charly
Date:
Thu Dec 02 20:30:09 2021 +0000
Parent:
8:f44d70665051
Child:
10:376299814a3b
Commit message:
Before change to STM32L432

Changed in this revision

TMCStepper.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- a/TMCStepper.lib	Thu Apr 22 18:11:49 2021 +0000
+++ b/TMCStepper.lib	Thu Dec 02 20:30:09 2021 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/charly/code/TMCStepper/#5ba0c258c4ed
+https://os.mbed.com/users/charly/code/TMCStepper/#b34e91b54373
--- a/main.cpp	Thu Apr 22 18:11:49 2021 +0000
+++ b/main.cpp	Thu Dec 02 20:30:09 2021 +0000
@@ -96,11 +96,31 @@
     
     // disable Driver
     enn=1;
+    // wait for Hhardware to settle
+    ThisThread::sleep_for(100ms);
         
     // Initialize Stepper
     printf("connecting to TMC-Module...\r\n");
     stepper.begin();                    // UART: Init SW UART (if selected) with default baudrate
-    printf("TMC-Version: %02X\r\n",stepper.version());
+    
+    //read and check version - must be 0x21
+    uint8_t tmc_version = stepper.version();
+    printf("TMC-Version: %02X\r\n",tmc_version);
+    if (tmc_version != 0x21) {
+            printf("Wrong TMC-Version(not 0x21) or communication error!! STOPPING!!!\r\n");
+            if (stepper.CRCerror) {
+                printf("CRC-Error!!!\r\n");
+            }
+            while (1) {
+                ledCW = 1;
+                ledCCW = 0;
+                ThisThread::sleep_for(50ms);
+                ledCW = 0;
+                ledCCW = 1;
+                ThisThread::sleep_for(50ms);
+            };
+    }
+    
     stepper.push();                     // initialize all registers??? required?
     
     stepper.toff(3);                    // Enables driver in software - 3, 5 ????
@@ -138,17 +158,18 @@
     
     // do a peep by setting vactual to a too high speed
     
-    stepper.VACTUAL(50000*MICROSTEPS);
-    ThisThread::sleep_for(1s);
+    //stepper.VACTUAL(50000*MICROSTEPS);
+    //ThisThread::sleep_for(1s);
     
     // initialize Automatic tunig (Chap 6.1)
+    printf("Start automatic tunig Chap6.1 .....");
     stepper.VACTUAL(1);
     stepper.VACTUAL(0);
     ThisThread::sleep_for(100ms);
     stepper.VACTUAL(500*MICROSTEPS);
     ThisThread::sleep_for(2s);
     stepper.VACTUAL(0);
-    
+    printf("done\r\n");
     
     diag.rise(&trigger_diag);
     
--- a/mbed-os.lib	Thu Apr 22 18:11:49 2021 +0000
+++ b/mbed-os.lib	Thu Dec 02 20:30:09 2021 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#bfde5aa1e74802771eaeacfa74789f71677325cb
+https://github.com/ARMmbed/mbed-os/#b1796dedeb8accde1cbaecf136fab96895e23d81