Skip to content

Commit

Permalink
feature: add foc knob
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunru-hub authored and espressif-bot committed Dec 28, 2023
1 parent eb135f5 commit 1d7a23c
Show file tree
Hide file tree
Showing 12 changed files with 588 additions and 306 deletions.
1 change: 1 addition & 0 deletions components/motor/esp_simplefoc/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ dependencies:
examples:
- path: ../../../examples/motor/foc_openloop_control
- path: ../../../examples/motor/foc_velocity_control
- path: ../../../examples/motor/foc_knob_example
38 changes: 18 additions & 20 deletions examples/motor/foc_knob_example/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
| Supported Targets |ESP32-S3 | ESP32-C3 |
| ----------------- |-------- |----------|

# ESP FOC Knob
This example demonstrates the application of the ESP-32S3 microcontroller to control a motor, effectively transforming it into a knob-like interface.
# ESP FOC Knob
This example demonstrates the application of the ESP32-S3 microcontroller to control a motor, effectively transforming it into a knob-like interface.

## Modes supported

| Mode | Description |
|-----------------------------------|------------------------------------------------------------|
| 0. Fine Value with Detents | Motor can be unbounded with fine rotation and fine dents points. |
| 1. Unbounded, No Detents | Motor can be unbounded with fine rotation and no dent points. |
| 2. Super Dial | Motor can be unbound with fine rotation and noticeable dent points. |
| 3. Fine Values with Detents, Unbounded | Motor can be unbounded with fine rotation and noticeable dents points. |
| 4. Bounded 0-13, No Detents | Motor will be constrained within a specific range (180-360) with fine rotation and no detent points. |
| 5. Coarse Values, Strong Detents | Motor can be unbounded with coarser rotation and strong dent points. |
| 6. Fine Values, No Detents | Motor will be constrained within a specific range (256, 127), fine rotation, no dent points |
| 7. On/Off, Strong Detents | Motor will be constrained within a specific range presents a On/off functionality with noticeable stopping points. |
| Mode | Description |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| 0. unbound no detents | Motor can be unbounded with fine rotation and no dent points. |
| 1. Unbounded Fine detents | Motor can be unbounded with fine rotation and fine dent points. |
| 2. Unbounded Strong detents | Motor can be unbound with fine rotation and noticeable dent points. |
| 3. Bounded No detents | Motor will be constrained within a specific range (0-360) with fine rotation and no detent points. |
| 4. Bounded Fine detents | Motor can be constrained with coarser rotation and fine dent points. |
| 5. Bounded Strong detents | Motor can be constrained with coarser rotation and strong dent points. |
| 6. On/Off strong detents | Motor will be constrained within a specific range presents a On/off functionality with noticeable stopping points. |

However, users have the flexibility to adjust mode parameters to attain various responses. Within the following structure, users can modify these values to customize the functionality according to their specific requirements.

```
```c
typedef struct {
int32_t num_positions; // Number of positions
int32_t position; // Current position
Expand All @@ -32,10 +28,10 @@ typedef struct {

```

### Hardware Required
### Hardware Required
This example is specifically designed for ESP32-S3-Motor-LCDkit.

Other components
Other components
1. The BLDC Motor Model 5v 2804 is compatible and can be employed.
2. A Position Sensor (Hall-based) such as MT6701 or AS5600 is suitable for use.

Expand All @@ -53,9 +49,11 @@ step2: build the project
idf.py build
```

step 3: Flash and monitor
step 3: Flash and monitor
Flash the program and launch IDF Monitor:

```bash
idf.py flash monitor
```
```

![FOC Knob exmaple](https://dl.espressif.com/ae/esp-iot-solution/foc_knob.gif)
10 changes: 10 additions & 0 deletions examples/motor/foc_knob_example/components/foc_knob/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
menu "FOC Knob"

config FOC_KNOB_MAX_VELOCITY
int "FOC Knob Max Velocity"
range 1 100
default 23
help
When the maximum velocity is smaller, the rebound velocity will also be smaller.

endmenu
31 changes: 15 additions & 16 deletions examples/motor/foc_knob_example/components/foc_knob/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# Component FOC Knob
# Component FOC Knob
The FOC knob is a component that offers an extensive API, empowering the user to define various modes of operation. Users have the flexibility to employ different types of BLDC motors to achieve the desired functionality of a haptic feedback knob.

## Modes supported
By default, certain modes are pre-defined in the **foc_knob_default.c** file. Users have the option to leverage these default modes for their applications.

| Mode | Description |
|-----------------------------------|------------------------------------------------------------|
| 0. Fine Value with Detents | Motor can be unbounded with fine rotation and fine dents points. |
| 1. Unbounded, No Detents | Motor can be unbounded with fine rotation and no dent points. |
| 2. Super Dial | Motor can be unbound with fine rotation and noticeable dent points. |
| 3. Fine Values with Detents, Unbounded | Motor can be unbounded with fine rotation and noticeable dents points. |
| 4. Bounded 0-13, No Detents | Motor will be constrained within a specific range (180-360) with fine rotation and no detent points. |
| 5. Coarse Values, Strong Detents | Motor can be unbounded with coarser rotation and strong dent points. |
| 6. Fine Values, No Detents | Motor will be constrained within a specific range (256, 127), fine rotation, no dent points |
| 7. On/Off, Strong Detents | Motor will be constrained within a specific range presents a On/off functionality with noticeable stopping points. |
| Mode | Description |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| 0. unbound no detents | Motor can be unbounded with fine rotation and no dent points. |
| 1. Unbounded Fine detents | Motor can be unbounded with fine rotation and fine dent points. |
| 2. Unbounded Strong detents | Motor can be unbound with fine rotation and noticeable dent points. |
| 3. Bounded No detents | Motor will be constrained within a specific range (0-360) with fine rotation and no detent points. |
| 4. Bounded Fine detents | Motor can be constrained with coarser rotation and fine dent points. |
| 5. Bounded Strong detents | Motor can be constrained with coarser rotation and strong dent points. |
| 6. On/Off strong detents | Motor will be constrained within a specific range presents a On/off functionality with noticeable stopping points. |

However, users have the flexibility to adjust mode parameters to attain various responses. Within the following structure, users can modify these values to customize the functionality according to their specific requirements.

```
```c
typedef struct {
int32_t num_positions; // Number of positions
int32_t position; // Current position
Expand All @@ -26,15 +25,15 @@ typedef struct {
float endstop_strength_unit; // Strength of detent when reaching the end
float snap_point; // Snap point for each position
const char *descriptor; // Description
} knob_param_t;
} foc_knob_param_t;

```
### Hardware Required
### Hardware Required
This example is specifically designed for ESP32-S3-Motor-LCDkit.

Other components
Other components
1. The BLDC Motor Model 5v 2804 is compatible and can be employed.
2. A Position Sensor (Hall-based) such as MT6701 or AS5600 is suitable for use.

### Example
### Example
[FOC_knob_example](../../../foc_knob_example/)
Loading

0 comments on commit 1d7a23c

Please sign in to comment.