You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Find in these pages a summary of library options and build flags for your reference.
15
+
16
+
## Options
17
+
18
+
[Commonly used options](cheetsheet/options_reference) of <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span> objects.
19
+
20
+
## Build flags
21
+
22
+
[Build flags](cheetsheet/build_flags) control the way the compiler generates the code for <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span>.
So you hooked everything up, downloaded your sketch, applied power, and... nothing. Or another common scenario: motor jerks around and makes terrible sounds.
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/monitoring.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ The monitoring function can output 7 different motor specific variables:
48
48
-`target` - current target value, specific to the motion control used (either current [A], voltage [V], velocity [rad/s], or position [rad])
49
49
-`voltage.q` - [V] - set voltage in q direction
50
50
-`voltage.d` - [V] - set voltage in d direction
51
-
-`current.q` - [mA] - measured current in q direction ( if current sense available )
51
+
-`current.q` - [mA] - measured current in q direction ( if current sense available ) or estimated current if no current sense but provided phase resistance
52
52
-`current.d` - [mA] - measured current in d direction ( if current sense available )
You can test this algorithm by running the examples in the `motion_control/open_loop_motor_control/` folder.
41
41
42
-
This control algorithm is very simple. User sets the target angle it wants to achieve <i>a<sub>d</sub></i>. The algorithm only subtracts the current angle <i>a<sub>c</sub></i> and the desired angle <i>a<sub>d</sub></i> to find the direction it needs to move and goes in that direction with the highest velocity possible `motor.velocity_limit`(max velocity). To set this velocity it uses the same algorithm as for [velocity open-loop control](velocity_openloop). It integrates the velocity it in time to find out what is the angle it needs to set to the motor <i>a<sub>c</sub></i> in order to achieve it. Then the maximal allowed voltage `motor.voltage_limit` is going to be applied in the direction of the <i>a<sub>c</sub></i> using `SinePWM` or `SpaceVector` modulation.
42
+
This control algorithm is very simple. User sets the target angle it wants to achieve <i>a<sub>d</sub></i>. The algorithm only subtracts the current angle <i>a<sub>c</sub></i> and the desired angle <i>a<sub>d</sub></i> to find the direction it needs to move and goes in that direction with the highest velocity possible `motor.velocity_limit`(max velocity). To set this velocity it uses the same algorithm as for [velocity open-loop control](velocity_openloop). It integrates the velocity it in time to find out what is the angle it needs to set to the motor <i>a<sub>c</sub></i> in order to achieve it. Then the maximal allowed voltage `motor.voltage_limit` is going to be applied in the direction of the <i>a<sub>c</sub></i> using `SinePWM` or `SpaceVector` modulation.
43
+
44
+
```cpp
45
+
// calculate the distance from the target
46
+
d_angle = target_angle - past_angle;
47
+
// constrain the distance with maximal allowable displacement
The angle open-loop control will (if not provided phase resistance) set the voltage to the motor equal to the `motor.voltage_limit`
70
+
71
+
```cpp
72
+
voltage = voltage_limit; // Volts
57
73
```
74
+
This is very ineficeint, as for different motors with different phase resistances the same voltage values can produce wildly different currents.
75
+
For gimbal motor, you can run it in the open loop with the voltage limits of 5-10 Volts and it will reach the currents of 0.5-2 amps as it has the pahse resistance from 5-15 Ohms. For drone motors, the voltage limits should stay very low, under 1 volt. Because they have pahse resisatnce of 0.05 to 0.2 Ohms.
58
76
59
-
This type of motion control is highly inefficient therefore try not to use to high value for `motor.voltage_limit`. We suggest you to provide the motor class with the `phase_resistance` value and set the `motor.current_limit` instead the voltage limit. This current might be surpassed but at least you will know an approximate current your motor is drawing. You can calculate the current the motor is going to be producing by checking the motor resistance `phase_resistance` and evaluating:
77
+
### Current limiting approaches
78
+
79
+
We suggest you to provide the motor class with the `phase_resistance` value and set the `motor.current_limit` instead the voltage limit. This current might be surpassed but at least you will know an approximate current your motor is drawing. You can calculate the current the motor is going to be producing by checking the motor resistance `phase_resistance` and evaluating:
80
+
```cpp
81
+
voltage = current_limit * phase_resistance; // Amps
82
+
```
83
+
The best way to use this control strategy would be to provide both phase resistance value and KV rating of your motor. The the library would be able to calculate he back-emf voltage and much more precisely estimate the consumed current. And with the current and the back-emf current the library can set much more appropriate voltage to the motor.
voltage = current_limit*phase_resistance + desired_velocity/KV; // Amps
62
86
```
63
87
88
+
### Velocity limit
89
+
64
90
The maximal velocity `motor.velocity_limit` value is going to determine how fast your motor goes in between positions. The higher the value the faster the transition. But since we are turning the motor in open-loop we will not be able to know if the motor can follow the velocity. So make sure to put the `velocity_limit` value that is achievable for your motor. Also beware that for higher velocities and more holding torque you will need to increase the `motor.voltage_limit` or `motor.current_limit` variable as well.
65
91
92
+
### Changing limits in real-time
93
+
66
94
Also, you can change the voltage limit `motor.voltage_limit` (`motor.current_limit`) and transition velocity `motor.velocity_limit` in real-time if you need this kind of behavior in your application.
95
+
67
96
## Position open-loop control example
68
97
Here is one basic example of the velocity open-loop control with the complete configuration. The program will set the target position of `0 RAD` and maintain it, and the user can change the target position using serial terminal.
69
98
```cpp
@@ -74,12 +103,11 @@ Here is one basic example of the velocity open-loop control with the complete co
This type of motion control is highly inefficient therefore try not to use to high value for `motor.voltage_limit`. We suggest you to provide the motor class with the `phase_resistance` value and set the `motor.current_limit` instead the voltage limit. This current might be surpassed but at least you will know an approximate current your motor is drawing. You can calculate the current the motor is going to be producing by checking the motor resistance `phase_resistance` and evaluating:
62
+
The velocity open-loop control will (if not provided phase resistance) set the voltage to the motor equal to the `motor.voltage_limit`
63
+
64
+
```cpp
65
+
voltage = voltage_limit; // Volts
66
+
```
67
+
This is very ineficeint, as for different motors with different phase resistances the same voltage values can produce wildly different currents.
68
+
For gimbal motor, you can run it in the open loop with the voltage limits of 5-10 Volts and it will reach the currents of 0.5-2 amps as it has the pahse resistance from 5-15 Ohms. For drone motors, the voltage limits should stay very low, under 1 volt. Because they have pahse resisatnce of 0.05 to 0.2 Ohms.
69
+
70
+
### Current limiting approaches
71
+
72
+
We suggest you to provide the motor class with the `phase_resistance` value and set the `motor.current_limit` instead the voltage limit. This current might be surpassed but at least you will know an approximate current your motor is drawing. You can calculate the current the motor is going to be producing by checking the motor resistance `phase_resistance` and evaluating:
voltage = current_limit * phase_resistance; // Amps
64
75
```
76
+
The best way to use this control strategy would be to provide both phase resistance value and KV rating of your motor. The the library would be able to calculate he back-emf voltage and much more precisely estimate the consumed current. And with the current and the back-emf current the library can set much more appropriate voltage to the motor.
77
+
```cpp
78
+
voltage = current_limit*phase_resistance + desired_velocity/KV; // Amps
79
+
```
80
+
81
+
### Changing limits in real-time
65
82
66
83
Also, you can change the voltage/current limit in real-time if you need this kind of behavior in your application.
67
84
@@ -75,15 +92,13 @@ Here is one basic example of the velocity open-loop control with the complete co
0 commit comments