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
Diff: defines.h
- Revision:
- 1:40bdbe1a93b7
- Parent:
- 0:dd126a1080d3
- Child:
- 7:794bd40830c1
--- a/defines.h Tue Feb 14 05:12:54 2017 +0000 +++ b/defines.h Fri Jun 22 02:09:50 2018 +0000 @@ -1,67 +1,70 @@ +#ifndef DEFINES_H +#define DEFINES_H -#ifndef DEFINES_H_INCLUDED -#define DEFINES_H_INCLUDED +#include "defines_debug.h" +#include "defines_pins.h" //#####################################################################################\\ +#define SERIAL_BAUD_RATE 115200 + #define N_THRUSTERS 8 -#define PID_PERIOD 50.0 // [ms] -#define LED_PERIOD 50.0 // [ms] -#define DEBUG_PERIOD 1000.0 // [ms] -#define THRUST_PERIOD 1000.0 // [ms] -#define THRUST_PWM_N 10 // Number of PWM steps per PID period +#define PID_PERIOD 50.0 // [ms] Update period of the PID command +#define LED_PERIOD 50.0 // [ms] Period of the blinking LED +#define MEAS_PERIOD 50.0 // [ms] Period at which to publish new velocity measurement +#define PID_DEBUG_PERIOD 2500.0 // [ms] Period at which to publish PID parameters +#define THRUST_PERIOD 500.0 // [ms] PWM period of thrusters +#define THRUST_PWM_N 20.0 // Number of PWM steps per PID period +#define MOTOR_PWM_PERIOD 0.00005 // 20 kHz + +// Parameters for motor encoder +#define NCREV 64.0 // Number of counts per revolution +#define SPEED_COUNTS 100 // Number of counts per speed measurement in encoder + +#define NGR 18.75 // Gear ratio +#define V_SMAX 500.0 // [RPM] No-load max shaft speed +#define M2SEC 60.0 // [sec/min] Conversion +#define REV2DEG 360.0 // [deg/rev] Conversion + +#define V_SMAX_ENF 400.0 // [RPM] Enforced maximum shaft speed +#define V_SMIN_ENF 0.0 // [RPM] Enforced minimum shaft speed -#define NCREV 64.0 // Number of counts per revolution -#define NGR 18.75 // Gear ratio -#define V_SMAX 500.0 // [RPM] No-load max shaft speed -#define M2SEC 60.0 -#define MOTOR_PWM_PERIOD 0.00005 // 20 kHz -#define SPEED_COUNTS 50 // Number of counts per speed measurement in encoder -#define SCALED_MAX 10000.0 // Number representing maximum motor speed -#define V_SMAX_ENF 400.0 // [RPM] Enforced maximum shaft speed -#define V_SMIN_ENF 10.0 // [RPM] Enforced minimum shaft speed +#define COUNTS2SHAFT M2SEC/NCREV/NGR // Counts/sec to shaft speed in RPM + +#define R 2.4 // 12 V / 5 A +#define CURRENT_MAX 5.0 // Stall curent of motor +#define VOLTAGE_MAX 12.0 // Supply voltage to motor -#define R 2.4 // 12 V / 5 A -#define CURRENT_MAX 5.0 // Stall curent of motor -#define VOLTAGE_MAX 12.0 // Supply voltage to motor +// Regular PID +#define KP_INIT 1.0 +#define KI_INIT 0.0001 +#define KD_INIT 0.0 +#define ACC_LIMIT_INIT 0.0 // Scaled accumulated error limit -#define KP 1.0 -#define KI 0.0002 -#define KD 0.0 -#define ACC_LIMIT 3.0 // Scaled accumulated error limit +// PID with feed-foward term +#define KP_FF_INIT 0.1 +#define KI_FF_INIT 0.00001 +#define KD_FF_INIT 0.0 +#define ACC_LIMIT_FF_INIT 0.0 +#define SLOPE_FF_INIT 0.001704 +#define INTER_FF_INIT -0.0171 #define SMOOTHING_VAL 0.9 -#define PWM_LIMIT 1.0 +#define PWM_LIMIT 0.7 #define INITIAL_SP 0.0 -#define COARSE_INCR 2000.0 -#define FINE_INCR 1000.0 -#define HAIR_INCR 200.0 +#define COARSE_INCR 50.0 +#define FINE_INCR 25.0 +#define HAIR_INCR 5.0 -#define KE_ADJUST 0.75 -#define WAIT_LIMIT 5 - -#define DEFAULT_BAUD_RATE 115200 -#define DEFAULT_BITS 8 -#define DEFAULT_PARITY Serial::None -#define DEFAULT_STOP_BITS 1 +#define KE VOLTAGE_MAX/(V_SMAX*NGR) -#define SCALE_VELCOUNTS 1000.0*SCALED_MAX*M2SEC/(NCREV*V_SMAX*NGR*VEL_PERIOD) -#define SCALE_COUNTS SCALED_MAX*M2SEC/(NCREV*V_SMAX*NGR) -#define SCALE_VSHAFT SCALED_MAX/V_SMAX -#define KE VOLTAGE_MAX/(V_SMAX*NGR) -#define KE_SCALED VOLTAGE_MAX/SCALED_MAX*KE_ADJUST -#define SCALED_SMAX_ENF V_SMAX_ENF*SCALE_VSHAFT -#define SCALED_SMIN_ENF V_SMIN_ENF*SCALE_VSHAFT - -/*extern const float SCALE_VELCOUNTS = 1000.0*SCALED_MAX*M2SEC/(NCREV*V_SMAX*NGR*VEL_PERIOD); // Scales motor pulses per velocity period to scaled motor speed (0 to SCALED_MAX) -extern const float SCALE_COUNTS = SCALED_MAX*M2SEC/(NCREV*V_SMAX*NGR); // Scales motor pulses per second to scaled motor speed -extern const float SCALE_VSHAFT = SCALED_MAX/V_SMAX; -extern const float KE = VOLTAGE_MAX/(V_SMAX*NGR); // [V*s/(motor revs)] Motor voltage constant //(60.0/(582.0*NCREV)) // 18.75 gear ratio * 500 RPM / 12 V -extern const float KE_SCALED = VOLTAGE_MAX/SCALED_MAX*KE_ADJUST; -extern const float SCALED_SMAX_ENF = V_SMAX_ENF*SCALE_VSHAFT; -extern const float SCALED_SMIN_ENF = V_SMIN_ENF*SCALE_VSHAFT;*/ +// RGBA LED parameters +#define MODE_AMBER false +#define RGB_LED_PERIOD 50 +#define DEF_CLR_FADE_T 1000 +#define DEF_ALP_FADE_T 1000 //#####################################################################################\\