Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ros_lib_kinetic
defines.h@7:794bd40830c1, 2021-03-02 (annotated)
- Committer:
- thomasjlew
- Date:
- Tue Mar 02 22:49:24 2021 +0000
- Revision:
- 7:794bd40830c1
- Parent:
- 1:40bdbe1a93b7
Embedded code for RSS 2021 Safe Active Learning submission - increased control frequency / reduced PWM duty cycle.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Knillinux | 1:40bdbe1a93b7 | 1 | #ifndef DEFINES_H |
Knillinux | 1:40bdbe1a93b7 | 2 | #define DEFINES_H |
Knillinux | 0:dd126a1080d3 | 3 | |
Knillinux | 1:40bdbe1a93b7 | 4 | #include "defines_debug.h" |
Knillinux | 1:40bdbe1a93b7 | 5 | #include "defines_pins.h" |
Knillinux | 0:dd126a1080d3 | 6 | |
Knillinux | 0:dd126a1080d3 | 7 | //#####################################################################################\\ |
Knillinux | 0:dd126a1080d3 | 8 | |
Knillinux | 1:40bdbe1a93b7 | 9 | #define SERIAL_BAUD_RATE 115200 |
Knillinux | 1:40bdbe1a93b7 | 10 | |
Knillinux | 0:dd126a1080d3 | 11 | #define N_THRUSTERS 8 |
Knillinux | 0:dd126a1080d3 | 12 | |
Knillinux | 1:40bdbe1a93b7 | 13 | #define PID_PERIOD 50.0 // [ms] Update period of the PID command |
Knillinux | 1:40bdbe1a93b7 | 14 | #define LED_PERIOD 50.0 // [ms] Period of the blinking LED |
Knillinux | 1:40bdbe1a93b7 | 15 | #define MEAS_PERIOD 50.0 // [ms] Period at which to publish new velocity measurement |
Knillinux | 1:40bdbe1a93b7 | 16 | #define PID_DEBUG_PERIOD 2500.0 // [ms] Period at which to publish PID parameters |
thomasjlew | 7:794bd40830c1 | 17 | #define THRUST_PERIOD 100.0 // [ms] PWM period of thrusters |
thomasjlew | 7:794bd40830c1 | 18 | #define THRUST_PWM_N 1000.0 // Number of PWM steps per PID period |
Knillinux | 1:40bdbe1a93b7 | 19 | #define MOTOR_PWM_PERIOD 0.00005 // 20 kHz |
Knillinux | 1:40bdbe1a93b7 | 20 | |
Knillinux | 1:40bdbe1a93b7 | 21 | // Parameters for motor encoder |
Knillinux | 1:40bdbe1a93b7 | 22 | #define NCREV 64.0 // Number of counts per revolution |
Knillinux | 1:40bdbe1a93b7 | 23 | #define SPEED_COUNTS 100 // Number of counts per speed measurement in encoder |
Knillinux | 1:40bdbe1a93b7 | 24 | |
Knillinux | 1:40bdbe1a93b7 | 25 | #define NGR 18.75 // Gear ratio |
Knillinux | 1:40bdbe1a93b7 | 26 | #define V_SMAX 500.0 // [RPM] No-load max shaft speed |
Knillinux | 1:40bdbe1a93b7 | 27 | #define M2SEC 60.0 // [sec/min] Conversion |
Knillinux | 1:40bdbe1a93b7 | 28 | #define REV2DEG 360.0 // [deg/rev] Conversion |
Knillinux | 1:40bdbe1a93b7 | 29 | |
Knillinux | 1:40bdbe1a93b7 | 30 | #define V_SMAX_ENF 400.0 // [RPM] Enforced maximum shaft speed |
Knillinux | 1:40bdbe1a93b7 | 31 | #define V_SMIN_ENF 0.0 // [RPM] Enforced minimum shaft speed |
Knillinux | 0:dd126a1080d3 | 32 | |
Knillinux | 1:40bdbe1a93b7 | 33 | #define COUNTS2SHAFT M2SEC/NCREV/NGR // Counts/sec to shaft speed in RPM |
Knillinux | 1:40bdbe1a93b7 | 34 | |
Knillinux | 1:40bdbe1a93b7 | 35 | #define R 2.4 // 12 V / 5 A |
Knillinux | 1:40bdbe1a93b7 | 36 | #define CURRENT_MAX 5.0 // Stall curent of motor |
Knillinux | 1:40bdbe1a93b7 | 37 | #define VOLTAGE_MAX 12.0 // Supply voltage to motor |
Knillinux | 0:dd126a1080d3 | 38 | |
Knillinux | 1:40bdbe1a93b7 | 39 | // Regular PID |
Knillinux | 1:40bdbe1a93b7 | 40 | #define KP_INIT 1.0 |
Knillinux | 1:40bdbe1a93b7 | 41 | #define KI_INIT 0.0001 |
Knillinux | 1:40bdbe1a93b7 | 42 | #define KD_INIT 0.0 |
Knillinux | 1:40bdbe1a93b7 | 43 | #define ACC_LIMIT_INIT 0.0 // Scaled accumulated error limit |
Knillinux | 0:dd126a1080d3 | 44 | |
Knillinux | 1:40bdbe1a93b7 | 45 | // PID with feed-foward term |
Knillinux | 1:40bdbe1a93b7 | 46 | #define KP_FF_INIT 0.1 |
Knillinux | 1:40bdbe1a93b7 | 47 | #define KI_FF_INIT 0.00001 |
Knillinux | 1:40bdbe1a93b7 | 48 | #define KD_FF_INIT 0.0 |
Knillinux | 1:40bdbe1a93b7 | 49 | #define ACC_LIMIT_FF_INIT 0.0 |
Knillinux | 1:40bdbe1a93b7 | 50 | #define SLOPE_FF_INIT 0.001704 |
Knillinux | 1:40bdbe1a93b7 | 51 | #define INTER_FF_INIT -0.0171 |
Knillinux | 0:dd126a1080d3 | 52 | |
Knillinux | 0:dd126a1080d3 | 53 | #define SMOOTHING_VAL 0.9 |
Knillinux | 1:40bdbe1a93b7 | 54 | #define PWM_LIMIT 0.7 |
Knillinux | 0:dd126a1080d3 | 55 | |
Knillinux | 0:dd126a1080d3 | 56 | #define INITIAL_SP 0.0 |
Knillinux | 1:40bdbe1a93b7 | 57 | #define COARSE_INCR 50.0 |
Knillinux | 1:40bdbe1a93b7 | 58 | #define FINE_INCR 25.0 |
Knillinux | 1:40bdbe1a93b7 | 59 | #define HAIR_INCR 5.0 |
Knillinux | 0:dd126a1080d3 | 60 | |
Knillinux | 1:40bdbe1a93b7 | 61 | #define KE VOLTAGE_MAX/(V_SMAX*NGR) |
Knillinux | 0:dd126a1080d3 | 62 | |
Knillinux | 1:40bdbe1a93b7 | 63 | // RGBA LED parameters |
Knillinux | 1:40bdbe1a93b7 | 64 | #define MODE_AMBER false |
Knillinux | 1:40bdbe1a93b7 | 65 | #define RGB_LED_PERIOD 50 |
Knillinux | 1:40bdbe1a93b7 | 66 | #define DEF_CLR_FADE_T 1000 |
Knillinux | 1:40bdbe1a93b7 | 67 | #define DEF_ALP_FADE_T 1000 |
Knillinux | 0:dd126a1080d3 | 68 | |
Knillinux | 0:dd126a1080d3 | 69 | //#####################################################################################\\ |
Knillinux | 0:dd126a1080d3 | 70 | |
Knillinux | 0:dd126a1080d3 | 71 | #endif // End include guard |