118 Commits

Author SHA1 Message Date
raiden00pl
94d02aaaf2 examples: unify Private Types banners
unify Private Types banners according to NuttX coding standard

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-05-28 10:16:50 +08:00
Alin Jerpelea
a91768e715 examples: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-12-30 18:02:50 +08:00
raiden00pl
a7024aea89 examples/foc: protect control loop with critical section
If the controller frequency is high, system timer interrupts will
eventually interrupt the controller function, thereby increasing the
execution time. This may lead to skipping the control cycle, which
negatively affects the control algorithm.

With this option enabled, interrupts are disabled for the duration
of the controller function execution.

Here example results from CONFIG_EXAMPLES_FOC_PERF output
for b-g431b-esc1 board with CONFIG_EXAMPLES_FOC_NOTIFIER_FREQ=10000:

1. CONFIG_EXAMPLES_FOC_CONTROL_CRITSEC=n

  exec ticks=5258
    nsec=30929
  per ticks=21268
    nsec=125105

2. CONFIG_EXAMPLES_FOC_CONTROL_CRITSEC=y

  exec ticks=3428
    nsec=20164
  per ticks=19203
    nsec=112958

The difference is ~12us!
2024-10-18 10:43:46 +08:00
raiden00pl
b85a5ed306 examples/foc: ignore error for align and ident routines when motor controller disabled
CONFIG_EXAMPLES_FOC_RUN_DISABLE option is used for tests and benchmarks, so we don't
care about wrong results for motor identification and sensor alignment routines
2024-10-18 10:43:46 +08:00
raiden00pl
1aacc99491 examples/foc: print aling results only when verbose output enabled
it is a costly operation that takes a lot of time and is not of much value
2024-10-18 10:43:46 +08:00
raiden00pl
103bf83608 examples/foc: fix option that disable motor controller
fix some compiler error when EXAMPLES_FOC_RUN_DISABLE is enabled
2024-10-18 10:43:46 +08:00
raiden00pl
beeec27afd examples/foc: improve perf monitor
improve FOC perf monitor:

- add options to choose when perf result should be printed
- measure the controller thread call period
2024-10-18 10:43:46 +08:00
raiden00pl
5c166edf63 examples/foc: fix compilation error
fix compilatgion error:

foc_motor_f32.c: In function 'foc_motor_init':
foc_motor_f32.c:1574:7: error: label 'errout' used but not defined
 1574 |       goto errout;
2024-10-18 10:43:46 +08:00
raiden00pl
fc863b6cd0 examples/foc: fix snprintf warning
fix snprintf warning:

    foc_thr.c:110:39: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 7 [-Wformat-truncation=]
      110 |   snprintf(mqname, sizeof(mqname), "%s%d", CONTROL_MQ_MQNAME, envp->id);
          |                                       ^~
    foc_thr.c:110:36: note: directive argument in the range [-2147483648, 0]
      110 |   snprintf(mqname, sizeof(mqname), "%s%d", CONTROL_MQ_MQNAME, envp->id);
          |                                    ^~~~~~
    foc_thr.c:110:3: note: 'snprintf' output between 5 and 15 bytes into a destination of size 10
      110 |   snprintf(mqname, sizeof(mqname), "%s%d", CONTROL_MQ_MQNAME, envp->id);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-10-18 10:43:46 +08:00
simbit18
7e30c0e4c9 Fix Kconfig style
Remove spaces from Kconfig files
Add TABs
Add comments
2024-04-09 08:16:40 +02:00
raiden00pl
27588be53e examples/foc: replace CONFIG_INDUSTRY_FOC_* with CONFIG_EXAMPLES_FOC_*
Decouple the FOC example configuration from the FOC lib configuration.
Purely cosmetic change, without affecting functionality.
2023-11-18 08:40:16 -08:00
raiden00pl
144bf0bd1f examples/foc: remove obsolete CONFIG_EXAMPLES_FOC_IPHASE_ADC option 2023-11-15 18:49:42 +01:00
raiden00pl
fa19b71ba4 examples/foc: get iphase scale from the FOC device interface 2023-11-15 03:48:53 -08:00
raiden00pl
9eb5bd4091 examples/foc: pass from velocity controller to torque controller 2023-11-14 09:46:07 -08:00
raiden00pl
ce53f0fc4c examples/foc: add torque saturation 2023-11-14 09:46:07 -08:00
raiden00pl
dc4330476d examples/foc: add velocity saturation 2023-11-14 09:46:07 -08:00
raiden00pl
32a8c29753 examples/foc: don't raise error when EXAMPLES_FOC_IPHASE_ADC isn't set
This is the first step towards getting rid of CONFIG_EXAMPLES_FOC_IPHASE_ADC completely
2023-11-14 04:42:13 -08:00
raiden00pl
eeacbdde3a examples/foc: get velocity from observer if sensored mode 2023-11-14 10:30:52 +01:00
raiden00pl
c5314b54a4 examples/foc: fix active brake for sensored mode 2023-11-14 10:30:52 +01:00
raiden00pl
cb36d9c8b2 examples/foc: fix compilation for open-loop without angle observer 2023-11-14 10:30:52 +01:00
raiden00pl
b52f7dae0c examples/foc: set direction when updating new setpoint 2023-11-13 08:49:21 -08:00
raiden00pl
1095aec162 examples/foc: start from the beginning if control loop is started
After the start request to FOC device, we should return to the
beginning of the loop and wait for the first synchronization event.

