-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathdemo_script_01_uart_connection.py
More file actions
64 lines (48 loc) · 1.72 KB
/
demo_script_01_uart_connection.py
File metadata and controls
64 lines (48 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Demo file for testing the UART connection
"""
from tmc_driver import Tmc2209, Loglevel, Board, tmc_gpio
from tmc_driver.com import TmcComUart
print("---")
print("SCRIPT START")
print("---")
# -----------------------------------------------------------------------
# initiate the Tmc2209 class
# use your pins for pin_en, pin_step, pin_dir here
# -----------------------------------------------------------------------
UART_PORT = {
Board.RASPBERRY_PI: "/dev/serial0",
Board.RASPBERRY_PI5: "/dev/ttyAMA0",
Board.NVIDIA_JETSON: "/dev/ttyTHS1",
}
tmc = Tmc2209(
None,
None,
TmcComUart(UART_PORT.get(tmc_gpio.BOARD, "/dev/serial0")),
loglevel=Loglevel.DEBUG,
)
# -----------------------------------------------------------------------
# these functions change settings in the TMC register
# -----------------------------------------------------------------------
tmc.set_direction_reg(False)
tmc.set_current_rms(300)
tmc.set_interpolation(True)
tmc.set_spreadcycle(False)
tmc.set_microstepping_resolution(2)
tmc.set_internal_rsense(False)
print("---\n---")
# -----------------------------------------------------------------------
# these functions read and print the current settings in the TMC register
# -----------------------------------------------------------------------
tmc.read_register("ioin")
tmc.read_register("chopconf")
tmc.read_register("drvstatus")
tmc.read_register("gconf")
print("---\n---")
# -----------------------------------------------------------------------
# deinitiate the Tmc2209 class
# -----------------------------------------------------------------------
del tmc
print("---")
print("SCRIPT FINISHED")
print("---")