![]() ![]() This routine is responsible for reading the IMU (MPU6050), calculating necessary control signal, e.i. ![]() The next time-sensitive task is to update the velocity and recalculate the step delay, this should be run faster than the measurement routing, otherwise, the "force" will not have enough time to act and to have an effect. This routine should be as fast as possible and should not contain any floating-point calculations. But the step itself should be precise in time, so I used a timer interrupt to make steps and 40kHz frequency (tried with 8kHz up to 100kHz, works fine but it eats CPU cycles and the control is not very smooth). Since we have stepper motors, we need to calculate the next step delay ideally after each step (or as fast as possible). It means the motors should turn with acceleration. The robot balances itself by applying a force that is roughly proportional to the angle. I used 2 embedded PID control loops, one for holding the upright position and another for stabilizing velocity or position. MPU6050 - gyro and accelerometer with DMP on-board, also tried with the more advanced chip: MPU9250, but I didn't find good library support yet.Arduino Nano, 16MHz, I tried to squeeze as much computing power as possible, I'll probably replace it with the BlackPill (100MHz) or ESP32 WROOM (80-240MHz).So far I ended up with the following setup: I prefer to simulate the system before I build it and tune the parameters in a safe virtual environment. I thoroughly described the model and the simulation in my article. In this article, I'll outline the main issues I faced working on the project, hope this will be useful in your future projects and you'll learn something new. That time I ended up using a DC-motor with an encoder but numerous examples of a balancing robot with stepper motors inspired me to continue working on it. ![]() I had trouble stabilizing it using stepper motors, however, I liked the idea of producing a force with an open-loop (no encoders needed), it simplified a model quite a bit. Some time ago I was working on an inverted pendulum project. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |