summaryrefslogtreecommitdiff
path: root/digital/avr/modules/motor/control_state/control_state.txt
blob: 68a465ba4803c1a6a1392e80725bbc378ec33fe9 (plain)
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
============================
 motor/control_state module
============================
:Author: Nicolas Schodet

Introduction
============

The control state provides a way to enable or disable each control module in a
control system.

Usage
=====

Use `control_state_set_mode` to enable a control mode and every lower control
mode.  For example::

   control_state_set_mode (CS_MODE_SPEED_CONTROL, 0);

will enable speed control, position control and blocking detection.

The second argument can be used to disable a lower mode. For example, you can
enable position control without blocking detection::

   control_state_set_mode (CS_MODE_POS_CONTROL, CS_MODE_BLOCKING_DETECTION);

Actually, blocking detection is always enabled, only its effect can be
avoided (if disable, a blocked state will not disable control).

Use `control_state_finished` to signal that the current high level move is
finished.  This will restore every position control and blocking detection if
at least one position control is enabled and set the finished flag.

Use `control_state_blocked` to signal a blocked state.  This will disable
every mode and set the blocked flag.

The functions `control_state_is_finished` and `control_state_is_blocked` can
be used to query those flags.

When state has changed, it is usually safest to wait for the next control
cycle before state is changed again.  This is done naturally if the order of
update functions is respected (see control system documentation).

API
===

.. include:: control_state.exd