22constexpr uint32_t kPPR = 12;
23constexpr uint32_t kReductionRation = 90;
25#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
127 Serial.begin(115200);
128 printf(
"setting up\n");
130 g_encoder_motor_0.Init();
131 g_encoder_motor_1.Init();
132 g_encoder_motor_2.Init();
133 g_encoder_motor_3.Init();
135 printf(
"setup completed\n");
139 const int16_t speed_rpm = map(analogRead(26), 0, 4095, -21, 21) * 5;
141 g_encoder_motor_0.RunSpeed(speed_rpm);
142 g_encoder_motor_1.RunSpeed(speed_rpm);
143 g_encoder_motor_2.RunSpeed(speed_rpm);
144 g_encoder_motor_3.RunSpeed(speed_rpm);
146 printf(
"target speed rpm: %4" PRIi16
", current speed rpm: [%4" PRId32
", %4" PRId32
", %4" PRId32
", %4" PRId32
147 "], pwm duties: [%5 " PRIi16
", %5" PRIi16
", %5" PRIi16
", %5" PRIi16
"], pulse counts: [%" PRId64
", %" PRId64
148 ", %" PRId64
", %" PRId64
"]\n",
150 g_encoder_motor_0.SpeedRpm(),
151 g_encoder_motor_1.SpeedRpm(),
152 g_encoder_motor_2.SpeedRpm(),
153 g_encoder_motor_3.SpeedRpm(),
154 g_encoder_motor_0.PwmDuty(),
155 g_encoder_motor_1.PwmDuty(),
156 g_encoder_motor_2.PwmDuty(),
157 g_encoder_motor_3.PwmDuty(),
158 g_encoder_motor_0.EncoderPulseCount(),
159 g_encoder_motor_1.EncoderPulseCount(),
160 g_encoder_motor_2.EncoderPulseCount(),
161 g_encoder_motor_3.EncoderPulseCount());
@ kAPhaseLeads
Represents the situation where phase A leads phase B when the motor is rotating forward.
String Version()
Get the version number string.