Testprogram for TMC2209-Library. Uses Speed-Control via VACTUAL instead of Step/Dir
Dependencies: TMCStepper mRotaryEncoder-os
Revision 10:376299814a3b, committed 2021-12-11
- Comitter:
- charly
- Date:
- Sat Dec 11 16:44:13 2021 +0000
- Parent:
- 9:babbfb61d347
- Commit message:
- baremetal profile
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed_app.json | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Dec 02 20:30:09 2021 +0000
+++ b/main.cpp Sat Dec 11 16:44:13 2021 +0000
@@ -12,14 +12,15 @@
*/
-DigitalOut ledCW(LED1); // Show rotation clockwise
-DigitalOut ledCCW(LED2); // Show rotation counterclockwise
+DigitalOut ledCW(LED1); // Show rotation clockwise // Gren LED LD3
+DigitalOut ledCCW(NC); // Show rotation counterclockwise // no more LEDs on L432
//Virtual serial port over USB with 15200 baud 8N1
static BufferedSerial host(USBTX, USBRX,115200);
//mRotaryEncoder(PinName pinA, PinName pinB, PinName pinSW, PinMode pullMode=PullUp, int debounceTime_us=1000)
-mRotaryEncoder wheel(p16, p17, p18,PullUp,3000); // default 1500
+mRotaryEncoder wheel(D2, D3, D6,PullUp,3000); // default 1500
+ //D7, D8 not available on L432KC with default solder bridges
// hardware parameters:
// MOTOR Steps per Revolution ( 1/8 Microsteps, 200Steps per Rev / 1.8 degrees per FullStep)
@@ -30,15 +31,15 @@
#define DRIVER_ADDRESS 0b00 // TMC2209 Driver address according to MS1 and MS2
#define R_SENSE 0.11f // R-Sense in OHM. Match to your driver
#define MICROSTEPS 256 // # of microsteps
-#define RMSCURRENT 1000 // RMS current of Stepper Coil in mA
-#define MAXSPEED 5000 // Maximaum speed (5000 with RMS800 @12V/0.6Amax)
+#define RMSCURRENT 800 // RMS current of Stepper Coil in mA
+#define MAXSPEED 5500 // Maximaum speed (5500 with RMS800 @12V/0.6Amax)
// A TMCStepper-object with UART and given address and R-Sense
//RX, TX, RS, Addr
-TMC2209Stepper stepper(p14, p13, R_SENSE, DRIVER_ADDRESS);
+TMC2209Stepper stepper(D0, D1, R_SENSE, DRIVER_ADDRESS);
-InterruptIn diag(p21);
-DigitalOut enn(p22);
+InterruptIn diag(D12);
+DigitalOut enn(D11);
volatile bool enc_pressed = false; // Button of rotaryencoder was pressed
volatile bool enc_rotated = false; // rotary encoder was totaded left or right
@@ -81,7 +82,7 @@
int main()
{
printf("\r\nConnected to mbed\r\n");
-
+ printf("This is Mbed OS %d.%d.%d.\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
//Intitiallize RotaryEncoder
// call trigger_sw() when button of rotary-encoder is pressed
wheel.attachSW(&trigger_sw);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json Sat Dec 11 16:44:13 2021 +0000
@@ -0,0 +1,11 @@
+{
+ "requires": ["bare-metal"],
+ "target_overrides": {
+ "*": {
+ "target.c_lib": "small",
+ "target.printf_lib": "minimal-printf",
+ "platform.minimal-printf-enable-floating-point": false,
+ "platform.stdio-minimal-console-only": true
+ }
+ }
+}