CNC Replace stepper motors with DC motors with encoder

hello,

I am looking for a software solution or interface to transform the two phases planned for a stepper motor to a DC motor with encoder feedback. The encoder feedback would serve to calibrate the DC motor to the number of steps originally intended for the PAP motor.

Some industrial CNC have this connection option in PAP or DC motor with encoder.

These is no simple replacement for driving not-a-stepper motors with encoders with stepper software. You have a major undertaking ahead of you.

I know, but i think it's possible.. perhaps...

What do you think of this:

  • increment a counter with pulses coming from GRBL
  • the evolution of the counter value advances the setpoint of the motor 0 / 10Volts
  • the corresponding analog output of the ArduinoMega is regulated by a PID (examples on the Net)
  • the direction of rotation is derived from the second setpoint sent to the stepper motor by Grbl ?

Thanks of your help.

Its not that major to get something working. You need two ISRs, one for reading the quadrature from
the encoder - I'd recommend using pin change interrupts for that as you can have one handler triggered
from a change of either A or B inputs. That ISR maintains the actual position variable

A single normal interrupt channel can count the step pulses from GRBL (as well as the direction)
and set the set-point variable.

The in loop() you run a PID to take the difference of the two values and derivce a control output
(direction and magnitude) for the motor controller.

Due to the speed of pulses it is probably worth using direct port manipulation in the ISRs so
each runs in a dozen microseconds or less.

Hi,
thank you very much for your quick response.

I am reassured about the feasibility of my project.
I took as base the Grbl of Denvi / candle in v1.0.9.
Perhaps you know a better software?
I now have to perform an opto coupling to the "interrupt" inputs of my second Arduino to pick up the PAP pulses and enter them in a comparator to prepare the PID + - 10 Volts set point.
Have a good day.

What +/- 10V? Is this some external motor with analog bipolar control input?

MarkT:
What +/- 10V? Is this some external motor with analog bipolar control input?

Yes, it's for commanding from -10 V to +10 V the variator speed input of DC motor with coder.

Look up "Servostrap" or "Repstrap" for examples of how it can be done.

Thank you very much for your keywords; A quantity of ideas.
:slight_smile: I look at it all.

MarkT:
What +/- 10V? Is this some external motor with analog bipolar control input?

In fact, I think using an H bridge to operate the motor of each axis. So I do not need to create a + - 10 Volts setpoint.

The project is as follows:

  • a Uno for processing G-Code to Grbl.
  • the PWM-Uno will send its pulses to an Arduino-Mega interrupt input.

The PWM of each of the 3 axes will be created by the Mega and the Grbl by a Uno.

A second possibility:
Do you think it would be possible to add the Grbl processing in the Mega without risk of calculation error?
In this case, I would have only one Arduino.

The problem of recovering the Grbl / PWM for the PID addition would then arise ...

Do you think it would be possible to add the Grbl processing in the Mega without risk of calculation error?
In this case, I would have only one Arduino.

No, I think you'll run out of CPU time handling interrupts for several fast quadrature encoders. Besides the
Mega only has pin change interrupts on a small subset of its pins, whereas the Uno has them on every pin.

Consider a Pro Mini(*) per motor/motor-driver, then once you have some sort of working code your entire
system is going to starting doing something - trying to hack GRBL to handle loads of interrupts and
PID loops just sounds like something that will present many difficult issues. Keep the same modularity
as already works for steppers - you can then even drive steppers and servomotors together.

(*) small, cheap, convenient.

OK for the mini pro. I do not know this model.
I will try to adapt Grbl for a stepper motor at first.

The biggest challenge for me will be finding the PID lines of the Grbl.
Thank you for your help

Just to be clear, Grbl's job is to convert text-based gcode into step/direction pulses to stepper drivers. Servostrap/Repstrap's job is to take step/direction pulses from grbl to control the position of a DC motor. To do what you're asking to do there's no need to modify the code of either firmware.

Each piece of firmware is written to be extremely efficient since the respective tasks are incredibly time-sensitive. Like MarkT said, you can't hope to combine both Grbl's and Servostrap's job onto a single microcontroller.

Chagrin:
Just to be clear, Grbl's job is to convert text-based gcode into step/direction pulses to stepper drivers. Servostrap/Repstrap's job is to take step/direction pulses from grbl to control the position of a DC motor. To do what you're asking to do there's no need to modify the code of either firmware.

Each piece of firmware is written to be extremely efficient since the respective tasks are incredibly time-sensitive. Like MarkT said, you can't hope to combine both Grbl's and Servostrap's job onto a single microcontroller.

I understand very well what you are saying, and I thank you for your information.
My project, a bit "crazy" may be to operate DC motors with encoder, replacing step motors; always on the basis of a Grbl (rather programmed for step by step seems it).
So I intend to work from the PWM output of a Uno that will provide the trajectory pulses to an input of a Mega.
The latter will drive by PID each of the 3 DC motors.

I have just come to see this link Servostrap:
...using-dc-motors-to-replace-steppers-on

Perhaps an early solution. I do not know if I can drive this project by Grbl.

Chagrin:
Look up "Servostrap" or "Repstrap" for examples of how it can be done.

Thanks to "Chagrin".