Labeling Machine

Hi, everybody!

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.

Setup:

  • 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:

  1. 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.
  2. 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:

  1. 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?
  2. 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?
  3. 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?

Thank you so much in advance for your help! :pray:t3:

1 Like

Hi there, welcome to SimpleFOC!

Sounds like a very interesting project, please send us some pics :slight_smile:

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.

Please let us know how it goes :slight_smile:

1 Like



Hello runger, thanks for responding to my questions.

If I change the hardware, will the library with the stepper motor achieve good accuracy, or am I better off buying a servo motor like this one
https://a.co/d/9mlSpv7

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.

It sounds to me like a stepper with tmc2209 or similar driver would probably do what you want more easily and result in a cheaper system. I would check if you have a repeatability issue or something else.

Rungers advice is all good, I was able to use a bunch of darlington transistors without difficulty as a power stage if that’s useful, you can get darlington transistors that say they can handle 5 amps pretty cheap.

IF you use a stepper motor there probably is little need or SimpleFOC. I used a stepper library with the raspberry pi pico recently and it was a snap.