0
\$\begingroup\$

I'm building a circuit board to control a small homemade CNC machine for PCB prototyping. The board I built so far is able to control the 3 TMC stepper drivers using an ESP32 running Grbl_Esp32.

In addition to the motion system, I also want to control the speed of a small DC spindle motor. Using only parts I had on hand, I came up with the following circuit to do so using PWM:

motor driver schematic

J12 connects to the motor. Spindle is the 3.3V logic signal from the micro-controller that has its own power-supply. VMot comes from an external 24V DC supply. +12V is derived from VMot using a buck converter, and there's an additional 3.3V logic supply for the stepper drivers:

3.3V supply

The stepper drivers are connected as shown below. All the signals go directly to the ESP32.

enter image description here

The behaviour I observe when turning on the Spindle PWM signal is the motor oscillating over the period of a few seconds until it gets up to speed. It spins up to low RPM fairly quickly, then acceleration slows down for a moment, picks back up again, and that cycle repeats a few times until it's up to speed.

Does this seem like it'd be because the initial current when switching on the motor is too large and loads down the VMot supply too much? I've tried adding some large low-ESR capacitance across Q1, but that didn't seem to make much of a difference and had other undesirable side-effects.

I wouldn't really be bothered by the motor taking a bit longer to spool up and sounding slightly funny when doing so, but unfortunately turning the spindle on also has the side-effect of apparently resetting the stepper drivers, which I assume is because of one or both of their power supplies dropping too low.

Is the high current demand on startup the reason for this behaviour? How could I address this issue so that the stepper drivers no longer get reset? Ideally I'd want to do this in hardware rather than by slowly ramping up the PWM signal in software.

Edit: This is the trace of the PWM signal on the input of the op-amp on CH2 and the 24V supply on CH1:

oscilloscope trace

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Do you have access to any kind of oscilloscope? It will be a great help for troubleshooting this, by measuring the control and supply voltages over time to identify any issues related to them. \$\endgroup\$ Jul 27, 2021 at 17:05
  • \$\begingroup\$ What is the PWM frequency of the signal SPINDLE? \$\endgroup\$
    – Ocanath
    Jul 27, 2021 at 17:18
  • 1
    \$\begingroup\$ A scope readout of the spindle motor PWM output, with a probe of 24V/Vmot would greatly help in answering your question \$\endgroup\$
    – Ocanath
    Jul 27, 2021 at 17:21
  • \$\begingroup\$ @JakobHalskov thank you - I've added a picture of what I think you asked for. \$\endgroup\$ Jul 27, 2021 at 19:59
  • \$\begingroup\$ @Ocanath Thank you. The PWM frequency is 2kHz, though I think it shouldn't really matter as I've been testing with a 100% duty-cycle. I've also added a picture of the measurements you asked for. \$\endgroup\$ Jul 27, 2021 at 20:00

2 Answers 2

1
\$\begingroup\$

It appears to be a 24V spindle motor that draws about 1A running and 10A surge on startup with an adequate supply. Less than adequate creates havoc.

This start surge is typical for efficient DC motors.

One solution would be to prevent the current limit that jerks accelerating on startup with a separate power supply with shared grounds.

Another is to current limit the driver to 1A with hysteresis so as to create a Pulsed rising frequency startup. Since you have an Op Amp, this is possible adding a 0.1 Ohm current sense from source to ground , lowering your threshold logic signal by attenuation from 3.3 to below 0.1V on Vin-. Vin+ is ground referenced to pullup needs to sense current signal that we want to limit just above 0.1 V. Next choosing the right hysteresis will control the frequency of the overcurrent cutoff pulses. start with 10% and see if that causes aliasing noises going up to 10kRPM. If so, then an LC LPF can be used. An RF cap on the shunt R will reduce flyback noise.

For EMI issues, use shielded twisted pairs for all wires and don’t share DC current back to the supply.

\$\endgroup\$
5
  • \$\begingroup\$ Using a separate power supply just for the motor indeed solves the problem, and that's the workaround I've been using so far, but one of the motivations behind my question is to switch back to a more convenient single 24V 5A power supply. That's the power supply the machine came with and which was previously able to operate without the issue I'm describing when used with the original control PCB. Unfortunately there's no schematics available for that original PCB, and I haven't yet managed to reverse-engineer it enough to identify how it differs from my DIY solution in this regard. \$\endgroup\$ Jul 27, 2021 at 20:18
  • \$\begingroup\$ Would you be so kind as to add a schematic for your proposed current-sensing solution? \$\endgroup\$ Jul 27, 2021 at 20:18
  • \$\begingroup\$ I have switch from iPoke to Windows box to do that easier. \$\endgroup\$ Jul 27, 2021 at 20:20
  • \$\begingroup\$ Too much trouble with negative logic to insert current feedback , with hysteresis For ramp. How much can you add on? It wasn’t as simple with active low. I was hoping to use an inverter on input then add the stuff I suggested \$\endgroup\$ Jul 28, 2021 at 0:40
  • 1
    \$\begingroup\$ This is what it took to add on to your design without subtracting anything to make PWM soft start work. tinyurl.com/yepck6yk see what I mean? I used a 3 second on off spindle cycle just to repeat testing and 50 x slower than real time \$\endgroup\$ Jul 28, 2021 at 2:28
1
\$\begingroup\$

If you're dropping the voltage to the processor, one approach to prevent everything from re-setting is to place a diode between your 12v supply and C7, which might allow you to run through power supply dips.

For the start issue, there are two issues that often trip up motor start routines. First of all, the kinetic energy of a rotating mass is proportional to the square of the rotational speed. Do the math and you will find that the increase in energy to accelerate a motor from zero to 10% rated speed is not the same as that from 90 to 100% - in fact it takes 19 times as much energy. So a linear PWM ramp will give you exactly the symptom you are seeing as the torque load pulls more current - more torque is needed to accelerate to the next PWM point. You may need to alter the slope of PWM increase curve to allow more time between steps at higher speeds; try piecewise-linear.

The second issue is the PWM pulsewidth resolution itself. What is the difference in duty cycle at each incremental PWM step? This is equal to the percentage increase in speed. If this step is too large, the motor will have to "jump" to the next speed, with potentially the same problem as described above. If you can increase the motor speed a step at a time without stalling, you need only change your PWM increase curve. If not, you will have to increase your PWM resolution.

Good luck!

\$\endgroup\$
2
  • \$\begingroup\$ There's no PWM ramping involved currently (it's not a feature Grbl_Esp32 supports and I'd prefer to not spend my time implementing it if there's an easy-ish hardware solution). The input to the op-amp is effectively a step function. \$\endgroup\$ Jul 27, 2021 at 20:27
  • \$\begingroup\$ I like your idea of using a diode to work around the problem. It's also a relatively easy modification to make to my excising board. \$\endgroup\$ Jul 27, 2021 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.