I hope you’re all doing well. I’m reaching out because I’m currently facing some precision issues with my setup, and I could really use your expertise and advice.
Microcontroller: Arduino Uno
Magnetic Encoder: AS5600
Motor Driver: L298N
Application: Labeling Machine
I’m using the SimpleFOC library to control a motor for a labeling machine application, and I’m having trouble achieving the level of precision I need. The labels need to be applied with great accuracy, so precision is crucial in this project.
Issues I’m Facing:
Lack of Precision: The motor isn’t stopping precisely at the desired positions, resulting in label misalignment. I suspect this might be due to tuning issues or perhaps limitations with the L298N driver.
Arduino Uno: I’m using an Arduino Uno, but I’ve heard that Teensy boards may be better suited for real-time control applications. Could switching to a Teensy board potentially improve the precision and control of my labeling machine?
Questions for the Community:
Have any of you worked with a similar setup involving an AS5600 encoder, L298N driver, and the SimpleFOC library for precise positioning? If so, what tips or tricks can you share?
Do you think switching to a Teensy board is a good idea for improved real-time control and precision, or are there other suggestions for optimizing my existing setup?
Are there specific parameters or settings in the SimpleFOC library that I should focus on for fine-tuning the control loop and achieving higher precision?
Sounds like a very interesting project, please send us some pics
I think you‘ve made your life a bit difficult by choosing the lowest spec components for all parts of the system:
UNO is only 8bit MCU and very slow compared to modern 32bit MCUs
L298N is not a BLDC driver. It is very old and slow transistor based tech. A modern BLDC driver uses FETs which switch much faster, and with far less losses
AS5600 is only 12bits, and uses I2C (which is slow)
Personally, I would not switch to the Teensy, because while it is the fastest MCU we support, the support is not as good as with other MCU types. If you do go for Teensy, use a Teensy 4 and not a 3.
RP2040 like a RPi Pico would be an inexpensive MCU that works well, also ESP32 Wroom or S3 type MCUs are cheap and super-fast.
STM32G4 or STM32F4 MCUs are probably the best supported, and work very well, but cost a little more.
For the driver, please switch to a dedicated BLDC driver, any model you choose will be better than L298N. A SimpleFOC mini will work fine.
For the sensor, I would recommend a better sensor, with an SPI or ABZ type interface. AS5048A or AS5047P work well and are not too expensive.
I think once you improve your hardware you will find it easier to tune it. Getting it to stop precisely in angle mode will be a matter of having a decently fast main loop, and tuning the velocity and angle PIDs until you get a good result. You can also use the max-ramp (acceleration) and velocity limits, as well as the LPF (low pass filter) settings to tune the performance.
It’s possible to achieve good accuracy, yes, but of course it can take some work and careful tuning of the system.
I think it won’t be any different for the servo in that regard, but of course servo and stepper motors are quite different in the end. I can’t say which is better in your application.