| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /////////////////////////////////////////////////////////////////////////
- // Configuration
- //////////////////////////////////////////////////
- #define MAX_POWER_PERCENT 90 // The maximum percentage on time, used to decrease average voltage to the motor.
- #define SCAN_DELAY 10 // Delay between updates in ms
- #define AVG_OVER_MILLIS 1500 // Number of milliseconds to average the speed over
- /////////////////////////////////////////////////////////////////////////
- // Output config
- /////////////////////////////////////////////////////////////////////////
- //#define SCAN_MODE // If set, output channel values rather than driving the robot.
- //#define DEBUG // If set, adjust timings and output debug lines
- #ifdef DEBUG
- #define SCAN_DELAY 1000
- #define AVG_OVER_MILLIS 3000
- #endif
- /////////////////////////////////////////////////////////////////////////
- // Internal values
- /////////////////////////////////////////////////////////////////////////
- #define LEFT 0
- #define RIGHT 1
- #define OUTPUT_RANGE 255 // The maximum value for PWM output
- #define THROT_RANGE 1000 // Value output by throttle (-THROT_RANGE to THROT_RANGE), later constrained to OUTPUT_RANGE
- #define STEER_RANGE THROT_RANGE/2 // Value output by steering (-STEER_RANGE to STEER_RANGE) to adjust throttles
- #define AVG_PERIODS AVG_OVER_MILLIS/SCAN_DELAY // Number of periods to average the speed over (reduces random variances)
- /////////////////////////////////////////////////////////////////////////
- // Channel pins
- /////////////////////////////////////////////////////////////////////////
- #define LOW_CHANNEL 1
- #define NUM_CHANNELS 6
- // Channel pins. Using numbers 1-6 for clarity, so using a bad value in index 0.
- const byte channels[7] = {255, 8,9,10,11,12,13};
- // How long (in microseconds) the channel is being held high for.
- int channelVals[NUM_CHANNELS + 1];
- /////////////////////////////////////////////////////////////////////////
- // Channel values
- /////////////////////////////////////////////////////////////////////////
- #define DEAD_MAN_MILLIS 100 // Time to wait after last interrupt before figuring the controller turned off
- // Right horizontal (steering)
- #define STEER_CHANNEL 1
- #define STEER_LEFT 1300
- #define STEER_RIGHT 1690
- #define STEER_NONE 1500
- #define STEER_DEAD_ZONE 30 // 10% of the range is dead zone
- // Right vertical (throttle)
- #define THROT_CHANNEL 2
- #define THROT_MAX 1940
- #define THROT_MIN 1160
- #define THROT_NONE 1510// Halfway range
- #define THROT_DEAD_ZONE 30 // approx 10% of the range is dead
- #define THROT_OFF 0 // Anything below this means the throttle switch (upper right) is off
- #define CH_4_MIN 0
- #define CH_4_MAX 0
- // Right knob
- #define LIGHT_CHANNEL 5
- #define LIGHT_MIN 990
- #define LIGHT_MAX 1990
- // Left knob
- #define SPEED_CHANNEL 6
- #define SPEED_MIN 1000
- #define SPEED_MAX 2000
- /////////////////////////////////////////////////////////////////////////
- // Output pins
- /////////////////////////////////////////////////////////////////////////
- #define LEFT_MOTOR_DIRECT_PIN 4
- #define LEFT_MOTOR_PIN 5
- #define RIGHT_MOTOR_PIN 6
- #define RIGHT_MOTOR_DIRECT_PIN 7
|