NXPCUP-libary
Library for car's control board on NXPCUP competition based on the Mbed framework.
Config.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "mbed.h"
4 
5 #include "Buttons.h"
6 #include "Camera.h"
7 #include "Motor.h"
8 #include "MotorControl.h"
9 #include "ObstacleDetector.h"
11 #include "SoftPWM.h"
12 #include "atoms/control/pid.h"
13 
14 #if !(defined MOTOR_HARDWARE_PWM || defined MOTOR_SOFTWARE_PWM)
15 #error It is neccesary to define which type of PWM you want use in Motor class: #define MOTOR_HARDWARE_PWM or #define MOTOR_SOFTWARE_PWM
16 #endif
17 
18 #if !(defined SERVO_HARDWARE_PWM || defined SERVO_SOFTWARE_PWM)
19 #error It is neccesary to define which type of PWM you want use in Servo class: #define SERVO_HARDWARE_PWM or #define SERVO_SOFTWARE_PWM
20 #endif
21 
22 namespace nxpcup {
23 namespace detail {
24  struct Bluetooth {
25  PinName TX;
26  PinName RX;
27  };
28 } // namespace detail
29 
30 namespace alamak {
31  namespace kl25z {
32  namespace config {
33 
34  nxpcup::Motor::Config MOTOR_LEFT{ PTA4, PTA5 }; // pins with PWM
35  nxpcup::Motor::Config MOTOR_RIGHT{ PTC9, PTC8 }; // pins with PWM
36 
38  PTC2, // analog in pin
39  PTB9, // clock pin
40  PTB8, // scan impulse pin
41  4000 // exposition in us
42  };
44  PTC1, // analog in pin
45  PTB11, // clock pin
46  PTB10, // scan impulse pin
47  4000 // exposition in us
48  };
49 
51  PTA12, // pin with PWM
52  -10, // angle correction,
53  45, // servo min/max angle,
54  0, // servo default angle
55  true // inverse the servo signal - IMPORTANT information in @{Servo::Config::isReverseSignal}
56  };
58  PTA13, // pin with PWM
59  0, // angle correction,
60  45, // servo min/max angle,
61  0 // servo default angle
62  };
63 
64  nxpcup::MotorControl::Config MOTOR_CONTROL{}; // use the default config
65 
67 
69  PTB2, // pin for left sensor with ADC
70  PTB3, // pin for right sensor with ADC
71  23000, // thresholdDistance
72  18, // moveFromObstacle - lower value -> closer to detected line
73  0.8, // encoderAvoidDistance (meters)
74  false // obstacle detector is deactivate
75  };
76 
78  PTC0, // analog in pin
79  // { button id, boundary analog value }
80  { { 3, 3840 }, { 2, 40448 }, { 4, 47104 }, { 5, 51200 }, { 6, 56320 } }
81  };
82 
83  detail::Bluetooth BLUETOOTH{ PTE22, PTE23 }; // TX, RX
84 
86  PTD4, // pin with interrupt
87  400 // pulsePerRevolution
88  };
90  PTD6, // pin with interrupt
91  400 // pulsePerRevolution
92  };
93 
95  2.5, // P constant
96  0, // I constant
97  0.8, // D constant
98  -90, // minimal value
99  90 // maximal value
100  };
101 
102  static constexpr uint8_t LORISS_SEND_PERIOD_MS = 150;
103 
104  } // namespace config
105  } // namespace kl25z
106 
107  namespace k66f {
108  namespace config {
109 
110  nxpcup::Motor::Config MOTOR_LEFT{ PTC12, PTC5 }; // pins with PWM
111  nxpcup::Motor::Config MOTOR_RIGHT{ PTA25, PTC2 }; // pins with PWM
112 
114  PTB3, // analog in pin
115  PTA26, // clock pin
116  PTA27, // scan impulse pin
117  4000 // exposition in us
118  };
120  PTB2, // analog in pin
121  PTA6, // clock pin
122  PTA4, // scan impulse pin
123  4000 // exposition in us
124  };
125 
127  PTC8, // pin with PWM
128  -10, // angle correction,
129  45, // servo min/max angle,
130  0, // servo default angle
131  true // inverse the servo signal - IMPORTANT information in @{Servo::Config::isReverseSignal}
132 
133  };
135  PTB18, // pin with PWM
136  5, // angle correction,
137  60, // servo min/max angle,
138  0, // servo default angle
139  500, // minUs pulse width
140  2400 // maxUs pulse width
141  // SG90 pulse width: https://servodatabase.com/servo/towerpro/sg90
142  };
143 
144  nxpcup::MotorControl::Config MOTOR_CONTROL{}; // use the default config
145 
147 
149  PTB7, // analog in pin
150  SERVO2, // servo for moving sensor
151  48000, // triggerDistance
152  15, // moveFromObstacle - lower value -> closer to line
153  0.8 // encoderAvoidDistance (meters)
154  };
155 
156  //nxpcup::Buttons::Config BUTTONS // not available due to missing ADC on the pin PTE11
157 
158  detail::Bluetooth BLUETOOTH{ PTC4, PTC3 }; // { TX, RX }
159 
161  PTC16, // pin with interrupt
162  400 // pulsePerRevolution
163  };
165  PTD13, // pin with interrupt
166  400 // pulsePerRevolution
167  };
168 
170  2.5, // P constant
171  0, // I constant
172  0.8, // D constant
173  -90, // minimal value
174  90 // maximal value
175  };
176 
177  constexpr int LORISS_SEND_PERIOD_MS = 150;
178 
179  } // namespace config
180  } // namespace k66f
181 
182 
183 } // namespace alamak
184 } // nxpcup
Definition: Motor.h:12
nxpcup::Encoder::Config ENCODER_LEFT
Definition: Config.h:160
PinName RX
Definition: Config.h:26
Definition: Config.h:24
nxpcup::MotorControl::Config MOTOR_CONTROL
Definition: Config.h:144
nxpcup::Motor::Config MOTOR_LEFT
Definition: Config.h:110
constexpr int LORISS_SEND_PERIOD_MS
Definition: Config.h:177
atoms::Pid< float >::Config STEERING_PID_CONFIG
Definition: Config.h:169
Definition: Encoder.h:9
Definition: BorderDetector.h:6
Definition: ObstacleDetectorWithServo.h:13
nxpcup::Servo::Config SERVO1
Definition: Config.h:126
nxpcup::BorderDetector::Config BORDER_DETECTOR
Definition: Config.h:146
Definition: Servo.h:11
nxpcup::Buttons::Config BUTTONS
Definition: Config.h:77
Definition: MotorControl.h:14
Definition: BorderDetector.h:12
nxpcup::Encoder::Config ENCODER_RIGHT
Definition: Config.h:164
detail::Bluetooth BLUETOOTH
Definition: Config.h:158
nxpcup::Camera::Config CAMERA2
Definition: Config.h:119
Definition: pid.h:13
nxpcup::Servo::Config SERVO2
Definition: Config.h:134
Definition: Camera.h:16
PinName TX
Definition: Config.h:25
nxpcup::Camera::Config CAMERA1
Definition: Config.h:113
nxpcup::Motor::Config MOTOR_RIGHT
Definition: Config.h:111
nxpcup::ObstacleDetectorWithServo::Config OBSTACLE_DETECTOR
Definition: Config.h:148
Definition: Buttons.h:13
Definition: ObstacleDetector.h:9