Skip to content

Commit 305e886

Browse files
committed
Add getGlobalStatus, clearReset, and clearDriveError methods
1 parent 92ad189 commit 305e886

File tree

5 files changed

+57
-24
lines changed

5 files changed

+57
-24
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.3.0
15+
- Version :: 9.4.0
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](#org14d03dc)
2-
- [Stepper Motors](#orgdd68c73)
3-
- [Stepper Motor Controllers and Drivers](#orgaf22ed8)
4-
- [Communication](#orgdf3ff08)
5-
- [Settings](#org9694a81)
6-
- [Examples](#orgf4511b6)
7-
- [Hardware Documentation](#org50a7c9b)
8-
- [Host Computer Setup](#orgd3aa6ed)
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)
99

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

1313

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

1616
# Library Information
1717

1818
- **Name:** TMC2209
19-
- **Version:** 9.3.0
19+
- **Version:** 9.4.0
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="orgdd68c73"></a>
33+
<a id="orgf7138df"></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="orgaf22ed8"></a>
44+
<a id="orgf2cb8c3"></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="orgdf3ff08"></a>
92+
<a id="orgb9a56de"></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="org9694a81"></a>
394+
<a id="org3f9ff61"></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="orgf4511b6"></a>
549+
<a id="org6021d16"></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="org50a7c9b"></a>
577+
<a id="org7006dc6"></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="orgd3aa6ed"></a>
612+
<a id="org33743be"></a>
613613

614614
# Host Computer Setup
615615

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.3.0
2+
version=9.4.0
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.

src/TMC2209.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,17 @@ class TMC2209
226226
const static uint8_t CURRENT_SCALING_MAX = 31;
227227
Status getStatus();
228228

229+
struct GlobalStatus
230+
{
231+
uint32_t reset : 1;
232+
uint32_t drv_err : 1;
233+
uint32_t uv_cp : 1;
234+
uint32_t reserved : 29;
235+
};
236+
GlobalStatus getGlobalStatus();
237+
void clearReset();
238+
void clearDriveError();
239+
229240
uint8_t getInterfaceTransmissionCounter();
230241

231242
uint32_t getInterstepDuration();
@@ -329,14 +340,11 @@ class TMC2209
329340
GlobalConfig global_config_;
330341

331342
const static uint8_t ADDRESS_GSTAT = 0x01;
332-
union GlobalStatus
343+
union GlobalStatusUnion
333344
{
334345
struct
335346
{
336-
uint32_t reset : 1;
337-
uint32_t drv_err : 1;
338-
uint32_t uv_cp : 1;
339-
uint32_t reserved : 29;
347+
GlobalStatus global_status;
340348
};
341349
uint32_t bytes;
342350
};

src/TMC2209/TMC2209.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,30 @@ TMC2209::Status TMC2209::getStatus()
548548
return drive_status.status;
549549
}
550550

551+
TMC2209::GlobalStatus TMC2209::getGlobalStatus()
552+
{
553+
GlobalStatusUnion global_status_union;
554+
global_status_union.bytes = 0;
555+
global_status_union.bytes = read(ADDRESS_GSTAT);
556+
return global_status_union.global_status;
557+
}
558+
559+
void TMC2209::clearReset()
560+
{
561+
GlobalStatusUnion global_status_union;
562+
global_status_union.bytes = 0;
563+
global_status_union.global_status.reset = 1;
564+
write(ADDRESS_GSTAT, global_status_union.bytes);
565+
}
566+
567+
void TMC2209::clearDriveError()
568+
{
569+
GlobalStatusUnion global_status_union;
570+
global_status_union.bytes = 0;
571+
global_status_union.global_status.drv_err = 1;
572+
write(ADDRESS_GSTAT, global_status_union.bytes);
573+
}
574+
551575
uint8_t TMC2209::getInterfaceTransmissionCounter()
552576
{
553577
return read(ADDRESS_IFCNT);
@@ -608,6 +632,7 @@ void TMC2209::initialize(long serial_baud_rate,
608632

609633
setOperationModeToSerial(serial_address);
610634
setRegistersToDefaults();
635+
clearDriveError();
611636

612637
minimizeMotorCurrent();
613638
disable();

0 commit comments

Comments
 (0)