Need ideas to provide pulsetrain to spin stepper motor

Go To Last Post
62 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a NEMA 34 stepper motor and Compumotor ZETA4 driver. I want to provide a pulsetrain to use the stepper motor in a more conventional application.

 

I have tested the motor/driver setup with a Compumotor 2100 controller that provides accel/decel ramps as well as constant continuous speed.

 

If necessary, I can use this controller for my application, but I would prefer to use a dedicated circuit.

 

My test setup proved I can get over 10,000 RPM from the motor/driver setup and that requires a pulse rate of 333,333 Hz. I will limit the speed to 7,200 RPM which translates to 240 kHz.

 

I am assuming this is too fast to generate with an AVR micro. An idea I have is to use a VCO to generate the pulses and a micro to ramp up/down the voltage of the VCO. I am open to any and all ideas....

 

My application is a small CNC lathe controlled with Arduino based grbl CNC controller. For normal turning, a simple motor is all that is required. But to cut threads, the spindle needs to be synchronized with the other axes. So for normal turning I want to use the above mentioned circuit, and then to cut threads, the motor will be controlled with grbl. Since the lathe is small, the max speed I plan to be 4000 RPM. It will be geared 1.8:1 so the motor speed is 7200 RPM. With 10 microsteps per full step and 200 full steps the step frequency is 240 kHz.

 

Any suggestions?

 

Cris

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A big question is what the allowable granularity is for speed? THAT really sets your required clock rate, instead of the simple pulse rate.

 

For example, suppose that your CPU clock rate is 16MHz. That gives you 66 clocks to go 242KHz. But, then going 68 clocks (assuming you want 50% duty cycle) gives you 235.3KHz. That period granularity remains constant so the percentage change in frequency drops dramatically as you slow it down.

 

Hmmm, just reread your post. Microsteps DO NOT require pulses like you propose, as far as I know. For microsteps, you gradually turn one phase on while turning the one, behind, slowly off, at the same rate. So, really, you only need the 200 pulses per revolution. If you are going to microstep, you are far better off using one of the stepper motor control ICs with a transistor for each winding phase. So, for 7200 RPM (120 Rev/second), you only need 200*120 pulses per second or 24K PPS. But those pulses have to be applied, complexly, to the windings.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Sat. Jul 21, 2018 - 01:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim,

 

The actual RPM can be quite coarse, but the bigger issue is the smoothness of the Accel/Decel ramp (which is probably what you are alluding to). Too large a frequency change can cause the stepper to loose sync with the pulse train and is worse at higher RPM, since there is less surplus torque available.

 

This is why I'm thinking of using a Voltage Controlled Oscillator to provide the pulse train. The voltage to set the frequency can be provided by a micro's PWM. This will have analog filtering that will help keep the accel/decel ramps smooth.

 

Cris

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Edited first post while you were posting. Review 3rd paragraph.

 

Jim

 

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

    What microcontroller are we talking about ?

 

    1. AT90PWM216/316 have timers running at 64MHz. I think there is a tiny one also with this feature.

    2. XMEGA can run timers at double the CPU clock with PLL

    3. Use fractional periods (called also dithering). This complicates the firmware, but I suppose your micro does not have much else to do. Lets say you run in CTC mode with OCRA = 68 and want to slightly increase the speed. Then you change OCRA to 67 every 10-th period. Then you will have something like 68 68 68 68 67 68 68 68 68 67 and then more 67s and less 68s until eventually all of them will be 67s.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
Edited first post while you were posting. Review 3rd paragraph.

Jim,

The stepper driver handles the microsteps and knows when to advance to the next microstep because it got a pulse. So after 10 pulses (in this case), the driver has incremented a full step.

 

angelu wrote:
What microcontroller are we talking about ?

I am most comfortable with ATmega and ATtinys. It'd be nice to use what I already have on hand (ATmega328, ATtiny261 and other 20mHz micros). Thanks for the dithering suggestion.

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The AT90PWM216/316, of all the standard Mega-like devices, will give you the PWM with the highest resolution (smallest delta-T between two counts). 

 

There are XMega that are faster, but, in spite of having "Mega" in the name, have some very substantial differences that make the learning curve relatively steep.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After reading the datasheet, it appears that the AT90PWM216/316 uses an internal PLL and internal 1mHz clock to get up to 64mHz PWM freq. This touched a memory in the back of my mind, so I looked at my ATtiny26 datasheet and found the same option. Since the ATtiny26 is obsolete (but I have dozens) I'll bet a large number of AVRs also have this option.

 

At first glance, I do not see that the AT90PWM has an advantage over the ATtiny26 in regard to PWM freq. They both use 16 bit timers and both can be 64mHz. So far the ATtiny seems to have the advantage with its 20mHz crystal vs. 16mHz with the AT90. Thank you to angelu and Jim for leading me down this path. I'll be studying datasheets to see if I can get what I'm after....

 

I wonder if there is enough bandwidth for 0 to 240kHz with a smooth accel/decel ramp. I don't do a lot of programming so it takes me a while to figure things out, but it looks questionable at first glance. The VCO idea mentioned above, still looks attractive....

 

Cris

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

Last Edited: Sat. Jul 21, 2018 - 06:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVR446 is your friend.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

2000 steps/s equals 60rpm. Do a spreadsheet of the integer divisors vs freq vs rpm. You could calc the acceleration to see if the motor will cope. Or just break out the Arduino and write a simple program to set a 16 bit timer up in CTC mode with output toggle.

Note that mhz is milli Hertz. You mean M for mega. If I asked you for a bolt that was 1 micron long, you’d most likely question me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

aeroHAWK wrote:

I wonder if there is enough bandwidth for 0 to 240kHz with a smooth accel/decel ramp. I don't do a lot of programming so it takes me a while to figure things out, but it looks questionable at first glance. The VCO idea mentioned above, still looks attractive....

The AVRs have trim-able oscillators, so you could look at that as a 'digital vco', but the step size is a reasonable portion of 1%

 

Or, you could use a ATtiny with DAC, and use a classic HC4046 VCO, or the better 74HCT9046, to get better frequency  - or, a DDS chip with a higher clock source, can allow you to define an Adder-based average clock out  (eg AD9837B)

- with that you still get some creepage of requested frequency, due to rounding errors in dividers

A problem with OSC vary, is that serial links like UARTS do not tolerate that well. i2c is more tolerant.

aeroHAWK wrote:
But to cut threads, the spindle needs to be synchronized with the other axes.
 

 

That detail sounds like it needs real care, as I can see tracking all these becomes a nightmare...

 

You may be better to jump to a more specialised chip like the Parallax P8X32, which you can treat as a 12 or even 16 channel 32bit NCO(DDS without sine), from a 80~100MHz sysclk.

Or, you can configure the 16 x 32b Counters as half NCO, and half checking-counters. - ie after every move, you can confirm all axes did move as many counts as you expected.

 

 

 With that, your 240k is defined as 80M/333.3333', and will automatically be created as /333, /333, /334, /333, /333, /334, to average that 333.333'

 

The real appeal here, is now all those tracking axes, can use the same  master clock, and each has a very precise average divider ratio, and you can even result-check them with any spare 32b counters.

The ratio of those dividers, gives your movement angle.

 

example calc is  2^32/(80M/240k) = 12884901.888  Adder is = 0x00C49BA5, and edge jitter is a low 12.5ns - you can see the sort of step-rate precision you can work with.

 

 

Last Edited: Sat. Jul 21, 2018 - 09:45 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Screwcutting requires a fixed relationship between the headstock and the leadscrew speeds. If you drove both motors from the same uC then they would both be from the same clock and would therefore be digitally locked together.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:
AVR446 is your friend.

Thanks Brian, great info!

 

Kartman wrote:
You could calc the acceleration to see if the motor will cope. Or just break out the Arduino and write a simple program to set a 16 bit timer up in CTC mode with output toggle. Note that mhz is milli Hertz. You mean M for mega.

 

I have already conducted test with the actual motor and driver and have empirically found I can turn the motor at 10,400 before it looses sync. I don't remember the acceleration off the top of my head.

 

Thank you for the correction "m" vs. "M". I was not paying attention....

 

Who-me wrote:
Or, you could use a ATtiny with DAC, and use a classic HC4046 VCO, or the better 74HCT9046, to get better frequency

 

aeroHAWK wrote:

But to cut threads, the spindle needs to be synchronized with the other axes.

 That detail sounds like it needs real care, as I can see tracking all these becomes a nightmare...

 

Thanks for the suggestion. I hadn't thought of a DAC. The thread cutting is straightforward since it is all taken care of in an Arduino running grbl firmware.

 

So far, I am liking the DAC with VCO idea. Actually I discovered a voltage to frequency converter is more accurate (linear) than a VCO so just as I used a lower case "m" when I should have used an upper case "M", I should have said VFC instead of VCO.

 

I googled VFC and found circuits using an op amp and a 555 to make one. I have a bunch of them lying around and I may have some old DACs from a few decades ago. I'll look to see what I can come up with.

 

Cris

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

THANK YOU to everyone that posted !

 

My plan is to make an 8 bit R-2R resistor ladder for a DAC, buffer it with an Op Amp, feed the output to a Voltage to Frequency Converter (made from an op amp and a 555), and use the output of the VFC as the pulsetrain to the stepper driver. I have everything I need on hand.

 

The speed of the spindle motor is dictated by an analog voltage from the Arduino running grbl (it is a filtered PWM signal). This analog voltage is then fed to the ADC (8 bits) of another micro that will output 8 bits to the R-2R ladder. This second micro may be an ATtiny or ATmega, and will smoothly count up from zero to the ADC value to provide a consistent linear acceleration ramp to maintain sync with the stepper motor. It will also provide a smooth deceleration ramp.

 

When I want the spindle to be controlled by the Arduino running grbl (to cut threads), I'll use a 2 to 1 multiplexer to select the appropriate line to provide the pulses to the stepper driver. The mux can either be controlled by the Arduino running grbl, or by a switch operated manually.

 

Thanks again,

 

Cris

 

 

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

Last Edited: Mon. Jul 23, 2018 - 06:39 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is analogue accurate enough for thread cutting?

 

I thought 'real' lathes did thread cutting by gearing the lead screw from the headstock drive so that you had a very accurate relationship between the headstock rotation and leadscrew movement (ie thread pitch).

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

just remember that micro stepping is only really needed down at low speeds.

 

And remember that a stepping motor don't run 100% smooth with two sine waves 90 deg out of phase anyway. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

why not just cut out the middleman and use an op-amp as an integrator fed from the pwm? Building a r2r ladder from discrete resistors probably won't yield something that could be described as linear - unless you plan to laser trim your resistors. Building a DAC using pwm is much simpler and will yield better linearity than a home brew r2r.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

#17

PWM don't work well at that speed!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do you mean? I'm anticipating the ramp is reasonably slow, so the pwm is used as a DAC to control the VCO. 

 

The OP's proposal is pwm->filter->ADC->micro->8bit r2r dac->vco

 

vs

 

pwm->integrator->vco

Last Edited: Mon. Jul 23, 2018 - 11:45 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:
Is analogue accurate enough for thread cutting?

Thread cutting will be done digitally. Analog is for general turning.

sparrow2 wrote:
remember that a stepping motor don't run 100% smooth with two sine waves 90 deg out of phase

This is true for very old stepper motors, but not accurate with the newer motors.

Kartman wrote:
pwm->filter->ADC->micro->8bit r2r dac->vco

 

vs

 

pwm->integrator->vco

I need a way to slowly ramp up/down the step frequency. That is why I include the micro. As I write this, I am seeing some genius in your suggestion. I'll have to study integrators some more....

 

I may need:

 

PWM->filter->integrator->vco

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

Last Edited: Mon. Jul 23, 2018 - 03:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is true for very old stepper motors, but not accurate with the newer motors.

Then it's NOT a stepper motor but a PM motor.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:
Then it's NOT a stepper motor but a PM motor.

I used to design stepper motors and I have personally built dozens from scratch, all stepper motors are specialized brushless DC motors.

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
why not just cut out the middleman and use an op-amp as an integrator fed from the pwm?

I found various tutorials online about integrators and it looks like the output is a negative voltage. Would I then use another op amp to invert it to get a positive voltage?

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After further study, I've found info for a non-inverting integrator circuit:

 

http://www.electronics-tutorial....

 

https://www.globalspec.com/refer...

 

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

Last Edited: Mon. Jul 23, 2018 - 06:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is what I have now. I have some rail-to-rail op amps that I'll use along with a 555 timer.

 

The PWM output from the Arduino running grbl is fed through the integrator, and the output of the integrator then goes to the VFC.

 

 

 

The integrator should provide a smooth and consistent Accel/Decel ramp. I still have some studying to do because I want to change the FVC to 50KHz/V instead of 100KHz/V.

 

I like this solution as it is very simple. Thanks again!

 

Cris

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

Last Edited: Mon. Jul 23, 2018 - 07:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

aeroHAWK wrote:
The PWM output from the Arduino running grbl is fed through the integrator, and the output of the integrator then goes to the VFC.

 

Do you have any numbers on what grbl expects there, in terms of PWM Duty % mapping to what Motor Speed (Step rate) ?

How many channels can grbl on Ardunio output & what is the output PWM period/step size ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Who-me wrote:
Do you have any numbers on what grbl expects there, in terms of PWM Duty % mapping to what Motor Speed (Step rate) ?

How many channels can grbl on Ardunio output & what is the output PWM period/step size ?

grbl outputs PWM from 0 to 100% duty cycle @ 5V. The motor speed depends upon the motor controller the PWM is sent to. It is a single channel and the default is 1000 Hz but can be changed when compiled.

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

10.000rpm, 7200rpm ???

Are those real rpm's for your nema34 stepper motor?

Are you going to use the stepper motor to drive the main shaft of a (small) lathe?

 

I'm having some doubts this will work satisfactory.

The available torque drops significantly if you drive a (norma) stepper motor over about 600rpm.

The motor might reach those speeds un loaded, but under load it is probably not going to be reliable.

 

What is the power supply voltage for your stepper motor?

Higher power supply voltages help a lot with gaining some torque at higher speeds.

 

Also consider some mechanical transmission.

Lathe's are often run at low rpm, but high torque, and if you gear the rpm of the motor down you'll get a lot more torque at low speed.

 

Also:

grbl has been ported to STM32F103

This ARM processsor runs @72 MHz, so if you want to program a timer to generate a 240kHz output frequency you still have 300 clock cycles to play with for accelleration / decelleration. Should be enough for smooth operation.

 

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
10.000rpm, 7200rpm ???

Are those real rpm's for your nema34 stepper motor?

Are you going to use the stepper motor to drive the main shaft of a (small) lathe?

Paul,

 

I'm a little surprised it took this long for someone to question this.... You are smart to have your doubts - as I did also.

 

Yes, they are REAL speeds that I achieved and measured before I decided to go this route. I was initially planning to use two separate motors -  a DC motor and speed control for normal turning and the stepper for threading. I planned to mechanically engage the appropriate motor with a lever or something.

 

Compumotor ZETA4 drivers have two damping regimes and operate from rectified and filtered AC line voltage (120 V). Typically, stepper motors work much better with a load because the load provide some damping. This driver's damping makes it work quite well with no load. I was quite amazed I could get 10,500 RPM before it lost sync. The rectified and filtered line voltage means that about 170 volts is available to the driver. All this makes this specific combination of parts somewhat unique. I seriously doubt this can be accomplished with any other available hardware.

 

I have a CNC machine shop and am highly skilled with machine tools. I have built a number of custom CNC machines (I am currently finishing a 6 axis custom machine for second ops on microwave circuits using two micros running grbl and a third micro to coordinate them). Also, in the early 1980s, I was the entire mechanical engineering department at Compumotor for its first two years of existence. As mentioned above I have designed and built dozens of stepper motors from scratch.

 

You may be right that this setup won't work. When I finish the spindle, it may take too much torque at the higher speeds. Since I was able to get 10,500 RPM (no load) and I am not planning to run more than 7,200 RPM, I am hopeful that I'll have sufficient torque for the task. The spindle will be geared down 1.8:1, so this will also help with torque. The lathe I am building will use 5C collets (1 1/16" max diameter), or an 80mm chuck (3 1/8" diameter). Torque requirements are small.

 

I have several Smoothieboard clones and I know that grbl runs on these boards. I have been in communication with someone that measured its max frequency and that it can provide pulses in excess of 200KHz. Thanks for reminding me of this option. I do have a concern that the Accel/Decel ramp my not be as smooth as it could be (I don't have any reason to be suspicious, but I don't know it is smooth, either).

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

aeroHAWK wrote:

PWM->filter->integrator->vco

 

    Your voltage to frequency converter already has an integrator. The separate integrator you show is not going to do anything. Usually an integrator is combined with other kind of feedback otherwise it will integrate until reach one of the minimum or maximum limit.

 

    Put it this way, if you put 1V at the input, the output will slowly go up to the positive rail and stays there. It is not what you want.

 

    What you need in front of the VF converter is an RC filter and an OP-AMP repeater, so I would use that MCP6231 from the "integrator" for that. You can increase C2 to make it smother as needed or play with the RC constant of the input filter from PWM (now R5C6).

 

    In order to lower the output frequency you can double R5 near NE555.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

angelu wrote:
Your voltage to frequency converter already has an integrator. The separate integrator you show is not going to do anything.

Thank you for your comments. First let me say that I am a mechanical engineer and I know just enough electronics to be dangerous. I have discovered that I can do a decent job designing digital circuits, but analog circuits are definitely above my pay grade. I researched online to get what I have shown.

 

It is my understanding that the integrator with the VFC is intended to make sure the cap on the 555 is charged linearly. This is supposed to make the correlation between input voltage and output frequency linear. Without the integrator the relationship is exponential.

 

The integrator I added ahead of that, is intended to make any change in the input to the VFC be slow and linear. The RC time constants for the two integrators are very different.

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

aeroHAWK wrote:
I have several Smoothieboard clones and I know that grbl runs on these boards. I have been in communication with someone that measured its max frequency and that it can provide pulses in excess of 200KHz. Thanks for reminding me of this option. I do have a concern that the Accel/Decel ramp my not be as smooth as it could be (I don't have any reason to be suspicious, but I don't know it is smooth, either).

 

That will also come down to the PWM Step size. If the PWM output rate is 1kHz, maybe the AVR can do 100% in 16M/1k = 16,000 steps ? - or maybe it uses 8 bits & prescaler for speed ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With what I read from your background you should know what your're doing...

 

I have also toyed a bit with CNC.

One of my goals is to use a Beaglebone Black with Machinekit (a fork from LinuxCNC).

Maximum step rate seems to be around 30kHz, which was an unpleasant surprize.

This is usually enough, but I am aiming for at least 1/8 uStepping to bring the noise down, and then I'm running out of headroom.

 

The PRU's (programmable realtime unit's) in the Beaglebone black are capable of much more, but unfortunately someone decided that optimisation for high steprate was not a priority.

On another project (github?) I read that the Beaglebone's PRU can generatate reliable step rates of > 1MHz.

 

Putting 120Vac into a stepper motor driver is not very exceptional, but it should be enough for decent performance.

A lot of the bigger stepper motor drivers can also run directly on 230Vac mains (default in the Netherlands)

For example the Leadshine DH-2306

https://www.damencnc.com/assortiment/cnc-besturingen/leadshine-closed-loop/drivers/high-voltage-closed-loop-stepper-drive-es-dh2306-230vac-6-0a-3phase/_404_w_123_923_NL_1

 

The closed loop steppers seem to be the way to go. They generate "micro steps" internally, and run a lot smoother, and generate feedback errors under overload.

 

Just curious:

Do you have any experience with 3-phase stepper motors?

Do they run smoother or have less torque rolloff at high RPM?

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
One of my goals is to use a Beaglebone Black with Machinekit (a fork from LinuxCNC).

