Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: moorea21 on April 22, 2010, 03:47:27 PM

Title: speed control of stepper used as spindle motor
Post by: moorea21 on April 22, 2010, 03:47:27 PM
Hi, I've asked this before in a different (maybe over complicated) way and got no replies, so I'm rephrasing it to get to the point a bit more...

How exactly does Mach3 handle step/dir for a stepper motor used as a spindle?

Under say, an M03 command, does it produce a step signal and direction signal, and have some internal algorithm for changing the frequency of the steps to alter the spindle speed? I assume this would need to be sent through a driver as for any ordinary axis.

Is it just a matter of connecting up a stepper motor as if it were an ordinary axis, but specifying it as 'spindle' in the motor outputs panel? still not sure why I can't make this work

Richard B
Title: Re: speed control of stepper used as spindle motor
Post by: Hood on April 22, 2010, 04:14:44 PM
It is just like any other axis, you need to work out the steps per unit and set a velocity and an acceleration.
One unit is one revolution so for example with a normal stepper that would be 200 steps per rev multiplied by any microstepping that your drive has. For example Geckos have 10 microsteps to 200 x 10 = 2000 steps per unit.
Now velocity I am not too sure about as I use a SmoothStepper on all my machines, the motor tuning page seems to suggest that it is revs per second for the velocity so say for example you reckon you will get 1000rpm out of your stepper you would set the Vel to 1000/60 = 16.66666667 revs per second. The Accel is Revs/s/s so start low, maybe 5 and see how things go.

If you command a M3S100 the spindle should rotate at 100 rpm, if its too slow then it is likely that the Velocity should actually be Revs per min so set it to 1000 and try the M3S100 again.

If you still have problems attach your xml and I will have a look and see if I can find a problem in your setup.

Hood
Title: Re: speed control of stepper used as spindle motor
Post by: moorea21 on April 22, 2010, 05:45:15 PM
Okay, thanks.

Just to note, the spindle DRO's yellow led flashes, but not a sound from the motor(S5000 on 1 line in the MDI, then M3 on the next). It's on an ncPod; their support don't know anything about spindle control, apparently. Xml attached, I think...

Richard
Title: Re: speed control of stepper used as spindle motor
Post by: Hood on April 22, 2010, 05:52:24 PM
Ah OK afraid I know nothing about the ncPod, it may well be that it does not support Step/Dir spindle.
Looked at your xml and all seems fine in it so it looks like its  a ncPod issue :(
Hood
Title: Re: speed control of stepper used as spindle motor
Post by: moorea21 on April 22, 2010, 06:08:02 PM
That's what I suspected. An alternative approach to solving this problem might be this:

What I want to do is to operate a linear stepper to deposit paint in straight lines (ie movement on the x axis only; no depositing of paint during movements involving any other axes), so I could 'link' the number of steps made by the x axis to those taken by the axis driving the pump, and play around with the ratio between the 2 rates to get a rate of deposit as required.

Would I need to write some code to achieve this? Or is there some way of slaving the a axis (pump) to the x axis, but specifying different steps per, or speeds, to achieve the desired ratio(s)?

This is for anyone to chip in on...Thanks Hood

Richard B
Title: Re: speed control of stepper used as spindle motor
Post by: simpson36 on April 23, 2010, 12:07:33 PM
Fascinating, as Spock would say,

If I understand the issue correctly you have a stepper motor driven pump that pumps paint in sync with movement of the X axis, and you have a controller in the mix that won't allow step dir spindle.

You might investigate the potential to set up the pump stepper as your 'A" axis.  In this way you can have independent control of the paint application, for example to start the X movement before the paint to avoid a puddle  . .  I'm speculating only here.

Mach will coordinate the movements of both axis so you could for example program:

G1 X25A7200

This would move the X axis 25 units and simultaneously rotate the pump 20 revolutions (or however much you have it set up to do). Actually this may be more intuitive than mentally converting linear motion into pump volumes, but in any case, be aware that Mach seems to have some 'interesting' ideas about how to mix rotary and linear speeds.  I'm still working on that one myself.
Title: Re: speed control of stepper used as spindle motor
Post by: moorea21 on April 23, 2010, 01:29:53 PM
You are correct, Simpson36, that is what I'm trying to achieve, and yes, the controller doesn't seem to want to know. The developers of the ncPod don't know if it handles step/dir for spindles, but assume it does. they don't know Mach3 well, apparently. I'm surprised they haven't tested this feature, but there.

I take heed of what you say about speed problems in combining/ interpolating rotary and linear axes together, in fact I'd considered using the z axis to drive the pump for that reason. Only trouble is, that might make generating the g code difficult,as I already have a physical z axis, so I'm hoping there's a way to configure the a axis as another linear axis.

Do you know if this is the case?

The problem remains in either case of 'fixing' the ratio between x axis movement and pump axis movement during 'painting' (Assuming the axes can work well enough simultaneously.) This is where I may need to write an app to edit my gcode that works like

 'read x axis value
 divide by the number needed to get correct ratio
 add this new value into the code and precede it with the designated axis letter'

This might be easier than trying to generate the pump axis code in, say, Cam Bam or whatever g code generator end up I using. This simple approach won't allow for non simultaneous starting of both axes, of course, but it's a start. Once I get the principles involved in getting to this stage, I should be able to have a go at more sophisticated stuff

I have no idea how to do this yet; it feels like it should be simple, but I bet it won't be!

Any suggestions?

Thanks,

Richard B
Title: Re: speed control of stepper used as spindle motor
Post by: simpson36 on April 23, 2010, 03:09:04 PM
I will tell you a workaround I have used to make mach run the axis at the speed I want, if that might help you.

The problem: Mach seems to have a very different idea about what 'speed' is to a rotary and linear axis. For example, using a G1 with the A axis and the X axis moving at the same time is like molasses in winter. It is the A axis that it is running at a snails pace. Maxing the speed in motor tuning has little effect. If I use a G0, if flies.

There may be something that I am unaware of that need to be set correctly, but I have not looked into that as it has not been a priority . . . . so far. It may have to do with using the stock radius to calculate the linear equivalent surface speed, or something similar, but so far I have not found it in Mach, at least not in a form that makes and sense to me. I've asked the question a couple times long ago but so far, no clear direction  :(

Anyway, what I do if I MUST have simultaneous movement and I cannot live with my normal G0 speed, then I have to set the X axis max speed down in the motor tuning to what I would want a G1 to be and then use G0. The tuning limits the speed, but G0 runs the A axis at full speed. limited then by the X axis and all is well.

That's pretty convoluted to follow, but I think I explained it correctly so just read it a few times and hopefully it will make sense.
Title: Re: speed control of stepper used as spindle motor
Post by: Hood on April 23, 2010, 04:34:49 PM
Simpson, I have never used a rotational  4th axis on any of my machines but have you set a rotational radius on the settings page, actually think it should be dia if I remember other peoples posts on the subject.
Maybe this has nothing to do with your problems but I thought I would just mention it in case.
Hood
Title: Re: speed control of stepper used as spindle motor
Post by: moorea21 on April 23, 2010, 04:47:18 PM
Thanks, Simpson, this sounds like a good way around the problem, especially as I don't use the max speed as it stands. I'll get back to you in a couple of days and say how it went.

Richard B
Title: Re: speed control of stepper used as spindle motor
Post by: simpson36 on April 23, 2010, 05:21:18 PM
Simpson, I have never used a rotational  4th axis on any of my machines but have you set a rotational radius on the settings page, actually think it should be dia if I remember other peoples posts on the subject.
Maybe this has nothing to do with your problems but I thought I would just mention it in case.
Hood

I don't see anything that is identified as a 'settings' page. Where would one find this?
Title: Re: speed control of stepper used as spindle motor
Post by: Hood on April 23, 2010, 05:26:20 PM
See pic.
Title: Re: speed control of stepper used as spindle motor
Post by: simpson36 on April 23, 2010, 05:37:34 PM
Thank you Mr Hood!

I have been looking for it under the configure tab all this time. I was told it was part of the 'configuration' and obviously made a wrong assumption  :-[

As my dear departed Mom used to say to use as kids: "If it had teeth, it would have bit you!"

Once again saved by the Hood!

You da man  :-*
Title: Re: speed control of stepper used as spindle motor
Post by: Hood on April 23, 2010, 05:38:50 PM
Let me know if it works for you please :)
Hood
Title: Re: speed control of stepper used as spindle motor
Post by: simpson36 on April 23, 2010, 05:40:30 PM
Willco . . .
Title: Re: speed control of stepper used as spindle motor
Post by: Hood on April 23, 2010, 05:48:14 PM
As my dear departed Mom used to say to use as kids: "If it had teeth, it would have bit you!"

I was going to be unkind and suggest you visit this site http://www.specsavers.co.uk/ they run some great adds on the telly and in magazines, heres one of them  http://bjcrum.com/images/specsavers.jpg

Hood
Title: Re: speed control of stepper used as spindle motor
Post by: simpson36 on April 23, 2010, 06:05:04 PM
Too funny.

I see there is a little 'cross pollination' going on there. Now I knew the Brits were pervs, but a Scotsman??   >:D
Title: Re: speed control of stepper used as spindle motor
Post by: RICH on April 23, 2010, 06:06:51 PM
HMM.....
For the rotary....
- Four different combinations for feedrates
- three feedrate modes
- a compensated f based on the rotational diameter
- then you have the slaving of axes
- no explanation that i can absorb easily
- the difference between setting up a stepper for use as a spindle as compared to just indexing

Then you add to that a stepper which looses torque as the speed increases thus feedrates / velocity setting are not linear , heck you can probably generate a torque to speed curve for your stepper motor from the data...

Good Grief.......it can get confusing ..... and i confuse easily

Rumor has that Simpson is going to do a write up on it all for us.  >:D

RICH
Title: Re: speed control of stepper used as spindle motor
Post by: Hood on April 23, 2010, 06:08:06 PM
:D Thats a clean one, you should google that phrase sometime you need a laugh.
Hood
Title: Re: speed control of stepper used as spindle motor
Post by: moorea21 on April 24, 2010, 05:23:20 AM
Okay, I've realised I still have part of the original problem, and in order to explain this I need to tell you some more about the machine:-

It's basically a 2.5d plotter, working from artwork in photoshop that's had a grid applied to it to turn it into a series of thin parallel lines. The jpeg file with these lines are then vectorised and turned into hgpl in the program I currently run (R2V). This involves x, y and z axes, as the z axis controls pen up/ pen down From there it should be easy to send that through a program that converts the hgpl into g code (not tried to yet), where, as I said earlier in this post, the paint is only pumped during horizontal strokes (x axis only, no y or z to interpolate.) Why? it's just easier that way, I know that it works from running an old Roland plotter for this  a few years ago.

The problem is, of course, that my g code will then only contain code for the x, y, and z axes. I still have to generate the code that tells the a axis (pump) how many steps to take while the x axis does it's thing. Spindle contorl would have been so much easier, I could just tel Cam Bam or whatever to only switch the spindle on when the z axis is in 'pen down' position. Oh well.

So it's back to my question about how to write an app that does that. (See earlier post for my crude program idea!)

Should I save the g code as .txt, and make a macro somehow to do that in microsoft word or some other text editor? Wild guess...

Can anyone give me some pointers on how to do this properly?

Ta,

Richard B