Skip to content

Commit bc08b82

Browse files
committed
Add unidirectional TestRP2040 example
1 parent 305e886 commit bc08b82

File tree

6 files changed

+80
-27
lines changed

6 files changed

+80
-27
lines changed

.metadata/README.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
* Library Information
1414
- Name :: TMC2209
15-
- Version :: 9.4.0
15+
- Version :: 9.4.1
1616
- License :: BSD
1717
- URL :: https://github.com/janelia-arduino/TMC2209
1818
- Author :: Peter Polidoro

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
- [Library Information](#org492394f)
2-
- [Stepper Motors](#orgf7138df)
3-
- [Stepper Motor Controllers and Drivers](#orgf2cb8c3)
4-
- [Communication](#orgb9a56de)
5-
- [Settings](#org3f9ff61)
6-
- [Examples](#org6021d16)
7-
- [Hardware Documentation](#org7006dc6)
8-
- [Host Computer Setup](#org33743be)
1+
- [Library Information](#org2f9c034)
2+
- [Stepper Motors](#org46f7059)
3+
- [Stepper Motor Controllers and Drivers](#orga565949)
4+
- [Communication](#org7308e9d)
5+
- [Settings](#org1c50612)
6+
- [Examples](#orgaacfc7b)
7+
- [Hardware Documentation](#orgdb15521)
8+
- [Host Computer Setup](#org0850996)
99

1010
<!-- This file is generated automatically from metadata -->
1111
<!-- File edits may be overwritten! -->
1212

1313

14-
<a id="org492394f"></a>
14+
<a id="org2f9c034"></a>
1515

1616
# Library Information
1717

1818
- **Name:** TMC2209
19-
- **Version:** 9.4.0
19+
- **Version:** 9.4.1
2020
- **License:** BSD
2121
- **URL:** <https://github.com/janelia-arduino/TMC2209>
2222
- **Author:** Peter Polidoro
@@ -30,7 +30,7 @@ The TMC2209 is an ultra-silent motor driver IC for two phase stepper motors with
3030
<img src="./images/trinamic_wiring-TMC2209-description.svg" width="1920px">
3131

3232

33-
<a id="orgf7138df"></a>
33+
<a id="org46f7059"></a>
3434

3535
# Stepper Motors
3636

@@ -41,7 +41,7 @@ A stepper motor, also known as step motor or stepping motor, is a brushless DC e
4141
[Wikipedia - Stepper Motor](https://en.wikipedia.org/wiki/Stepper_motor)
4242

4343

44-
<a id="orgf2cb8c3"></a>
44+
<a id="orga565949"></a>
4545

4646
# Stepper Motor Controllers and Drivers
4747

@@ -89,7 +89,7 @@ Another controller option is to use both a microcontroller and a separate step a
8989
<img src="./images/trinamic_wiring-TMC2209-stepper-controller.svg" width="1920px">
9090

9191

92-
<a id="orgb9a56de"></a>
92+
<a id="org7308e9d"></a>
9393

9494
# Communication
9595

@@ -391,7 +391,7 @@ A library such as the Arduino TMC429 library may be used to control the step and
391391
[Arduino TMC429 Library](https://github.com/janelia-arduino/TMC429)
392392

393393

394-
<a id="org3f9ff61"></a>
394+
<a id="org1c50612"></a>
395395

396396
# Settings
397397

@@ -546,7 +546,7 @@ In voltage control mode, the hold current scales the PWM amplitude, but the curr
546546
In current control mode, setting the hold current is the way to adjust the stationary motor current. The driver will measure the current and automatically adjust the voltage to maintain the hold current, even with the operating conditions change. The PWM offset may be changed to help the automatic tuning procedure, but changing the hold current alone is enough to adjust the motor current since the driver will adjust the offset automatically.
547547

548548

549-
<a id="org6021d16"></a>
549+
<a id="orgaacfc7b"></a>
550550

551551
# Examples
552552

@@ -574,7 +574,7 @@ In current control mode, setting the hold current is the way to adjust the stati
574574
<https://github.com/janelia-kicad/trinamic_wiring>
575575

576576

577-
<a id="org7006dc6"></a>
577+
<a id="orgdb15521"></a>
578578

579579
# Hardware Documentation
580580

@@ -609,7 +609,7 @@ In current control mode, setting the hold current is the way to adjust the stati
609609
[Janelia Stepper Driver Web Page](https://github.com/janelia-kicad/stepper_driver)
610610

611611

612-
<a id="org33743be"></a>
612+
<a id="org0850996"></a>
613613

614614
# Host Computer Setup
615615

examples/BidirectionalCommunication/TestRP2040/TestRP2040.ino

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
#include <TMC2209.h>
22

3-
// This example is meant to test the RP2040
3+
// This example is meant to test multiple ways of using bidirectional UART on RP2040
44
//
55
// See this reference for more details:
66
// https://arduino-pico.readthedocs.io/en/latest/serial.html
77

8-
SerialUART & serial_stream1 = Serial1;
9-
HardwareSerial & serial_stream2 = Serial2;
10-
SerialPIO Serial3(27,26);
11-
128
const long SERIAL_BAUD_RATE = 115200;
139
const int DELAY = 3000;
14-
const uint8_t SERIAL_RX_PIN1 = 9;
15-
const uint8_t SERIAL_TX_PIN1 = 8;
10+
const uint8_t SERIAL1_RX_PIN = 13;
11+
const uint8_t SERIAL1_TX_PIN = 12;
12+
const uint8_t SERIAL2_RX_PIN = 5;
13+
const uint8_t SERIAL2_TX_PIN = 4;
14+
const uint8_t SERIAL3_RX_PIN = 26;
15+
const uint8_t SERIAL3_TX_PIN = 27;
16+
17+
SerialUART & serial_stream1 = Serial1;
18+
HardwareSerial & serial_stream2 = Serial2;
19+
SerialPIO Serial3(SERIAL3_TX_PIN, SERIAL3_RX_PIN);
1620

1721
// Instantiate TMC2209
1822
TMC2209 stepper_driver1;
@@ -24,7 +28,10 @@ void setup()
2428
{
2529
Serial.begin(SERIAL_BAUD_RATE);
2630

27-
stepper_driver1.setup(serial_stream1, SERIAL_BAUD_RATE, TMC2209::SERIAL_ADDRESS_0, SERIAL_RX_PIN1, SERIAL_TX_PIN1);
31+
Serial2.setRX(SERIAL2_RX_PIN);
32+
Serial2.setTX(SERIAL2_TX_PIN);
33+
34+
stepper_driver1.setup(serial_stream1, SERIAL_BAUD_RATE, TMC2209::SERIAL_ADDRESS_0, SERIAL1_RX_PIN, SERIAL1_TX_PIN);
2835
stepper_driver2.setup(serial_stream2, SERIAL_BAUD_RATE);
2936
stepper_driver3.setup(Serial3, SERIAL_BAUD_RATE);
3037
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <TMC2209.h>
2+
3+
// This example is meant to test a FYSETC-ERB board containing an RP2040 and
4+
// two TMC2209 chips
5+
//
6+
// See this reference for more details:
7+
// https://github.com/FYSETC/FYSETC-ERB
8+
9+
10+
const uint8_t X_TX_PIN = 20;
11+
const uint8_t Y_TX_PIN = 17;
12+
const long SERIAL_BAUD_RATE = 115200;
13+
14+
SerialPIO x_serial(X_TX_PIN, SerialPIO::NOPIN);
15+
SerialPIO y_serial(Y_TX_PIN, SerialPIO::NOPIN);
16+
17+
// Instantiate TMC2209
18+
TMC2209 x_stepper_driver;
19+
TMC2209 y_stepper_driver;
20+
21+
// current values may need to be reduced to prevent overheating depending on
22+
// specific motor and power supply voltage
23+
const uint8_t RUN_CURRENT_PERCENT = 100;
24+
25+
const int32_t RUN_VELOCITY = 20000;
26+
27+
28+
void setup()
29+
{
30+
x_stepper_driver.setup(x_serial, SERIAL_BAUD_RATE);
31+
x_stepper_driver.setRunCurrent(RUN_CURRENT_PERCENT);
32+
x_stepper_driver.enableCoolStep();
33+
x_stepper_driver.enable();
34+
x_stepper_driver.moveAtVelocity(RUN_VELOCITY);
35+
36+
y_stepper_driver.setup(y_serial, SERIAL_BAUD_RATE);
37+
y_stepper_driver.setRunCurrent(RUN_CURRENT_PERCENT);
38+
y_stepper_driver.enableCoolStep();
39+
y_stepper_driver.enable();
40+
y_stepper_driver.moveAtVelocity(RUN_VELOCITY);
41+
}
42+
43+
void loop()
44+
{
45+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=TMC2209
2-
version=9.4.0
2+
version=9.4.1
33
author=Peter Polidoro <[email protected]>
44
maintainer=Peter Polidoro <[email protected]>
55
sentence=The TMC2209 is an ultra-silent motor driver IC for two phase stepper motors with both UART serial and step and direction interfaces.

platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
src_dir = examples/UnidirectionalCommunication/MoveAtVelocity
33
#src_dir = examples/UnidirectionalCommunication/SoftwareSerial
44
#src_dir = examples/BidirectionalCommunication/TestRP2040
5+
#src_dir = examples/UnidirectionalCommunication/TestRP2040
56

67
lib_dir = src
78
default_envs = teensy40

0 commit comments

Comments
 (0)