Hello Guest it is October 04, 2024, 11:40:40 PM

Author Topic: Closed Loop Spindle Control (Step/Dir)  (Read 5543 times)

0 Members and 1 Guest are viewing this topic.

Closed Loop Spindle Control (Step/Dir)
« on: August 19, 2014, 11:25:46 AM »
I have two issues.
One, is I cannot understand why the display rpms don't ever change. I can tell Mach3 S400 and change to S1000 and see a change in motor rpms but the display rpms stay at 2. I am very confused as to why this dosen't change at all when I know the encoder signals are valid. I have also wondered why I have to use an index signal instead of an encoder from the encoders tab. Seems like I would have better control over rpms with A and B encoder pulses rather than a index pulse per rev. If it is possible to use A and B signals for encoder, How do I do that?
 I have played with numerous settings and the only thing that seems to change the displayed rpms is the pully setup but again the display value stays the same when I tell Mach3 to change rpms with the "S" command.
Two, I am having trouble understanding the setup for closed loop control for the spindle. I have a feeling this will be easier once I get the rpm display to be correct.   I have complete control over my other axes, which are stepper driven, and all that remains is the spindle. :(

My spindle is a DC servo motor driven by a G320X geckodrive.
The encoder is 2500count/rev with A,B, and Z(index) pulses http://www.quantumdev.com/products/optical_encoders/qd200.html
I have the index set to pin 15 under inputs tab in Ports and Pins menu.

Thanks in advance.

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
Re: Closed Loop Spindle Control (Step/Dir)
« Reply #1 on: August 20, 2014, 06:39:12 AM »
If you are using the parallel port then the index signal from the encoder will be too short a duration to be seen.

You have 3 choices
1. Use electronics to lengthen the pulse
2. Use an alternative index pulse, such as a slotted disc and an optical switch.
3. Use an external motion controller that supports the use of an encoders index pulse.

Hood
Re: Closed Loop Spindle Control (Step/Dir)
« Reply #2 on: August 20, 2014, 09:24:13 PM »
So something weird has happened. I have managed to get an rpm to display using the A (or B) pulse and the Z index without using any of those three suggestions.  I started to make a pulse stretcher like the one here http://electronics.stackexchange.com/questions/46922/lengthening-a-5-ns-pulse but didn't seem to do anything. So then I increased the baud rate to 115200 and the kernel frequency to 100khz. I also switched the index from active low to active high. This switch was probably what did it.   I am using the z index signal from the encoder and it seems to be pretty accurate.  I have set spindle speed to 5, 10, 20, 30, 40, and 50 rpms and compared it to measured values and they were very close.  Still confused as to why its working but I guess I shouldn't complain.  I tried using the A signal with a massive pulley ratio thinking it would be more accurate but I got non linear results. 

I would like to know why setting the steps per unit to 4000 in the motor tuning seems to work. If I use different values the actual rpm varies greatly from the requested.
Also, control gets really weird when I up the rpms to anything over 60rpm. 

The only issues I have now are setting values for the PID. Changing from one rpm to another can be quite interesting. I found this guide  https://controls.engin.umich.edu/wiki/index.php/PIDTuningClassical and will try to use it to find the magic numbers.

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
Re: Closed Loop Spindle Control (Step/Dir)
« Reply #3 on: August 20, 2014, 09:52:51 PM »
Setting the kernel higher will likely be the reason you are seeing some results however you are possibly going to run into issues as 100KHz takes a very stable computer indeed.

If your RPM is only going to be a max of 50 then you may be fine as far as the reading from the Index is concerned, much faster and your readings will likely dissapear.

Closed loop? You automatically have closed loop when using Step/Dir and a servo. The loop is closed in the drive, is it the drives PID you are talking about? If not then dont bother messing with Machs closed loop if you are using Step/Dir servo.

Steps per unit should be set to whatever your encoder is, for example if your encoder is 500 line (2000 counts per rev) then your steps per unit will be 2000, assuming you do not have any gearing.

One other thing that will affect how things work is the settings you have in Spindle Pulleys. The Max RPM will need to be set the same as you have in motor tuning or you will not get the requested speeds corresponding to actual.

Hood
Re: Closed Loop Spindle Control (Step/Dir)
« Reply #4 on: August 25, 2014, 10:27:49 AM »
So I did more tinkering. I had the Closed Loop Spindle Control option checked and and after I unchecked it I had much better results. However, solving one issue lead to others, but on the bright side I think I know how to fix it.  On the bench test the motor appeared to have decent torque, but when I mounted the motor to the spindle drive it acted like it had very little torque.  The motor is rated at 9inlb at 1317RPM and for the speeds I am running I should have around 10inlb. I am thinking that the encoder resolution has something to do with it because when I apply 45V to the motor it definitely has the torque.  When I follow geckodrive's optimal encoder line count formula I come up with a line count below 255.  So, I am thinking that a 200 cpr encoder will fix my torque and speed display issues.  I just need to verify that having too high of a CPR will cause these types of issues before ordering a new one. 

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
Re: Closed Loop Spindle Control (Step/Dir)
« Reply #5 on: August 27, 2014, 05:36:49 AM »
The encoder should have no effect on the torque whatsoever.

Can you gve me some info on your setup,
Is the motor directly coupled or is thee a reduction between it and spindle?
If thee is a reduction wha is it?
What is the encoder count at he moment?

Also if yo attach your xml I ill look through that and get he rest of the info  I require.

Hood
Re: Closed Loop Spindle Control (Step/Dir)
« Reply #6 on: August 29, 2014, 10:55:05 AM »
Problem identified.  My coupling was slipping and catching making appear to not have any torque I have secured the current coupling and ordered a proper coupling.  Things are looking good so far. :)