> For the complete documentation index, see [llms.txt](https://docs.feelix.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.feelix.xyz/downloads/arduino-library-documentation/motor-control-functions.md).

# Control

## Functions and Parameters

#### Move Motor

{% hint style="success" %}
This code works with the [**Feelix Effect Arduino Library**](/downloads/c-library.md#library-for-exported-feelix-effects)
{% endhint %}

* In **torque** mode  `MotionControlType::torque`  the  `targetValue` sets the voltage.
* In **angle** mode  `MotionControlType::angle`  the  `targetValue` sets the target position (radians).
* In **velocity** mode  `MotionControlType::velocity`  the  `targetValue` sets the target speed (rad/s).

```cpp
feelix.move_feelix(float targetValue, MotionControlType controlType);
```

#### Disable driver

```c++
feelix.disable();
```

#### Enable driver

```c++
feelix.enable(); // enabled by default in feelix.init();
```

#### Set rotation range

```cpp
void setRange(float rangeMin, float rangeMax, bool updateStartPos = true);
```

* **rangeMin** – start position in degrees *(default: 0)*
* **rangeMax** – end position in degrees *(default: 360)*
* **updateStartPos** *(optional)* – set current position to zero *(default: true)*

#### **Constrain range within which effects can be played**

```cpp
bool constrain_range = true;  // default: false
```

#### Set voltage limit

```cpp
void setVoltageLimit(float limit);  // default: 12.0 V
```

#### Set velocity limit

```cpp
void setVelocityLimit(float limit);  // default: 22.0 rad/s
```

## Motor Control Parameters

**PID controller settings** (more [information](https://docs.simplefoc.com/pi_controller))

Angle PID

```cpp
feelix.bldc->P_angle.P = 14.0;
feelix.bldc->P_angle.I = 0.0;
feelix.bldc->P_angle.D = 0.0;
```

Velocity PID

```cpp
feelix.bldc->PID_velocity.P = 0.5;
feelix.bldc->PID_velocity.I = 10.0;
feelix.bldc->PID_velocity.D = 0.0;
```

## Variables

Variables updated in `feelix.run()`

```cpp
feelix.angle           // angle in radians
feelix.angleDeg        // angle in degrees
feelix.velocity        // velocity in rad/s
feelix.temperature     // temperature motor 
feelix.driverVoltage   // voltage used to drive the motor
feelix.status          // status of the motor (see below)
```

#### Status

```c++
enum STATUS {
  STANDBY             = 0, // default status
  ERROR_TEMP          = 1, // temperature exceeds 60.0 degrees
  ERROR_UNDERVOLTAGE  = 2, // voltage is below 6.0V
  RUN_HAPTIC          = 3, // playing a haptic effect 
  RUN_VELOCITY        = 4, // playing a velocity effect
  ROTATING            = 5, // moving towards a target position
  DISABLED            = 6, // driver disabled
  ENABLED             = 7  // driver enabled
};
```

#### Transmission Factor

Setting this factor lets you account for gear ratios so motion is calculated at the output shaft rather than just at the motor.

```cpp
float transmissionFactor = 1.0; //default 1.0
```

{% hint style="info" %}
**transmission factor = (teeth of driven gear) ÷ (teeth of driving gear)**
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.feelix.xyz/downloads/arduino-library-documentation/motor-control-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
