#ifndef CONSTANTS_H #define CONSTANTS_H /** * @brief all constants and custom data types * */ //#define DCAITI_DEBUG 0 /* 1 is on the right, 2 on the left */ /* motors */ #define NUM_MOTORS 2 #define M1_EN_PIN 10 #define M1_DIR_PIN 11 #define M2_EN_PIN 9 #define M2_DIR_PIN 8 #define SPEED_THRESHOLD 8 /* encoders */ #define ENC_1_A 6 #define ENC_1_B 7 #define ENC_2_A 5 #define ENC_2_B 4 #define COUNT_PER_ROTATION 3533 #define CHAIN_LENGTH_M 0.741 #define VEL_UPDATE_RATE_MS 20 #define MAX_SPEED 0.6 /* pid control */ #define KP_1 10 #define KD_1 0.0 #define KI_1 0.0 #define KP_2 10 #define KD_2 0.0 #define KI_2 0.0 #define VEL2TORQUE_RATIO 1.0 #define P_GAIN 1.0 /* misc */ #define PRINT_RATE_MS 500 /* uart */ #define UART_BAUD_RATE 115200 #define MAX_PACKET_LENGTH 50 #define PACKAGE_LENGTH_NO_P 10 #define RX_328_PIN 6 #define TX_328_PIN 7 #define UART_TRANSMIT_MS 10 #define PACKAGE_PAUSE_MS 10 #define START_BYTE_POS 0 #define FRAME_TYPE_POS 1 #define PAYLOAD_LENGTH_POS 2 #define COMPONENT_POS 3 #define TIMESTAMP_POS 4 #define COMMAND_POS 8 #define PAYLOAD_POS 8 #define FRAME_TYPE_STARTBIT 7 #define FRAME_TYPE_ENDBIT 5 #define COMPONENT_STARTBIT 7 #define COMPONENT_ENDBIT 4 #define START_BYTE 0xAA #define REQUEST_DRIVE_MOTOR 0x01 #define REQUEST_RESET_TIMESTAMP 0x02 #define FT_VALUE_BV 0 #define FT_REQUEST_BV 32 #define FT_RESPONSE_BV 64 #define CP_DEFAULT_BV 0 #define CP_LEFT_M_BV 16 #define CP_RIGHT_M_BV 32 #define CP_ALL_M_BV 48 #define LAST(k,n) ((k) & ((1<<(n))-1)) #define MID(k,m,n) LAST((k)>>(m),((n)-(m))) typedef enum frametypes { VALUE, REQUEST, RESPONSE } U_FrameType; typedef enum components { DEFAULT_COMPONENT, LEFT_MOTOR, RIGHT_MOTOR, ALL_MOTORS } U_Component; typedef enum requests { DEFAULT_REQUEST, DRIVE_MOTOR, RESET_TIMESTAMP, DRIVE_ENCODER, PID_PARAMETER } U_Request; #endif