How to configure for spindle motor - DC brushed servo w/encoder step/dir

More
24 Mar 2019 04:57 #129443 by Vinito
I have a decent brushed motor with 600ppr encoder on it which has so far been tested to be a nice potential replacement spindle motor for my little Taig toy mill. The stock motor was yer basic 1-phase motor, but of course PC control of spindle & rpm is sweet, so yeah, I'm going there.
Anyway, there isn't an option in the stepconf wizard for a step/dir spindle and I assume I'm gonna have to do some text editing to configure this to work.
Anybody feel like helping me figure this out? I'm sure I'm not the only one to do this, but I did search and only found one 8-year-old post about it, which was still pretty Greek to me.
I have a counterfeit Chinese Leadshine DCS810 brushed DC servo drive for this. I had my doubts about it but it does seem to be doing the business just fine on this motor via setting it up on an A-axis and testing it as such. Plenty smooth and plenty of torque. But of course the result is just a finite travel axis rather than a spindle so not quite the fit I require.
I did read that I need to change something to a velocity mode and I'm sure there's a few other things to edit & tweak. Basically I'm just shooting for sending M3 or M4 with an RPM command and have the thing spin as expected. I think the thing would be capable of handling rigid tapping and it would be fun to work on adding that someday, but for now if I could just get the control of the spindle on/off, direction and RPM that would be fantastic.

Any help is greatly appreciated. Thanks.

Please Log in or Create an account to join the conversation.

More
24 Mar 2019 07:35 #129445 by pl7i92
as you do not have a ATC
it is not to be used the encoder
also no need to use a Type of this Motor
better to go full VFD like ER16 1,1KW spindle motor
or ecen 2,2 if you go full metall work

Please Log in or Create an account to join the conversation.

More
24 Mar 2019 08:37 - 24 Mar 2019 09:01 #129454 by Vinito
No good (speaking from experience)
I built a nice machine a while back and put a regular 24Krpm 2.2KW on it with a nice TECO vector drive, and the torque drops off so drastically around 6K rpm that it's unusable for anything but high-speed engraving really. I want good torque at maybe 500 rpm to a few thousand for milling.
This DC motor spins with great torque just fine, AND I already own it - as opposed to having to buy a +$200 spindle/motor and $350 VFD, then have it not accomplish the requirements anyway. All I need to pull this off is a way to get step/direction signals out of LinuxCNC for spindle control. If I could do that I'm gold. I directly verified earlier tonight that I can get that exact correct type of signal signal to drive the motor, so the software can do it just fine. It was a beautiful thing. I just have to figure out a way to get that signal for spindle rather than an axis. Seems like it ought to be cake. I know it's not a no-brainer, but I would think it's doable. LinuxCNC is reportedly extremely capable and flexible so I would expect this to be possible.
Also, since it would be a servo, I might someday configure it to even do rigid tapping - the thing will spin with plenty of torque at extremely low RPM (I just tested this a couple hours ago). That would be wacky and cool to pull that off with this little toy mill, though it's not any kind of priority at the moment.
Last edit: 24 Mar 2019 09:01 by Vinito.

Please Log in or Create an account to join the conversation.

More
24 Mar 2019 09:55 #129461 by cmcnc

Please Log in or Create an account to join the conversation.

More
24 Mar 2019 10:50 #129463 by Vinito
Yeah I ran across that.
It probably would help a lot if I spoke German.

Please Log in or Create an account to join the conversation.

More
25 Mar 2019 08:21 - 25 Mar 2019 09:51 #129557 by Richard J Kinch

Anyway, there isn't an option in the stepconf wizard for a step/dir spindle and I assume I'm gonna have to do some text editing to configure this to work. Anybody feel like helping me figure this out?


I faced a very similar situation recently, having a AC servo motor with step/dir position control powering the spindle on my project for a CNC-upgraded lathe. I naively assumed that there was some simple LinuxCNC configuration matter to running a spindle as a continuous travel on an [angular] position-controlled rotary axis. The goal was to have one LinuxCNC configuration, and one G-code program, that could run the spindle at speed for turning, and also stop and position the spindle for live-axis milling (without changing configurations or requiring separate G-code programs).

There is a lapse of logic involved in implementing that concept. I'm not sure if the lapse is something I don't understand about the G-code model or LinuxCNC, or a non-feature LinuxCNC itself.

My investigation concluded that the axes in the G-code machine model (which is a horror of defective ideas itself), and hence in LinuxCNC, assume a finite range of motion, and any motion will be from one finite point to another. There's no way in this model to express the idea of "Dear machine, please move that way at such-and-such a speed, don't stop until you hear otherwise, and by the way let's move on to the next G-code block for now." This is why spindle motion {S,M3,M4,M5} and axis motion {G0,G1,...} are differing, orthogonal syntax in the G-code language. The axis and spindle motion concepts are different. Axis motion must have a start and stop that can be planned in deterministic time, not a mode that applies until otherwise changed, and axis motion commands proceed one at a time. Spindle action is a mode command that returns immediately and applies until changed directly (M5) or indirectly as a side effect (tool changing, for example).

In my project I abandoned the position-mode servo spindle, switched the spindle servo controller from position mode (step/dir input) to velocity mode (0-10VDC analog signal for 0-3000 rpm), and built a crude D/A converter circuit (one 12VDC CMOS gate + RC network) to get an analog voltage from the pwmgen output pulse train instead of stepgen. This works fine and shortcuts the process. The motor phase/index encoder signals feed into LinuxCNC HAL encoders, so all the surface-speed and axis coordination (threading) features work.

I haven't figured out if rotary positioning can work; I'm worried it can't since the spindle is logically controlled in velocity-mode and not an angular-position axis. You can readily coordinate with its instantaneous position, and command its angular velocity, but you can't command a stopping position. Having both capabilities in one configuration would seem to be prohibited by the position vs. velocity exclusive models in the G-code axis vs. spindle exclusive models (pick either model, but not both).

In my imagination there ought to be a complex HAL configuration that configures both position and velocity controls on a position-mode servo motor, with a mode switch that activates one to the exclusion of the other. I haven't worked on that. Issues like homing state make this a challenge to implement. Some wag will glibly announce that "you can do this in {Python,M-code remapping}", but that's not configuring LinuxCNC, it's writing your own CNC.

If you don't care about positioning the spindle, but just want to control velocity with a step/dir motor signal, then you can configure the HAL to convert the rotary speed value to a variable-frequency generator connected to motor step, and M3/M4 direction connected to motor dir. This is what stepgen ctrl_type = 'v', and stepgen.N.velocity−cmd are for.

Don't be confused by the stepgen documentation which says, "stepgen is used to control stepper motors". This should say, "motors with step signal control (step/dir or quadrature)", which can be stepper motors, but also just as validly and appropriately, servo motors with a servo controller that accepts step signals.
Last edit: 25 Mar 2019 09:51 by Richard J Kinch.

Please Log in or Create an account to join the conversation.

More
25 Mar 2019 11:08 - 25 Mar 2019 11:30 #129561 by Vinito
Holy cow, thanks for that reply.
If nothing else, I feel a bit better knowing my problem seems easier to overcome than yours. All I'm trying to do essentially is spin a motor at commanded RPM.

I think I've gathered a couple hints from what you've posted.
I got to thinking and my biggest problem seems to be that I'm so ignorant of this stuff that I don't know where to start. With that in mind I was thinking that maybe I ought to start with knowing what part of the hal "hears" M3, M4 and M5 commands and starts something going downstream. Then maybe I could work out what part of the hal generates then sends pulses to the appropriate two pins. Then maybe I can figure out what to put in between so it sorts it out right. I have a foggy idea now what some of that could be, but really I'm not certain of any part of it yet.
I grok the stepgen ctrl_type=v part, but there's enable, make-pulses, scaling (what the...), even step and dir, and others, then various parameters, all of which I can somewhat understand but I don't know which are actually required or necessary. I sure haven't had any luck so far - all I get is an error popup window on startup every single time. Could be missing structure, could be syntax... who knows? Not me yet.
Anyway, thanks for your reply. I'm a bit burned out but I'll come back to it a bit later and maybe start to make a bit of sense of it.
Last edit: 25 Mar 2019 11:30 by Vinito.

Please Log in or Create an account to join the conversation.

More
25 Mar 2019 17:04 - 25 Mar 2019 18:20 #129590 by Richard J Kinch

... but there's enable, make-pulses, scaling (what the...), even step and dir, and others, then various parameters, all of which I can somewhat understand but I don't know which are actually required or necessary.


It is indeed baffling.

To simplify the puzzling configuration: use stepconf to create a valid PWM spindle configuration, pretending your spindle motor has a PWM-signal velocity-control. Then hand-edit the configuration (.ini and .hal files) to modify the pwmgen to the stepgen that matches your hardware. This minimizes the amount of HAL schemas you have to invent.

You should also qualify your system's base-thread bandwidth available before investing in the approach. This is an upper bound on stepped spindle performance. For example, if your system were limited to, say, 12 kHz step rates and the motor is 600 steps/rev, then that's 12K/600 = 20 rev/sec = 1200 rpm max spindle speed. That's going to foil any 1800, 3000, or 3600 rpm imaginations you might dream from a given motor's native capacity. Motor speeds are a problem for small machine tools, which require using small diameter cutters, which require higher rpms to maintain SFM speed. In the end you can find yourself unhappily cornered into an unfavorable area of the performance envelope and crossing into infeasible areas. Then you'll regret the investment and learn the hard way that a 6000 rpm motor-spindle with sub-thou runout/rigidity is what a small machine needs as a basic element. These competing factors all must be orchestrated and harmonized from the concept stage, if you're inventing instead of following a proven configuration recipe.
Last edit: 25 Mar 2019 18:20 by Richard J Kinch.

Please Log in or Create an account to join the conversation.

More
25 Mar 2019 17:34 #129594 by rodw
This might be a bit crude but its possible to drive a stepper motor with a square wave. I've done this with some interrupt driven code on an Arduino. I Will say the motor gets a bit hotter than it does in LinuxCNC. So you might be able to do this with the siggen component.

But a custom component might be the order of the day. I'm sure I saw a post where Dewey Garrett pushed a change to support 16 axes but the extra axes require a seperate controller as they are outside of the kinematics paradigms. He suggested using limit3 to drive them. Good luck!

Please Log in or Create an account to join the conversation.

More
25 Mar 2019 18:34 - 25 Mar 2019 18:48 #129603 by Richard J Kinch

This might be a bit crude but its possible to drive a stepper motor with a square wave.


Right, but in the OP's case he's determined to use a brushed-DC servo controller with stepped signals, not a drive a stepper motor. So a HAL-generated single-phase square wave is all that is needed, with programmable frequency under HAL control, which is what HAL stepgen (in velocity mode) does. The OP is just asking for apocryphal HAL code to implement that. Some LinuxCNC scholar should just answer with a experience-proven example (I don't have one offhand, I gave up and resorted to PWM that stepconf comprehends) to this homework problem. It's not in the textus receptus or the forum midrash.
Last edit: 25 Mar 2019 18:48 by Richard J Kinch.

Please Log in or Create an account to join the conversation.

Time to create page: 0.260 seconds
Powered by Kunena Forum