Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tinymovr Version 2 #367

Merged
merged 251 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
251 commits
Select commit Hold shift + click to select a range
8d05300
initial spec refactor
yconst Oct 10, 2023
332a16f
Merge branch 'develop' into sensor_support
yconst Oct 21, 2023
a34ece7
rename to sensor
yconst Oct 28, 2023
f3203bf
refactor sensor
yconst Oct 28, 2023
4a3787e
refactor sensors for modularity
yconst Oct 29, 2023
43d852b
update sensor and observer structure
yconst Nov 8, 2023
9ca2e55
revise sensor initialization
yconst Nov 9, 2023
a455f0a
add observer init
yconst Nov 10, 2023
b8a6722
fix init routine
yconst Nov 10, 2023
f45279d
minor refactor of sensor
yconst Nov 10, 2023
3b63811
rename sensor folder
yconst Nov 12, 2023
aa7dd9a
update spec
yconst Nov 14, 2023
6463a73
fix import
yconst Nov 14, 2023
ff9831d
rename encoder to sensor
yconst Nov 14, 2023
065c6e8
update protocol
yconst Nov 16, 2023
7dff995
format function name
yconst Nov 16, 2023
4444d8d
refactor sensor structure
yconst Nov 16, 2023
aaf3ff5
fix import
yconst Nov 17, 2023
9b2199e
implement missing struct
yconst Nov 17, 2023
4f92df5
refactor sensor update loop
yconst Nov 17, 2023
9c8c9e9
rename variable
yconst Dec 6, 2023
fd35d32
implement sensor interfaces
yconst Dec 6, 2023
bc4130d
cxx file associations
yconst Dec 6, 2023
f6246d3
update interface functions and summary
yconst Dec 6, 2023
3ff0abd
update protocol
yconst Dec 9, 2023
957d072
implement some missing functions
yconst Dec 9, 2023
4e5a4c0
add compatibility flags
yconst Dec 10, 2023
dd803b9
align function name with standard
yconst Dec 10, 2023
034fd62
align implementations with multi-sensor support
yconst Dec 10, 2023
8572f36
minor fixes
yconst Dec 11, 2023
c0ac69a
delete duplicate definition
yconst Dec 11, 2023
3fc28d9
various misnaming fixes
yconst Dec 22, 2023
72871cb
builds
yconst Dec 23, 2023
df02b22
add instrumentation timer for debug
yconst Dec 29, 2023
62eb2b4
update includes
yconst Dec 29, 2023
aa8f43b
introduce separate interface header and source file for access to sen…
yconst Dec 29, 2023
64ae2cd
update imports
yconst Jan 1, 2024
f331175
refactor sensor structure
yconst Jan 1, 2024
de23e09
make offset and pole pair calibration sensor-generic
yconst Jan 5, 2024
6a96b18
add as5047 sensor
yconst Jan 5, 2024
ab7998d
minor fixes
yconst Jan 5, 2024
89e8209
set initialize variable on init
yconst Jan 9, 2024
ca0b037
default values for the sensors struct
yconst Jan 9, 2024
65e7b26
fix timer frequency
yconst Jan 9, 2024
32c7f79
Change sensor bits to 16
yconst Jan 10, 2024
03c2b44
consolidate sensor return types
yconst Jan 10, 2024
15b4f3b
fix typo
yconst Jan 11, 2024
f354bf1
remove unused function
yconst Jan 25, 2024
44cdd48
implement more initialization functions
yconst Jan 25, 2024
91a7ff3
refactor sensor initialization
yconst Jan 28, 2024
997d260
fix size of returned firmware version
yconst Jan 31, 2024
6247424
add new bootloader definition
yconst Feb 2, 2024
47afcec
fix erroneous functions pointers
yconst Feb 3, 2024
f14bbb0
update SPI config
yconst Feb 3, 2024
812b660
allow setting clock multiplier in SPI init HAL
yconst Feb 3, 2024
70a630a
add SPI mode mini cheat sheet
yconst Feb 3, 2024
8e86d26
add raw sensor angle reporting to device spec
yconst Feb 3, 2024
155e5cf
use pointer to each sensor pointer
yconst Feb 3, 2024
957a9df
add fw_version bootloader endpoint
yconst Feb 3, 2024
902408a
add size of config object
yconst Feb 4, 2024
542c0f1
basic sensor working with m5
yconst Feb 4, 2024
0f74d15
update DFU script to support DFU fw 1.1.x
yconst Feb 4, 2024
4860a57
update enums
yconst Feb 6, 2024
b6f5ac9
fix sensor sector calculation
yconst Feb 6, 2024
b4c5fca
set value of dropdown control
yconst Feb 6, 2024
d5e382d
introduce common sensor resolution
yconst Feb 7, 2024
24a2d36
introduce new transformations system to transform between different r…
yconst Feb 12, 2024
84a3c48
revise transforms
yconst Feb 13, 2024
9cab553
Merge branch 'master' into sensor_support
yconst Feb 17, 2024
2e5658a
move to header
yconst Feb 25, 2024
ef51d9a
use 1 to 1 transform for commutation
yconst Feb 25, 2024
5de6b0d
remove unneeded onversion
yconst Feb 25, 2024
eb1b579
promote data types
yconst Feb 25, 2024
1f8b4f2
enforce minimum trip current value
yconst Feb 25, 2024
b41a79d
refactor calibration routines
yconst Feb 25, 2024
f447057
Make the scheduler state volatile
eufrizz Mar 1, 2024
5d1c0cd
Merge pull request #327 from eufrizz/bugfix-volatileSchedulerState
yconst Mar 1, 2024
9e340fd
integrate reference frames diagram
yconst Mar 2, 2024
07e1d81
add references
yconst Mar 3, 2024
46c52d5
Merge branch 'develop' into sensor_support
yconst Mar 12, 2024
84cbff9
Merge branch 'master' into sensor_support
yconst Mar 12, 2024
b5142c2
add files
yconst Mar 13, 2024
85d1d79
fix accessor
yconst Mar 13, 2024
2f2f1db
fix calibration frame issues
yconst Mar 13, 2024
f9ef80f
init with default transforms
yconst Mar 13, 2024
eef606c
fix eccentricity and frames calibration
yconst Mar 13, 2024
47c2275
update transform library
yconst Mar 14, 2024
fefef8e
add pdf and epub builds
yconst Mar 14, 2024
3d3d683
make struct extern
yconst Mar 14, 2024
7bed2fe
add back dwt counter
yconst Mar 15, 2024
f017b31
disable reading the peripheral at every cycle
yconst Mar 15, 2024
21fd6d6
only prepare sensor once
yconst Mar 15, 2024
f8f9cbe
remove unused timer
yconst Mar 15, 2024
6b24466
add load endpoint to spec
yconst Mar 15, 2024
768a0ea
fix transforms
yconst Mar 15, 2024
8b7678a
make const
yconst Mar 17, 2024
7714f35
fix velocity limiting issue
yconst Mar 17, 2024
91cc22d
make const
yconst Mar 17, 2024
eea5497
rename can state struct
yconst Mar 17, 2024
7b7532c
update spec with new function signatures
yconst Mar 18, 2024
ca485cb
consolidate ref frame updates
yconst Mar 18, 2024
1a43b34
update docs with transform explanation
yconst Mar 18, 2024
28dbe88
elaborate on sensor setup
yconst Mar 19, 2024
df2f081
optimize some operations
yconst Mar 19, 2024
a97c99d
increase ssp rate for external sensor
yconst Mar 19, 2024
cac39ee
enable inverter before proceeding
yconst Mar 19, 2024
6365ae2
fix hall sector count
yconst Mar 20, 2024
784ec63
report hall angle as full circle in ticks
yconst Mar 20, 2024
550f1c7
adapt caibration procedure to accommodate hall sensors
yconst Mar 20, 2024
52baf44
use sensor type getter
yconst Mar 20, 2024
9f97669
update hall sensor config docs
yconst Mar 20, 2024
244b857
add get config implementations
yconst Mar 20, 2024
21d613f
remove unused functions
yconst Mar 21, 2024
9f16f9c
erase as many pages as needed
yconst Mar 21, 2024
634af52
use separate update params function
yconst Mar 26, 2024
3ede56e
remove unneeded declarations
yconst Mar 26, 2024
c8f0a8f
init all members
yconst Mar 26, 2024
818898e
add initial amt22 support
yconst Mar 26, 2024
48d53bd
minor fixes
yconst Mar 27, 2024
7afb868
update tests for new firmware
yconst Apr 1, 2024
2b80698
refactor sensor initialization
yconst Apr 1, 2024
2595486
refactor observer initialization
yconst Apr 1, 2024
cac5428
add condition to support R3.x boards
yconst Apr 1, 2024
45a82b9
update tests
yconst Apr 1, 2024
5719ab4
update figures
yconst Apr 1, 2024
c839e40
update sensor docs
yconst Apr 1, 2024
6dde965
add as5047 test
yconst Apr 1, 2024
adaf1c2
fix reference
yconst Apr 1, 2024
2b180f4
elaborate on examples
yconst Apr 1, 2024
0b45474
add conditional tests
yconst Apr 2, 2024
0627e32
add more verbose pre- and post-build messages
yconst Apr 3, 2024
8dda620
add note about commutation transform
yconst Apr 3, 2024
b735a62
remove unused parameter
yconst Apr 3, 2024
06a8f8c
toggle sending of heartbeat
yconst Apr 4, 2024
e1b1293
reset observer state
yconst Apr 4, 2024
eff3a3c
fix scaling
yconst Apr 4, 2024
642b7ef
accommodate hall sensor calibration
yconst Apr 4, 2024
58cc291
init sensors after uart and can
yconst Apr 4, 2024
f0c1493
explicit check
yconst Apr 4, 2024
21f3d2a
reset observer state on change
yconst Apr 4, 2024
9bf80a9
fix conversion
yconst Apr 4, 2024
d0c9eec
rename vars
yconst Apr 4, 2024
aaa8acd
Use proper checkboxes for boolean values
yconst Apr 4, 2024
5e5affa
Merge pull request #333 from tinymovr/studio/bool_checkbox
yconst Apr 4, 2024
09f577e
add optional precheck callback param
yconst Apr 5, 2024
dc0dce9
add hall test
yconst Apr 5, 2024
2312673
change optimization level
yconst Apr 6, 2024
e878f42
update only visible items
yconst Apr 12, 2024
55085eb
add more external sensor tests
yconst Apr 13, 2024
9a99475
remove unused function
yconst Apr 13, 2024
aeac576
add parity calculation for the amt22 sensor
yconst Apr 13, 2024
afb60d0
add amt22 connection diagram
yconst Apr 15, 2024
e4512a2
parametrize the ssp data size
yconst Apr 15, 2024
997a42e
fix reading of AMT22
yconst Apr 15, 2024
454fbcd
add amt22 test
yconst Apr 16, 2024
8589ed4
track and use reference frame calibrations
yconst Apr 17, 2024
91b9a19
update as5047 tests
yconst Apr 17, 2024
b3ec7c0
Merge pull request #338 from tinymovr/sensor_support
yconst Apr 19, 2024
09be975
Merge pull request #339 from tinymovr/studio/adaptive_update
yconst Apr 19, 2024
9a541fa
change scheduler error to warning
yconst Apr 19, 2024
abc0cf5
rename device spec
yconst Apr 19, 2024
d589813
Merge pull request #340 from tinymovr/firmware/reent_warning
yconst Apr 19, 2024
ba9b4c0
update protocol headers based on new spec
yconst Apr 21, 2024
e0cd57c
add init_func for initialization using sensor pointer only
yconst Apr 21, 2024
b628c28
add getter and setter for rate
yconst Apr 21, 2024
1f41182
include spi rate as an init parameter
yconst Apr 21, 2024
f555ea2
config rates in blank objects
yconst Apr 21, 2024
f464ddb
add test for different baud rates
yconst Apr 21, 2024
2d5fa50
use internal enums
yconst Apr 21, 2024
fa968ce
Merge pull request #341 from tinymovr/configurable_sensor_rate
yconst Apr 21, 2024
0abc02a
add spec to manifest
yconst Apr 26, 2024
69638a3
update simple test for compatibility with M5
yconst Apr 26, 2024
933cf1b
Merge pull request #344 from tinymovr/fix_manifest_and_tests
yconst Apr 26, 2024
1288487
add app icon
yconst Apr 29, 2024
4e7a77c
add adjustable splitter
yconst Apr 29, 2024
3fd5682
Merge pull request #346 from tinymovr/studio/gui_improvements
yconst Apr 29, 2024
4abe475
basic console implementation
yconst Apr 29, 2024
80f44b7
improve logging
yconst Apr 29, 2024
80b5d1f
enable manually setting of device select pin
yconst May 3, 2024
fb247a7
implement correct SPI delays according to amt22 datasheet
yconst May 3, 2024
54d0023
compute checksum
yconst May 3, 2024
84d7af9
always set calibration current before calibration
yconst May 3, 2024
2ff368d
Merge pull request #348 from tinymovr/firmware/amt22_fixes
yconst May 3, 2024
ad047a8
refactor bus discovery and management
yconst May 8, 2024
cd285af
update tests
yconst May 8, 2024
ce66267
add busrouter api docs
yconst May 8, 2024
023b604
add logger parameter
yconst May 8, 2024
72480c9
update sim (mock) test
yconst May 8, 2024
83b7116
Merge pull request #350 from tinymovr/studio/refactor_bus_infra
yconst May 8, 2024
7c82586
Merge branch 'develop' into studio/GUI_console
yconst May 8, 2024
c4020e0
Merge pull request #347 from tinymovr/studio/GUI_console
yconst May 8, 2024
f6f6589
use alt string format in logging
yconst May 12, 2024
61a4e04
add logging message
yconst May 20, 2024
c6216d3
use customized exception
yconst May 27, 2024
01758f6
clear console
yconst May 27, 2024
56a52c8
Merge pull request #352 from tinymovr/studio/fix_logging
yconst May 27, 2024
c253513
Add configurable update rate
yconst May 27, 2024
fadc5eb
formatting
yconst May 27, 2024
b0df47b
add time window selection for plot
yconst May 27, 2024
9d7df98
Merge pull request #353 from tinymovr/studio/update_rates
yconst May 27, 2024
9b5b11f
improve pole pair calibration error reporting
yconst May 29, 2024
22b796b
fix persistence of shared ram
yconst May 29, 2024
98e31ce
also set shared ram
yconst May 29, 2024
d249496
update bootloader
yconst Jun 1, 2024
9ce88c2
reduce timeouts
yconst Jun 1, 2024
650295c
add power cycle dfu test
yconst Jun 1, 2024
09bbdcb
Merge pull request #354 from tinymovr/firmware/pp_error_reporting
yconst Jun 1, 2024
6f41966
Merge pull request #355 from tinymovr/firmware/shared_ram
yconst Jun 1, 2024
3446573
initialize can and adc after loading config
yconst Jun 5, 2024
0bee46c
properly handle response error
yconst Jun 5, 2024
78b0684
remove unneeded return
yconst Jun 5, 2024
bf4bb02
Merge pull request #356 from tinymovr/firmware/fix_can_setup
yconst Jun 6, 2024
3b3c8c1
add motor resistance and inductance limitations table
yconst Jun 6, 2024
96032e3
Merge pull request #357 from tinymovr/docs/resistance-and-inductance-…
yconst Jun 6, 2024
ef72c6b
fix erroneous return during transform derivation
yconst Jun 6, 2024
307717a
update expired discord link, once again :(
yconst Jun 6, 2024
46a241a
Merge pull request #358 from tinymovr/firmware/fix_transform_derivation
yconst Jun 6, 2024
289daa7
use wildcards
yconst Jun 14, 2024
fbe7882
Merge pull request #359 from tinymovr/studio/manifest-wildcards
yconst Jun 14, 2024
4a68e5d
add force flag for forcing device flashing
yconst Jun 24, 2024
9e9d682
Merge pull request #360 from tinymovr/studio/allow_force_dfu_flash
yconst Jun 26, 2024
fe1cb5a
add test case
yconst Jun 27, 2024
b4b502a
Merge pull request #361 from tinymovr/studio/add_test_case
yconst Jun 27, 2024
24acfe3
add figure to sensors docs
yconst Jun 27, 2024
6f0acb9
update erratum
yconst Jun 27, 2024
0960129
Merge pull request #362 from tinymovr/docs/add_ma7xx_figure
yconst Jun 27, 2024
4a12c9c
Update expired Discord link
yconst Jul 1, 2024
9e3856b
validate data written to nvm
yconst Jul 6, 2024
83442d0
add checksum validation
yconst Jul 6, 2024
d1418bd
fix saving and validating to nvm
yconst Jul 7, 2024
057534b
rename test
yconst Jul 7, 2024
780ecbe
Merge pull request #363 from tinymovr/firmware/validate_nvm_write
yconst Jul 8, 2024
5fbcd6f
update spec
yconst Jul 14, 2024
01de899
first reset setpoint and wait
yconst Jul 14, 2024
a2e16e6
relax some tests
yconst Jul 14, 2024
47bc4d1
add pre-cl checks
yconst Jul 14, 2024
0231297
Merge pull request #364 from tinymovr/firmware/pre_cl_check
yconst Jul 17, 2024
0ffd022
add abnormal calibration voltage check
yconst Jul 17, 2024
49a2ea3
Refactor abnormal voltage check to be more robust
yconst Jul 29, 2024
92219e1
Merge pull request #365 from tinymovr/firmware/abnormal_calibration_v…
yconst Aug 9, 2024
3ac344c
update bootloader binaries
yconst Aug 19, 2024
2197a9a
add board options
yconst Aug 19, 2024
4cf3242
fix calibration sequence
yconst Aug 19, 2024
fcf7b0e
reduce false positives in current detection
yconst Aug 19, 2024
556b87b
add hitl mini test group
yconst Aug 19, 2024
4d8827d
update external spi port for r53
yconst Aug 19, 2024
518bcc0
use filtered current for R measurement
yconst Aug 19, 2024
41bd702
update test constants
yconst Aug 19, 2024
57c2fe2
Merge pull request #366 from tinymovr/firmware/tinymovr_r53
yconst Aug 19, 2024
3380b83
Merge branch 'master' into develop
yconst Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ sphinx:
python:
install:
- requirements: docs/requirements.txt

# Build PDF & ePub
formats:
- epub
- pdf
3 changes: 2 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
"_UNICODE",
"__CC_ARM"
],
"cStandard": "c11",
"cppStandard": "c++17",
Expand Down
27 changes: 26 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,32 @@
"files.associations": {
"random": "c",
"limits": "c",
"common.h": "c"
"common.h": "c",
"__hash_table": "c",
"__tuple": "c",
"array": "c",
"type_traits": "c",
"ratio": "c",
"tuple": "c",
"variant": "c",
"chrono": "c",
"compare": "c",
"cstddef": "c",
"__locale": "c",
"__bit_reference": "c",
"__node_handle": "c",
"atomic": "c",
"bitset": "c",
"__memory": "c",
"locale": "c",
"optional": "c",
"system_error": "c",
"vector": "c",
"motor.h": "c",
"trajectory_planner.h": "c",
"xf1.h": "c",
"controller.h": "c",
"observer.h": "c"
},
"python.testing.unittestArgs": [
"-v",
Expand Down
3 changes: 2 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@
"R50",
"R51",
"R52",
"R53",
"M51"
],
"default": "R52"
"default": "R53"
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![FW Check Build](https://github.com/yconst/tinymovr/workflows/Tinymovr%20Firmware%20Check%2FBuild/badge.svg)
![Studio Lint Test](https://github.com/yconst/tinymovr/workflows/Tinymovr%20Studio%20Lint%2FTest/badge.svg)
![Docs Build](https://github.com/yconst/tinymovr/workflows/Tinymovr%20Docs%20Build/badge.svg)
[![Discord](https://img.shields.io/discord/742400176664084535)](https://discord.gg/CzcCaXbU)
[![Discord](https://img.shields.io/discord/742400176664084535)](https://discord.gg/UnmfuVzKuQ)

[Tinymovr is an affordable motor controller](https://tinymovr.com) with integrated encoder and CAN bus for precise control of 3-phase brushless motors (PMSMs).

Expand Down
4 changes: 3 additions & 1 deletion avlos_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ generators:
generator_c:
enabled: true
paths:
output_enums: ./firmware/src/tm_enums.h
output_header: ./firmware/src/can/can_endpoints.h
output_impl: ./firmware/src/can/can_endpoints.c
header_includes:
- src/common.h
- src/tm_enums.h
impl_includes:
- <string.h>
- src/adc/adc.h
- src/system/system.h
- src/encoder/encoder.h
- src/sensor/sensors.h
- src/observer/observer.h
- src/motor/motor.h
- src/scheduler/scheduler.h
Expand Down
17 changes: 14 additions & 3 deletions docs/hardware/errata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Hardware Errata

.. _alpha-erratum-1:

Tinymovr Alpha CAN Bus Connector Erratum
Tinymovr Alpha CAN Bus Connector
****************************************

The CANine v1 Adapter that came with Tinymovr alpha had the DF-13 pins reversed and as such is not compatible with regular DF-13 cables. Alpha users are advised to use the alternative pin header on the board and the included DF-13 to 2.54mm pin converter cable to communicate with Tinymovr, as shown in the diagram below:
Expand All @@ -16,7 +16,7 @@ Note above that the red wire should stay disconnected and to the left side of th

.. _alpha-erratum-2:

Tinymovr Alpha USB Micro Connector Erratum
Tinymovr Alpha USB Micro Connector
******************************************

The USB Micro connector used in the v1 adapter was unfortunately not very robust. In order to ensure that there is a good contact between the board and the USB cable, please ensure the male connector of the cable is firmly seated in the female connector of the board.
Expand All @@ -33,6 +33,17 @@ Tinymovr R5 UART Silkscreen Reversed

The silkscreen next to the UART port on the rear of Tinymovr R5 has the order of pins reversed. The correct pins are provided in the figure below.

This does not affect R5.2 and above.

.. image:: erratum_R51.png
:width: 600
:alt: Tinymovr R5 reversed silkscreen on UART port
:alt: Tinymovr R5 reversed silkscreen on UART port

.. _r52-erratum-1:

Tinymovr R5.2 FLEX2 Port as SPI
************************************

Even though Tinymovr R5.2 has the FLEX2 port which can function as SPI, due to a hardware incompatibility this port does not implement SPI correctly. As such, external sensors are only supported on the M5.x series at the moment.

Tinymovr R5.3 and above does not have this issue and supports external SPI sensors normally.
5 changes: 5 additions & 0 deletions docs/hardware/gimbal.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _gimbal-motors:

*************
Gimbal Motors
*************
Expand Down Expand Up @@ -28,6 +30,9 @@ To achieve closed-loop current control, motor controllers such as Tinymovr use c

The gimbal mode of Tinymovr disables closed-loop current control. The commanded currents are converted to voltages using basic resistance and inductance formulas.


.. _enabling-gimbal-mode:

Enabling Gimbal Mode
--------------------

Expand Down
32 changes: 28 additions & 4 deletions docs/hardware/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ Most gimbal motors can be used with Tinymovr M5. Gimbal motors are essentially o

* Motors with trapezoidal back-EMF can also be controlled, but control will be sub-optimal. The trapezoidal back-EMF will appear as residual in the dq frame, as a result it will be much harder for the current controller to regulate phase currents. The tangible result is that the motor may exhibit increased noise and vibration while running.

Limitations
***********

Tinymovr controllers are designed with certain limitations in terms of motor internal resistance and inductance, to ensure optimal closed loop current control performance.

.. list-table:: Motor Limits
:header-rows: 1

* - Controller Version
- Phase Resistance (ohms)
- Phase Inductance (henries)
* - Tinymovr R5.x and R3.x
- 0.01 to 1.0
- 5e-6 to 1e-3
* - Tinymovr M5.x
- 0.5 to 20.0
- 1e-5 to 1e-2

Note that motors with parameters outside this range will result in calibration failing. Ensure that the motors you select adhere to these parameters for the best operational experience. You can still use motors outside this range with open loop current control, through :ref:`enabling-gimbal-mode`.


Mechanical Setup
################
Expand Down Expand Up @@ -73,9 +93,9 @@ Sensor Magnet and Mounting Tips

* Ensure the sensor magnet is firmly attached to the motor shaft, otherwise it may slip out of sync. Use strong adhesive to secure.

* It is possible to have the magnet on the rear side of the PCB, i.e. opposite of the magnet sensor IC, but the gap needs to be reduced to account for the PCB thickness. This has been verified by MPS in `this forum post <https://forum.monolithicpower.com/t/mounting-ma702-and-magnet-on-opposite-sides-of-pcb/1609>`_, quoted below:
* It is possible to have the magnet on the rear side of the PCB, i.e. opposite of the magnet sensor IC, but the gap needs to be reduced to account for the PCB thickness. This has been verified by MPS in a forum post [1]_, quoted below:
*[...] this type of arrangement is possible, what really matters in the end is that there is enough magnetic field reaching the sensor.
Of course the minimum distance is imposed by the thickness of the PCB, so it puts some constraints on the design, that you have to take into account when chosing the magnet (you can use our online simulation tool for that). But as long as the PCB is not acting as a magnetic shield (due to copper plane), then it is fine.*
Of course the minimum distance is imposed by the thickness of the PCB, so it puts some constraints on the design, that you have to take into account when choosing the magnet (you can use our online simulation tool for that). But as long as the PCB is not acting as a magnetic shield (due to copper plane), then it is fine.*

* Calibration needs to be performed without any loads on the motor. If the motor is coupled to a load, the sensor offset angle may not be determined correctly, leading to a sub-optimal setup.

Expand Down Expand Up @@ -118,7 +138,7 @@ Connect the CAN bus header to one of the two CAN sockets on the board. It is not

* Tinymovr M5.x: you will need to provide an external 120Ω termination resistor.

In small setups with few nodes and short wires, it is better to enable just a single termination resistor, either on one Tinymovr board or on the CAN adapter. In setups with many nodes and long cables, you may need to enable termination resistors in both terminal nodes.
In small setups with few nodes and short wires, it is better to enable just a single termination resistor, either on one Tinymovr board or on the CAN adapter. In setups with many nodes and long cables, you may need to enable termination resistors in both terminal nodes. A typical CAN driver has an “open-drain” output structure, meaning that the dominant edge is actively driven and the recessive edge is not. Therefore, properly terminating the bus is very important because it ensures that the recessive edge decays properly, and in time for the next bit's sample point [2]_.

.. warning::
The UART pins in Tinymovr R5.1 have the silkscreen reversed. If you are planning to use UART with R5.1, consult :ref:`r51-erratum-1`.
Expand Down Expand Up @@ -148,4 +168,8 @@ Multiple nodes can be connected in a single CAN Bus network by means of daisy-ch

.. image:: daisy_chain.png
:width: 800
:alt: Connecting multiple nodes by daisy-chaining
:alt: Connecting multiple nodes by daisy-chaining


.. [1] MPS forum post on mounting MA702 and magnet on opposite sides of PCB: https://forum.monolithicpower.com/t/mounting-ma702-and-magnet-on-opposite-sides-of-pcb/1609
.. [2] Split Termination, Texas Instruments. Available at `https://www.ti.com/document-viewer/lit/html/SSZTB40#:~:text=for%20each%20termination.-,Split%20Termination,typically%20between%201%2D100nF`.
98 changes: 94 additions & 4 deletions docs/protocol/integrating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ Here below is an example using the API from Python scripts and controlling hardw
.. code-block:: python

import can
from tinymovr.tee import init_tee
from tinymovr.bus_router import init_router
from tinymovr.config import get_bus_config, create_device

params = get_bus_config(["canine", "slcan_disco"])
params["bitrate"] = bitrate
init_tee(can.Bus(**params))
params = get_bus_config(["canine", "slcan_disco"], bitrate=1000000)
init_router(can.Bus, params)
tm = create_device(node_id=1)

tm.controller.calibrate()
Expand All @@ -42,6 +41,97 @@ The above code block will instantiate a Tinymovr with CAN bus id of 1 and calibr
tm.controller.velocity_mode()
tm.controller.velocity.setpoint = 80000

BusRouter API
#############

The `BusRouter` class in the Tinymovr library is designed to facilitate message distribution and communication on the CAN bus by distributing incoming messages based on the result of a filter callback.

API Overview
------------

.. class:: BusRouter

Initializes and manages the routing of CAN bus messages between various clients. It integrates a simple forwarding mechanism for sending messages to simplify interfacing with CAN bus objects.

.. method:: __init__(bus_manager, timeout, logger)

Constructor for the BusRouter. Initializes the bus manager, timeout, and logger.

.. note::
This constructor should not be used directly. Instead, use the :func:`init_router` function.

:param bus_manager: Instance of BusManager to handle low-level bus interactions.
:param timeout: Timeout in seconds for receiving messages.
:param logger: Logger instance for logging information.

.. method:: run()

Main thread function that continuously listens for incoming frames and dispatches them to the appropriate clients based on filter results.

.. method:: add_client(filter_cb, recv_cb)

Registers a new client to receive messages that meet specific conditions.

:param filter_cb: Callback function that determines if the incoming frame should be passed to the client.
:param recv_cb: Callback function that handles the received frame.

.. method:: stop()

Stops the router's main running thread, effectively stopping the routing of messages.

.. method:: shutdown()

Performs a complete shutdown by stopping the router and closing all bus manager activities.

.. method:: send(frame)

Sends a frame via the bus manager.

:param frame: The CAN frame to be sent.

Bus Router Management Functions
-------------------------------

These helper functions manage the lifecycle of the `BusRouter` instance.

.. function:: init_router(bus_class, bus_params, logger, timeout=0.1)

Initializes a bus router using a python-can bus instance. This function creates a singleton instance of `BusRouter`.

:param bus_class: The bus class from python-can to be used.
:param bus_params: Parameters for the bus initialization.
:param logger: Logger instance for logging activities.
:param timeout: Timeout in seconds for receiving messages.
:return: An instance of `BusRouter`.

.. function:: destroy_router()

Destroys the existing bus router and stops its associated thread.

.. function:: get_router()

Returns the current instance of the bus router if it exists.

Deprecations
------------

The following functions are deprecated and will be removed in future versions:

.. function:: init_tee()

.. deprecated:: 2.1
Use :func:`init_router` instead.

.. function:: destroy_tee()

.. deprecated:: 2.1
Use :func:`destroy_router` instead.

.. function:: get_tee()

.. deprecated:: 2.1
Use :func:`get_router` instead.

Error Codes
###########

Expand Down
Loading
Loading