Skip to content
Snippets Groups Projects
Commit fe09d671 authored by yuichitamiya's avatar yuichitamiya
Browse files

add test stepper

parent 5d144cea
No related branches found
No related tags found
No related merge requests found
Pipeline #284308 passed
docs/Instruction/images/stepper/42SHD4002-24B.jpg

18 KiB

docs/Instruction/images/stepper/42SHD_spec.png

112 KiB

docs/Instruction/images/stepper/42SHD_wire.png

48.4 KiB

docs/Instruction/images/stepper/TMC2208_back.jpg

108 KiB

docs/Instruction/images/stepper/TMC2208_front.jpg

201 KiB

docs/Instruction/images/stepper/arduino_tmc2208_lib.png

437 KiB

docs/Instruction/images/stepper/mode_select.jpg

216 KiB

docs/Instruction/images/stepper/modes.png

169 KiB

docs/Instruction/images/stepper/vref_hole.jpg

302 KiB

docs/Instruction/images/stepper/vref_screw.jpg

277 KiB

# Stepper Motor Driver TMC2208
![](../images/stepper/TMC2208_front.jpg){width=300}
![](../images/stepper/TMC2208_back.jpg){width=300}
[Digikey](https://www.digikey.jp/en/products/detail/trinamic-motion-control-gmbh/TMC2208SILENTSTEPSTICK/6873626)
## About
[Datasheet](https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC220x_TMC2224_datasheet_Rev1.09.pdf)
Ref. [youtube](https://www.google.com/search?q=TMC2208+how+to+use&rlz=1C5CHFA_enJP913JP913&oq=TMC2208+how+to+use&aqs=chrome..69i57j0i22i30.12837j0j7&sourceid=chrome&ie=UTF-8#kpvalbx=_Zp0dYqfAI9Pg2roP9bWQSA43)
### Mode
![](../images/stepper/modes.png)
- Mode 1: Standalone STEP/DIR Driver (Legacy Mode)
- **Replacement for A4988**
- Manual Vref/Stepper Current
- Mode 2: Standalone STEP/DIR Driver with OTP pre-configuration
- OTP (One Time Programming)
- Mode 3: STEP/DIR Driver with Full Diagnostics and Control
- **pin PDN_UART is connected to the CPU UART interface**
## Set up as Mode 1
### Mode select
![](../images/stepper/mode_select.jpg){width=400}
- Mode 1: no jumber (default)
### Stepper Motor
![](../images/stepper/42SHD4002-24B.jpg)
[42SHD4002-24B](https://akizukidenshi.com/catalog/g/gP-14604/)|[datasheet](https://akizukidenshi.com/download/ds/fudeelec/42shd4002-24b.pdf)
![](../images/stepper/42SHD_spec.png){width=500}
![](../images/stepper/42SHD_wire.png){width=500}
- Rated voltage: 12V
- Rated current: 0.55A
### Vref formula
#### RMS Current
- Root Mean Square ([二乗平均平方根](https://ja.wikipedia.org/wiki/%E4%BA%8C%E4%B9%97%E5%B9%B3%E5%9D%87%E5%B9%B3%E6%96%B9%E6%A0%B9))
RMS Current = MAX CURRENT / 1.41
VREF = (RMS Current x 2.5)/1.77)
value |formula |42SHD4002-24B |Safer use 90% of VREF
-- |--- |-- |--
RMS Current|MAX Current / 1.41 |0.55[A] / 1.41 = 0.39 | -
VREF |(RMS Current x 2.5)/1.77 |(0.39 x 2.5)/1.77 = 0.55|0.55 x 0.9 = 0.495[V]
![](../images/stepper/vref_hole.jpg){width=300}
![](../images/stepper/vref_screw.jpg){width=300}
### Arduino
#### Library
New: [TMCStepper](https://github.com/teemuatlut/TMCStepper)
Old: [TMC2208Stepper](https://github.com/teemuatlut/TMC2208Stepper)
Sketch -> Include Library -> Library Manager -> Search "tmc" -> install both libraries
![](../images/stepper/arduino_tmc2208_lib.png){width=400}
#### sample Sketch
File -> Examples -> TMC2208Stepper -> TMC2208_Simple
```
// Author Teemu Mäntykallio, 2017-04-07
// Define pins
#define EN_PIN 38 // LOW: Driver enabled. HIGH: Driver disabled
#define STEP_PIN 54 // Step on rising edge
#include <TMC2208Stepper.h> // Include library
TMC2208Stepper driver = TMC2208Stepper(&Serial1); // Create driver and use
// HardwareSerial0 for communication
void setup() {
Serial.begin(9600);
Serial.println("Start...");
Serial1.begin(115200); // Start hardware serial 1
driver.push(); // Reset registers
// Prepare pins
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
digitalWrite(EN_PIN, HIGH); // Disable driver in hardware
driver.pdn_disable(true); // Use PDN/UART pin for communication
driver.I_scale_analog(false); // Use internal voltage reference
driver.rms_current(500); // Set driver current 500mA
driver.toff(2); // Enable driver in software
digitalWrite(EN_PIN, LOW); // Enable driver in hardware
uint32_t data = 0;
Serial.print("DRV_STATUS = 0x");
driver.DRV_STATUS(&data);
Serial.println(data, HEX);
}
void loop() {
digitalWrite(STEP_PIN, !digitalRead(STEP_PIN));
delayMicroseconds(100);
}
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment