Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Tinymovr consists of **two separate projects**:
| **adc** | Sensing | Current measurement, ADC trigger |
| **gatedriver** | Actuation | PWM generation, Space Vector Modulation |
| **can** | Comm | CAN bus interface, Avlos endpoint dispatch |
| **uart** | Comm | UART interface (alternative to CAN) |
| **uart** | Comm | UART interface (same Avlos endpoints as CAN, ASCII by endpoint ID) |
| **ssp** | I/O | SPI for external encoders |
| **nvm** | Storage | Configuration persistence to flash |
| **scheduler** | Timing | Interrupt sync, CPU load monitoring |
Expand Down
2 changes: 2 additions & 0 deletions avlos_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ generators:
output_enums: ./firmware/src/tm_enums.h
output_header: ./firmware/src/can/can_endpoints.h
output_impl: ./firmware/src/can/can_endpoints.c
output_metadata_header: ./firmware/src/can/avlos_endpoint_metadata.h
output_metadata_impl: ./firmware/src/can/avlos_endpoint_metadata.c
header_includes:
- src/common.h
- src/tm_enums.h
Expand Down
295 changes: 37 additions & 258 deletions docs/interfaces/interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ For a detailed description, please see :ref:`integrating` and :ref:`api-referenc
UART
----

As an alternative to CAN Bus, Tinymovr offers UART-based (serial) communication. The protocol is much simpler than CAN and mainly designed for troubleshooting or testing in the absence of CAN hardware.
As an alternative to CAN Bus, Tinymovr offers UART-based (serial) communication. The protocol is human-readable ASCII and exposes the same endpoints as CAN, so you can use any serial terminal without Tinymovr Studio.

.. warning::
The UART port on Tinymovr is NOT 5V tolerant. Applying 5V voltage will immediately damage the onboard PAC5527 controller. Please use only 3.3V for UART communication.
Expand All @@ -40,297 +40,76 @@ Protocol Description

The UART port is TTL at 115200 baud. A regular FTDI-style USB to UART adapter should be sufficient.

UART communication is based on a simple human-readable protocole dubbed the "dot protocol", because the dot is the command starting character. The protocol is response-only, meaning that Tinymovr will only respond to commands initiated by the client, it will never initiate a transmission on it's own.
UART uses the same Avlos endpoint set as CAN. Each command is one line: it starts with a dot (``.``), followed by the **endpoint ID** (0–99, decimal), then optionally one or more space-separated **values** for writes or calls. The line is terminated by a newline (``\n``). Tinymovr only responds to commands; it never sends on its own.

The command template is as follows:
**Command format**

.. code-block:: shell

.Cxxxx

The command begins with a dot. The next single character identifies the command. The characters following the second one are optional values to pass to write commands. Read commands only include the dot and command character. The command is finalized with a newline character (\n, not shown above).

For instance, to get the current position estimate:

.. code-block:: shell

command: .p
response: 1000

To set the velocity estimate in encoder ticks:

.. code-block:: shell

command: .V10000
(no response)

The values passed or returned are always integers scaled by the mentioned factor (see command reference below).

Note that command characters are case-sensitive, i.e. capitals and small represent different commands. As a convention, capital letters are setters and small are getters, where applicable.

Command Reference
#################

.Z
==

Transition to idle state.

Example

.. code-block:: shell

.Z
0

.Q
==

Transition to calibration state.

Example

.. code-block:: shell

.Q
0

.A
==

Transition to closed loop control state.

Example

.. code-block:: shell
- **Read**: ``.<endpoint_id>`` → response is one line with the value (number, ``true``/``false``, or string).
- **Write** (single value): ``.<endpoint_id> <value>`` → response is ``ok``.
- **Call** (no args, e.g. save config): ``.<endpoint_id>`` → response is ``ok``.
- **Call** (with args, e.g. set position + velocity): ``.<endpoint_id> <arg1> <arg2> ...`` → response is ``ok`` or one value if the call returns data.

.A
0
Values are human-readable: integers, decimals (e.g. ``1000.5``), and ``true``/``false`` or ``1``/``0`` for booleans. No scaling is required; the firmware parses and formats values according to the endpoint type.

.e
==
**Response format**

Get the error code.
- One line per command: the value (ASCII), or ``ok`` for writes and void calls, or ``error: invalid endpoint`` / ``error: bad value`` on failure.

Example

.. code-block:: shell

.e
0

.p
==

Get position estimate (ticks).

Example

.. code-block:: shell

.p
1000

.v
==

Get velocity estimate (ticks/s).


Example

.. code-block:: shell

.v
-200

.i
==

Get current (Iq) estimate (mA).

Example

.. code-block:: shell

.i
2000

.P
==

Get/set position setpoint (ticks).

Example

.. code-block:: shell

.P
1000

.. code-block:: shell
**Endpoint IDs**

.P1000
Endpoint IDs match the same API as CAN. For the full list and types, see :ref:`api-reference`. Endpoints are numbered in the order they appear in the spec (e.g. 0 = protocol hash, 4 = Vbus, 11 = save_config, 25 = controller position setpoint).

.V
==

Get/set velocity setpoint (ticks/s).

Example

.. code-block:: shell

.V
-10000

.. code-block:: shell

.V-10000

.I
==

Get/set current (Iq) setpoint (mA).

Example

.. code-block:: shell

.I
1000

.. code-block:: shell

.I1000

.W
==

Get/set current (Iq) limit (mA).

Example

.. code-block:: shell

.W
10000

.. code-block:: shell

.W15000

.Y
==

Get/set position gain.

Example

.. code-block:: shell

.Y
25

.. code-block:: shell

.Y25

.F
==

Get/set velocity gain (x0.000001).

Example

.. code-block:: shell
Examples
########

.F
20
Read protocol hash:

.. code-block:: shell

.F20

.G
==

Get/set velocity integrator gain (x0.001).

Note that high values (e.g. above 10) may cause instability.

Example

.. code-block:: shell
.0
3999954334

.G
2
Read bus voltage (float):

.. code-block:: shell

.G2
.4
24.500000

.H
==

Get/set motor phase resistance (mOhm).

Example

.. code-block:: shell

.H
200
Read firmware version (string):

.. code-block:: shell

.H 200

.L
==
.2
2.3.4-17-g0768c21-dirty

Get/set motor phase inductance (μH).

Example
Set position setpoint then read it back (endpoint 25, float):

.. code-block:: shell

.L
2000
.25 1000.5
ok

.. code-block:: shell
.25
1000.500000

.L 2000

.R
==

Reset the MCU.

Example
Save configuration (endpoint 11, void call):

.. code-block:: shell

.R

.S
==
.11
ok

Save board configuration.

Example
Call an endpoint that takes multiple arguments (e.g. two floats):

.. code-block:: shell

.S

.X
==

Erase board configuration and reset.
.47 1000.0 50.0
ok

Example
Invalid endpoint:

.. code-block:: shell

.X
.200
error: invalid endpoint
3 changes: 2 additions & 1 deletion docs/protocol/reference.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

.. _api-reference:

API REFERENCE
=============

The :ref:`api-reference` section below lists all endpoints.



protocol_hash
Expand Down
Loading