This also fixes the problem with the extended first loop cycle,
so we can remove the workaround in foc_perf.
2023-11-13 08:48:22 -08:00
raiden00pl
f9a4ace59a examples/foc: fix warning for sensored configurations 2023-11-13 08:47:21 -08:00
raiden00pl
87dcf877e7 examples/foc: raise error if both sensorless and sensored modes enabled 2023-11-13 08:47:21 -08:00
raiden00pl
8a04e2b282 examples/foc: add #error messages 2023-11-13 08:47:21 -08:00
raiden00pl
3c541c496b examples/foc: allow sensored velocity mode 2023-11-13 08:47:21 -08:00
raiden00pl
9ba7092000 examples/foc: add support for control loop performance measurements
also format CMakeLists.txt
2023-11-06 09:02:28 +08:00
raiden00pl
73ab7dedd4 examples/foc: refactor control loop
1. get FOC device state at the beginning of the loop
2. simplify if-else block
2023-11-05 13:56:52 +08:00
raiden00pl
7e918964e4 remove examples/xxx/README.md. Migrated to Documentation/applications/examples
part of examples/bastest is moved to examples/bastest.testcases.md
2023-10-30 10:00:01 +08:00
raiden00pl
292b0cbc28 examples/foc: change the velocity ramp parameters scale to x1
controlling the ramp with greather accuracy makes no practical sense
2023-10-29 10:40:27 +08:00
raiden00pl
8568439b80 examples/foc: configure acceleration and deceleration from command line 2023-10-29 10:40:27 +08:00
raiden00pl
aad2bcb621 examples/foc: use the current configuration values when printing the help message
This is useful when tuning the controller and running application many times with different parameters from the NSH
2023-10-19 19:18:48 -04:00
raiden00pl
1c922f2d2d examples/foc: add phase angle observer support (sensorless mode)
This app can work now as sensorless ESC.

Also introduce a cmd line option that force open-loop control
which is useful when tuning angle/velocity observers
2023-10-19 19:33:43 +08:00
raiden00pl
8398297518 examples/foc: add an option to call nxscope work from control thread
This alows nxscope data to be sent with every cycle of the control loop,
which increases the execution time of the control loop, but allows data
to be sent at a highier frequency using the small nxscope buffer.

Useful when tuning and debuging using RTT transfer.
2023-10-19 01:24:07 +08:00
raiden00pl
4652c5516d examples/foc: rename SETPOINT_ADC_SCALE to SETPOINT_INTF_SCALE
SETPOINT_INTF_SCALE is more appropriate name because this definition is not only used for ADC scale
2023-10-18 14:15:47 +08:00
raiden00pl
de6a384668 examples/foc: add velocity PI controller 2023-10-18 14:15:12 +08:00
raiden00pl
9dde6983e6 examples/foc: add support for feedforward compensation 2023-10-17 22:45:26 +08:00
raiden00pl
c8a4abfcb2 examples/foc: remove align configuration checks
these are already done when you configure the align routine
2023-10-17 22:42:42 +08:00
raiden00pl
fd0da7d4df examples/foc: open-loop needs initial phase alignment 2023-10-17 22:42:42 +08:00
raiden00pl
8e0819df04 examples/foc: add velocity observers 2023-10-17 22:42:42 +08:00
raiden00pl
9bcca69967 examples/foc: initialize motor phy 2023-10-17 22:42:42 +08:00
raiden00pl
9ee4daea43 examples/foc: configure active breake current 2023-10-17 14:24:58 +08:00
raiden00pl
e8ff9ad005 foc/example/Kconfig: cosmetics 2023-10-17 14:23:42 +08:00
raiden00pl
969607ac44 examples/foc: fix setpoint scale for char interface 2023-10-17 14:23:42 +08:00
raiden00pl
4c4976a4e9 examples/foc: add warning if no controller enabled 2023-10-17 14:23:42 +08:00
raiden00pl
5dd4813b34 examples/foc: fix wrong nxscope functions for fixed16 2023-10-16 13:53:40 -04:00
raiden00pl
8ee684e586 industry/foc: make direction alignment configurable
for sensorless velocity controller (ESC) we don't need to align the direction,
but we have to align the initial motor phase each time the motor start
2023-10-16 13:44:37 -04:00
raiden00pl
b88057fffd examples/foc: support svm3 state with nxscope 2023-10-05 20:42:46 +08:00
raiden00pl
a56f0922c5 industrial/foc: add an interface that returns the modulation state
Useful for debugging and demonstrating FOC operation
2023-10-05 20:42:46 +08:00
raiden00pl
5cbd9b2b7b examples/foc: allow nxscope transfer over RTT interface
For UART serial interface TERMIOS is required, but for RTT serial interface it's not.
2023-10-02 21:46:52 +03:00