DCAITI Robot Hardware  1.0
constants.h
Go to the documentation of this file.
1 #ifndef CONSTANTS_H
2 #define CONSTANTS_H
3 
9 //#define DCAITI_DEBUG 0
10 
11 /* 1 is on the right, 2 on the left */
12 
13 /* motors */
14 #define NUM_MOTORS 2
15 #define M1_EN_PIN 10
16 #define M1_DIR_PIN 11
17 #define M2_EN_PIN 9
18 #define M2_DIR_PIN 8
19 #define SPEED_THRESHOLD 8
20 
21 /* encoders */
22 #define ENC_1_A 6
23 #define ENC_1_B 7
24 #define ENC_2_A 5
25 #define ENC_2_B 4
26 #define COUNT_PER_ROTATION 3533
27 #define CHAIN_LENGTH_M 0.741
28 #define VEL_UPDATE_RATE_MS 20
29 #define MAX_SPEED 0.6
30 
31 /* pid control */
32 #define KP_1 10
33 #define KD_1 0.0
34 #define KI_1 0.0
35 #define KP_2 10
36 #define KD_2 0.0
37 #define KI_2 0.0
38 #define VEL2TORQUE_RATIO 1.0
39 #define P_GAIN 1.0
40 
41 /* misc */
42 #define PRINT_RATE_MS 500
43 
44 /* uart */
45 #define UART_BAUD_RATE 57600
46 #define MAX_PACKET_LENGTH 50
47 #define PACKAGE_LENGTH_NO_P 10
48 #define RX_328_PIN 6
49 #define TX_328_PIN 7
50 #define UART_TRANSMIT_MS 10
51 #define PACKAGE_PAUSE_MS 10
52 
53 #define START_BYTE_POS 0
54 #define FRAME_TYPE_POS 1
55 #define PAYLOAD_LENGTH_POS 2
56 #define COMPONENT_POS 3
57 #define TIMESTAMP_POS 4
58 #define COMMAND_POS 8
59 #define PAYLOAD_POS 8
60 
61 #define FRAME_TYPE_STARTBIT 7
62 #define FRAME_TYPE_ENDBIT 5
63 
64 #define COMPONENT_STARTBIT 7
65 #define COMPONENT_ENDBIT 4
66 
67 #define START_BYTE 0xAA
68 
69 #define REQUEST_DRIVE_MOTOR 0x01
70 #define REQUEST_RESET_TIMESTAMP 0x02
71 
72 #define FT_VALUE_BV 0
73 #define FT_REQUEST_BV 32
74 #define FT_RESPONSE_BV 64
75 #define CP_DEFAULT_BV 0
76 #define CP_LEFT_M_BV 16
77 #define CP_RIGHT_M_BV 32
78 #define CP_ALL_M_BV 48
79 
80 #define LAST(k,n) ((k) & ((1<<(n))-1))
81 #define MID(k,m,n) LAST((k)>>(m),((n)-(m)))
82 
83 typedef enum frametypes {
86 
87 typedef enum components {
90 
91 typedef enum requests {
94 
95 #endif
enum frametypes U_FrameType
components
Definition: constants.h:87
@ LEFT_MOTOR
Definition: constants.h:88
@ ALL_MOTORS
Definition: constants.h:88
@ RIGHT_MOTOR
Definition: constants.h:88
@ DEFAULT_COMPONENT
Definition: constants.h:88
enum components U_Component
requests
Definition: constants.h:91
@ RESET_TIMESTAMP
Definition: constants.h:92
@ PID_PARAMETER
Definition: constants.h:92
@ DEFAULT_REQUEST
Definition: constants.h:92
@ DRIVE_ENCODER
Definition: constants.h:92
@ DRIVE_MOTOR
Definition: constants.h:92
enum requests U_Request
frametypes
Definition: constants.h:83
@ REQUEST
Definition: constants.h:84
@ VALUE
Definition: constants.h:84
@ RESPONSE
Definition: constants.h:84