I looked at this too. I found that there was not enough support or hardware available. RPi has much more.... Although it's apples and oranges.

Paulvdh wrote:
Maximum step rate seems to be around 30kHz, which was an unpleasant surprize.

Yes, that is disappointing.

Paulvdh wrote:
Putting 120Vac into a stepper motor driver is not very exceptional

It is rare in hobby CNC. Yes, industrial steppers are different. I am intrigued with the closed loop steppers. There seem to be many examples that sense position without an encoder. I am leery of them but I don't know enough about them. I have looked at Smart Stepper and have been impressed. It uses an encoder.

Paulvdh wrote:
Just curious:

Do you have any experience with 3-phase stepper motors?

Do they run smoother or have less torque rolloff at high RPM?

The motors I designed and built in the early 1980s were 3-phase. There is little potential difference with the number of phases. The biggest issue is with the number of bridges needed for the driver, and it can affect the cost of the electronics.

 

Smoothness is not a function of the number of phases, but is affected by other aspects of the motor geometry. Torque rolloff has to do with inductance and voltage....

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

Last Edited: Wed. Jul 25, 2018 - 12:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A NEMA34 motor (expecially the longer one's) could very well be enough for a small lathe.

Another way would be to any motor which is can be (somewhat) speed regulated, measure velosity of the motor, and slave the other motors to the speed of the main spindle for things such as threading.

aeroHAWK wrote:

I looked at this too. I found that there was not enough support or hardware available.

As hardware I have the BBB, a few old 74LS244 chips to buffer the outputs and commercial stepper motor drivers (Wantai DQ542MA) (115mm NEMA23)

These stepper drivers have a quite big CPU for just translating steps to motor phases. It's an MC56F8013.

 

aeroHAWK wrote:
RPi has much more.... Although it's apples and oranges.

Not really. The PRU's in the BBB are quite exceptional. These can generate steps with >1MHz reliable (according to that other CNC project on github).

 

aeroHAWK wrote:
Paulvdh wrote:
Putting 120Vac into a stepper motor driver is not very exceptional

It is rare in hobby CNC. Yes, industrial steppers are different.

It is not really hobby / industrial, but small / big stepper motors. It is just that not many hobbyists use NEMA34 or bigger motors.

Do you use insulation transformes with these motor drive's?

 

aeroHAWK wrote:
I am intrigued with the closed loop steppers. There seem to be many examples that sense position without an encoder. I am leery of them but I don't know enough about them. I have looked at Smart Stepper and have been impressed. It uses an encoder.

Trinamic has been a bit innovative with their stepper motor drivers.

For example the TMC246 uses "stall guard", sensor less feedback to detect stalls.

https://www.trinamic.com/products/integrated-circuits/details/tmc246b-pa/

Trinamic also has other interesting AN's.

I just bumped into:

https://www.trinamic.com/solutions/white-papers/reducing-timer-interrupt-load/

The idea is to program an TMC5130A-TA with ramp parameters and let it generate the steps itself with very little uC intervention.

Another Idea of Trinamic is to use a step multiplier in the motor driver. This makes the Trinamic chips run smooth and quiet even at low microstepping settings.

Without motion feedback there is not much use in microstepping, except to make the motor run smoother, and that is exactly what Trinamic has done.

 

If you want to design a motor driver yourself, start with FOC (Field oriented controll) as used with BLDC motors. Stepper motors are very much like 50 pole BLDC motors.

The goal is to keep a 90 degree phase shift between the rotor position and the field generated by the electromagnets. (Optimisation of the torque generated by the input current).

For a stepper motor this means that the motor position is always a full step behind the stator field.

A lot of uC manufacturers have AN's about FOC. Ti has a few very nice youtube seminairs.

 

About Feedback:

Optical encoders are increasigly being exchanged by magnetic encoders. Just slap a 50ct Neodibium magnet on the end of the stepper axle and measure the position (up to 14 bit) with an EUR 5 IC.

An example of such a project is "HighPower-Mechaduino", which uses an AS5047D for position sensing.

There are also small ARM based stepper controllers with this feedback.

VESC is also worth noting.

http://misfittech.net/smart-steppers/ uses an ATSAMD21

The easiest way to experiment with steppers with feedback is to buy complete sets on Ali / Ebay / China.

Price difference for A set of Motor + controller and with / without feedback is about USD 30 for NEMA23, and a bit (but not much) more for NEMA34.

I do not have much experience with them. I have some NEMA23's (-115mm length) without feedback and 2 NEMA 34's ( 12Nm, 150mm long without encoder) with feedback and my initial opinion is that the motors with feedback run a lot smoother. I also like the alarm output. The motor controller generates an error if the motor can not follow the steps. That alone is worth the price difference.

 

But you have to ask yourself: Do I want to design a motor controller, or do I want to build a CNC machine?

 

aeroHAWK wrote:
The motors I designed and built in the early 1980s were 3-phase. There is little potential difference with the number of phases. The biggest issue is with the number of bridges needed for the driver, and it can affect the cost of the electronics.

 

Smoothness is not a function of the number of phases, but is affected by other aspects of the motor geometry. Torque rolloff has to do with inductance and voltage....

 

Sometimes I'm dreaming of developing my own motor controller (not motor).

Components would be an STM32F103 (which has 3-phase motor controller timer) BTS7960 Half bride drivers (with current measurement feedback) and one of the Hall angle sensor feedback IC's.

A 2 phase motor would need 4 half bridges, while a 3-phase motor only needs 3. 2-phase stepper motors seem to be a bit cheaper and more common than 3-phase motors.

I might put 4 of the BTS7960 chips on it and make the 2 vs 3 phase a software option.

 

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

Last Edited: Wed. Jul 25, 2018 - 02:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paul,

 

I enjoy having these conversations. Keep in mind the title of this thread is “Need ideas to provide pulsetrain to spin stepper motor”. We are getting away from that.

 

Since I am not very experienced with analog circuitry, I'm more interested in comments about the schematic I posted above. Angelu made some comments that I responded to and am interested in learning more about voltage to frequency converters and integrators.

 

For example, when using a 555 timer, there are many R and C values one can use. The RC time constant is the same for 100K x .01uF and 10K x .1uF, but the impedance is different. What effect does the impedance have on the circuit?

 

Cris

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For the monostable mode of the 555 timer, it relies on the time constant of the R and C. Why would you be concerned about the impedance of this? What you might want to consider is the input impedance of the 555 as this loads the RC circuit. There are limitations as to how small the capacitor is due to stray capacitance and also how large the resistance is due to leakage current of the 555.
You can answer your question empirically by building the circuit and changing the values.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

555?

I grew up with the 555 and analog circuits.

 

I then I learned about microcontrollers.

 

These days I would grab an Xmega32E5 and read the analog input voltage with the ADC and output the pulse stream as required.

 

That chip runs at 32 MHz in spec, and is otherwise probably overkill for this project.

 

DO get out your O'scope and play with the analog approach as in the schematic above, I think you will find it is very finicky to work with.

The micro makes it trivial and reproducible.

 

Just my 2 cents.

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
These days I would grab an Xmega32E5 and read the analog input voltage with the ADC and output the pulse stream as required.

 

Usually that's the best advice, but here the OP needs smooth frequency output, at high rates.  Small MCUs are rather granular at high rates. **

You could trim the OSC, to reduce granularity, but that's less calibrated.

 

aeroHAWK wrote:
Since I am not very experienced with analog circuitry, I'm more interested in comments about the schematic I posted above. Angelu made some comments that I responded to and am interested in learning more about voltage to frequency converters and integrators.

 

Good idea, his advice is accurate.

aeroHAWK wrote:
The integrator I added ahead of that, is intended to make any change in the input to the VFC be slow and linear. The RC time constants for the two integrators are very different.

Not quite. The first stage is needed to convert the PWM signal, into a clean Analog value, which the VFC needs.

Angelu is right, a true integrator is not the correct element to use here, you need a low pass filter, probably a 2 stage one.   You can make that with the same RC+RC you have now, just a slight rewire to change the Opamp to a second order Low pass.

 

 

** My advice for a MCU here, would be one that can capture the PWM directly (in the time domain, no Analog step needed), and that includes a NCO for frequency out.

The P8X32 can do that, with a 80MHz clock, it can capture 1Khz PWM to one part in 80,000 (> 16 bits) and it can generate NCO output 

- some 32b NCO examples, for P8X32 

 80M*round(2^32/(80M/333k))/2^32      = 332999.99

 80M*round(1+2^32/(80M/333k))/2^32  = 333000.01

 80M*round(1+2^32/(80M/3k))/2^32 = 3000.0135

 80M*round(2^32/(80M/3k))/2^32     = 2999.9949

that 32b precision may be an overkill here.

 

Microchip has NCO in some PICs, but I think not yet in AVR's

http://www.microchip.com/design-...

https://www.microchip.com/ParamC...

 

Maybe the PIC16F15313 can be good enough ?

Last Edited: Thu. Jul 26, 2018 - 01:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So please bare with me here.... I don't get it - I'm not saying anybody is wrong, I just don't understand.

Kartman wrote:
why not just cut out the middleman and use an op-amp as an integrator fed from the pwm?

Kartman wrote:
pwm->integrator->vco

If I have a Voltage to Frequency Converter, and input 1 volt, I get 50KHz output. 2 volts = 100KHz.... 5 volts = 250KHz.

 

Then I take a circuit that will take an instantaneous 5V change in voltage and slow it down (linearly) to 1 volt / second, and feed it to the VFC; after the first second, the output will be 50KHz... 5 seconds 250KHz?

 

Isn't that what Kartman is suggesting above?

 

I posted a circuit for a VFC and a circuit for an integrator. Are those circuits incorrect? Are they indeed circuits for a VFC and integrator?

 

If they are what I think they are... what am I missing?

 

Isn't an integrator a low pass filter? (My googling suggests that it is)

 

Cris

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

Last Edited: Thu. Jul 26, 2018 - 07:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

These are simple circuits you can build on a breadboard - you can perform your experiments and come to a better understanding. Otherwise you'll keep going around in circles here.

An integrator is a form of low pass filter, but they are not equal. Feed a sinewave into an integrator and you'll get a triangle wave. Feed a sinewave into a lowpass filter and you'd expect to get a sinewave out - maybe attenuated depending on the corner freq. Then we could talk about phase response and get really technical.

 

Build one building block at a time and you'll quickly come to understand what works for you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

aeroHAWK wrote:

I posted a circuit for a VFC and a circuit for an integrator. Are those circuits incorrect? Are they indeed circuits for a VFC and integrator?

 

If they are what I think they are... what am I missing?

 

Isn't an integrator a low pass filter? (My googling suggests that it is)

An integrator is not quite the same as a low pass filter.

Left all day, a low pass filter has an output equal to the input. Left all day, a real integrator output is one of the supply rails.

That detail matters, as you want to preserve DC-average of the PWM, and not have it creep.

 

Have a play here 

http://www.analog.com/designtool...

You should be able to get a Low pass design, in 2R and 2C + opamp.

The PWM rate is 1kHz but you can set the filter cut-off lower than that, ie more related to how fast you expect speed to actually change.

100Hz corner will be in the ballpark of 10ms, 10Hz is ballpark 100ms etc.

The AVR should have some slew-limits, but you might like to add some more here.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Feed a sinewave into an integrator and you'll get a triangle wave.

? You may have meant square wave ?

The integral of a Sine is a Cosine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

It’s been many years since i’ve played with 555’s and opamps!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
These are simple circuits you can build on a breadboard - you can perform your experiments and come to a better understanding. Otherwise you'll keep going around in circles here.

You have suggested this a couple times now. I will heed your advise....

Who-me wrote:
Left all day, a low pass filter has an output equal to the input. Left all day, a real integrator output is one of the supply rails.

That detail matters, as you want to preserve DC-average of the PWM, and not have it creep.

This is good to know. It is also a good argument for a digital (micro) solution.

Who-me wrote:
My advice for a MCU here, would be one that can capture the PWM directly (in the time domain, no Analog step needed)

If I go with a micro, this sounds like a good idea.

 

Cris

 

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For anybody interested in how an integrator works, they are actually quite simple - only three parts!  Here is a crude sketch (apologies in advance).

 

Integrator Circuit Schematic

 

In drawing #1 you just have a voltage across a resistor, so the current goes through it to ground.  The voltage at point A is zero.

 

An op-amp can be thought of as a very simple device whose only goal is to make sure the voltage at it's two inputs is identical and will do whatever is necessary to achieve this.  It does this by adjusting the voltage on its output to whatever is necessary and can source or sink current as needed.

 

So in circuit #2, we just put an op-amp in the path to ground as shown.  Since V+ is connected directly to ground, the op-amp will now do whatever is necessary to make sure V- is also at ground.  You now have a virtual ground at point A.

 

One more thing about op-amps -- no current flows in or out of the input pins, so now you have to do something with the current flowing through the resistor.

 

If you just tie point A to the op-amp output (circuit #3), it will set it's output voltage to 0V and sink all the current.

 

To make an integrator out of this, simply put a capacitor in the path between point A and the op-amp output pin as shown in circuit #4.

 

With a constant current flowing into the capacitor, the voltage across it increases linearly.  So what does the op-amp have to do? it has to sink the current as before, but also compensate for the voltage developing across the capacitor.  Thus Vout must be exactly the negative of the capacitor voltage.  Depending on what is attached to the integrator's output, some current may flow into it or out of it, but it doesn't matter because the op-amp will adjust its own current flow.

 

With a digital input, each positive pulse causes the integrator to ramp down its voltage for the duration of the pulse and then it remains steady until the next pulse.

 

A "real" circuit will place a large resistor across the capacitor (Rc >> R) so that the voltage has a way to bleed off slowly.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm still having doubts about your general setup.

Unless you have a very special combination of stepper motor and driver, I doubht you will have much usable torque above 2000rpm.

Do you have the datasheet of your stepper motor?

 

Also, an AVR timer can easily generate a steady frequency of 10MHz, and @ 250kHz you have some granularity for speed control.

When using this thing for synchronized operations such as threading, then those will be run at much lower RPM's and a 16-bit timer should be sufficient.

I do not see an added value in a VCO or other intermediate analog electronics.

 

Also, just to be clear:

If I understand well, you use the NEMA34 for the main spindle of a small CNC lathe, and you want to use a separate circuit to generate the step timing.

Then you have another uC which runs GRBL, and you somehow syncronize the GRBL uC with the main spindle for threading.

Correct?

 

aeroHAWK wrote:
the spindle needs to be synchronized with the other axes.

Ah, now I see, you want to do it the other way around.

GRBL is controlling the X and Y axis, and you want to synchronize the main spindle to that.

While threading, any drift or accumulation of error would be unacceptable.

So if there is some analog electronics in between you will need feedback and a PID loop.

It seems much simpler, to have GRBL generate synchronized steps for 3 axis for threading.

Then use another way (hardware timer, VCO, NE555, whatever) for high RPM of the motor.

 

Note:

Just today I read an article of a port of GRBL to ESP32 on Hackaday.

ESP32 is a dual core 300+ MHz uC which costs < EUR 10.

Apparently there are still some issues with timing.

https://hackaday.com/2018/07/26/grbl-ported-to-the-esp32/

 

Also:

This sounded just to common to not have been done before.

A quick search confirms this:

https://duckduckgo.com/html?q=grbl+lathe+threading

https://github.com/grbl/grbl/issues/602

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avr-mike wrote:
For anybody interested in how an integrator works, they are actually quite simple -

Thank you Mike. I appreciate your desire to forward my analog education. I will study.... (real busy right now)

Paulvdh wrote:
I'm still having doubts about your general setup.

I have been operating machine tools for almost 50 years (49). I have been designing and building stepper motor machines for almost 40 years (39). This has provided and/or confirmed I have excellent intuition about such matters. This does not guarantee I am always right, so your concerns are valid. To a certain degree, I share them. My preliminary tests are encouraging so I am moving forward to see what will happen. If it doesn't work as I hope... oh well.... but I am going to give it a shot. Nothing will be accomplished if one is afraid to fail....

Paulvdh wrote:
Also, just to be clear:

If I understand well, you use the NEMA34 for the main spindle of a small CNC lathe, and you want to use a separate circuit to generate the step timing.

Then you have another uC which runs GRBL, and you somehow syncronize the GRBL uC with the main spindle for threading.

Correct?

Incorrect. GRBL will control all three axes for threading so it will automatically provide synchronization.

Paulvdh wrote:
It seems much simpler, to have GRBL generate synchronized steps for 3 axis for threading.

Then use another way (hardware timer, VCO, NE555, whatever) for high RPM of the motor.

I agree, that's exactly why I am attempting to do it this way.

Paulvdh wrote:
This sounded just to common to not have been done before.

The fact that someone has done something similar is what got me started. I noticed somebody used two separate motors - a DC motor for turning, and a stepper for threading. I began a design to do the very same. But for some reason, I thought I'd test and actual motor to see what it could do. I was VERY surprised at its performance and decided to see if I could do it with only a stepper motor....

 

Paul, I don't really know your motivation here. You seem to be trying to tell me I'm doomed to fail. SO WHAT! I get that you are skeptical, so was I. But I have made some preliminary test with a REAL motor and a REAL driver and been completely surprised. I tried to tell you this earlier but you keep going. I suspect I am far more experienced with stepper motors, and therefore am familiar with their capabilities (as well as what makes them work or not work). I appreciate your desire to help, but I got your concerns earlier. What do you want me to be doing - what is your point?

 

Cris

 

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

Last Edited: Fri. Jul 27, 2018 - 06:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is me. I'm having trust issues.

I tend to trust data from datasheets more then unknown people.

 

I'm not trying to tell you you're doomed to fail.

I'd be happy if it works for you.

But as you also (should) know. A free running test is no good indication for available torque for a stepper motor.

So do some thourough tests to make sure it works good enough under load before you put in a lot of effort in making bracketes to mount your motor and shielding for your belts.

Experimenting is fun, but putting a lot of effort in to make it sturdy and look good and only then find out you don't have enough torque and have to change it all again is no fun.

 

I.... may well be wasting your time by pointing out the obvious...

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will also like to see :

Do you have the datasheet of your stepper motor?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paul,

 

First I want to be clear that, although my previous post may sound terse, I am not irritated nor angry. I am merely having a discussion to determine what your point is and understand your message.

Paulvdh wrote:
I.... may well be wasting your time by pointing out the obvious...

Yes, you are pointing out the obvious, but I don't characterize this as a waste of time. There are others reading this besides you and me. Although it is getting quite a bit off topic.

Paulvdh wrote:
So do some thourough tests to make sure it works good enough under load before you put in a lot of effort in making bracketes to mount your motor and shielding for your belts.

Doing thorough tests is also a lot of effort. I will build a CNC lathe, and the motor is a small part of the lathe itself. Making new motor mounts if needed is fairly trivial.

Paulvdh wrote:
I tend to trust data from datasheets more then unknown people.

My first post gives enough info for Google to get you a datasheet (the motor is an M83-93).

 

How about looking at comparisons. Grizzly Industrial sells a Mini-Lathe that is comparable in may ways. I have a motor and controller from one of them. I had originally planned to use it for this lathe. This is the spec sheet for the Grizzly Mini-Lathe:

http://cdn1.grizzly.com/specshee...

 

The Grizzly lathe's motor driver is 250 watts. The Compumotor ZETA4 stepper motor driver can deliver 4 amps at 170 volts. 680 watts. This is an oversimplification and in may ways is apples and oranges. But in many ways it is a valid comparison. It helps understand the power requirement for the task.

 

I have very high confidence that I can build a lathe that will work just fine. It may not get to 4,000 RPM, but my toolroom lathe only turns 2,000 RPM and I've been satisfied with it for 35 years.

 

Cris

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

Last Edited: Fri. Jul 27, 2018 - 04:31 PM

Pages