TransWikia.com

Need to synchronize stepper motors

Electrical Engineering Asked by AK46 on December 31, 2021

am using two A4988 drivers to control two NEMA 17 stepper motors with 1.8 degree full step resolution on Rpi 2b. I am using them as wheels. The motors are initially given ramp signal using PGPIO wave_chain function and then a steady PWM signal using the SET_PWM function in PGPIO library.

The ramp and pwm are defined each wheel and are called together but the problem is the wheels turn one after the other and not synchronously.

pWhich wheel turns first depends on which wheels function is executed first. Please help me to resolve the issue

3 Answers

If it is possible to drive both motors from the same driver with adequate current limit, they will stay in sync. I have done that successfully with an XY gantry with two X motors on belts at high speeds and optical home recal only needed on one side each for XY over 1m square gantry that can race around all corners in a couple seconds and end up in same home position. Using an Uno with gcode file and CNC shield with Gcode Panel (Win) to USB on Uno).

Ramping step rate depends on available excess torque so drag and inertia will define your max. acceleration and braking constant.

Answered by Tony Stewart EE75 on December 31, 2021

It is known that whichever wheel function is called first, moves first. This implies a delay in returning from the execution of the wheel function.

Either

  1. try to remove delay from the code.
  2. Write a forward function which activates each one at a time
  3. Use a separate own signal tied to both stepper controllers.

Do you need complete independent control of both wheels? Thinking one own for driving both and one for driving one for steering.

Answered by Mark N Hopgood on December 31, 2021

The problem is that a Raspberry runs a kernel (linux) and you do not have direct access to the IO nor have full CPU process.

This results to a undefined, variable random delay to your IO access and is not easy to solve on a Raspberry.

If your raspberry has several CPU Core, you can reserve one core to a specific task, so you won't have kernel task switch over and you can then control your timings. You probably also would need some kernel level drivers to access the IO directly from your separate core, if that is possible. All this is not an easy feat.

The easier method would be to control your PWM with an Arduino, and connect the arduino to the raspberry through SPI/I2C, this approach will be much simpler and you will be able to accurately control and synchronize your PWM and the motor.

Here a link for motor drive system with arduino.

Answered by Damien on December 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP