Commanded Spindle Speed Is Incorrect
02 Sep 2013 09:18 #38389
by jorsborn
Commanded Spindle Speed Is Incorrect was created by jorsborn
I have just wired up a HuanYang VFD to a 2.2kW spindle and have LinuxCNC talking to the VFD via its analog input. I have PDM output on pin 14 of my parallel port. This is wired to a Gecko G540 which filters the PDM to create an analog voltage. The voltage is then fed to the VFD. I have setup my hal file as below:
This all works to the extent that I can get the spindle running at speeds varying between 0 and 24,000 RPM. However, the actual speed does not match the speed I command. It is off significantly in some cases.
A few notes:
Any thoughts?
loadrt pwmgen output_type=0
addf pwmgen.update servo-thread
addf pwmgen.make-pulses base-thread
net spindle-speed-cmd motion.spindle-speed-out => pwmgen.0.value
net spindle-on motion.spindle-on => pwmgen.0.enable
net spindle-pwm pwmgen.0.pwm => parport.0.pin-14-out
# Set the spindle's top speed in RPM
setp pwmgen.0.scale 24000
# Use PDM
setp pwmgen.0.pwm-freq 0
This all works to the extent that I can get the spindle running at speeds varying between 0 and 24,000 RPM. However, the actual speed does not match the speed I command. It is off significantly in some cases.
A few notes:
- The VFD is correctly scaling speed according to the input voltage at the terminals. The error is in the voltage ouput from LinuxCNC/Gecko. For example, I command S12000 which should be half speed according to my scale settings. That should present 5V (0-10V), yet I see 7.06V.
- It's not a problem of resolution as I am able to step the spindle at ~ 100 RPM increments under manual control.
- Looking at the output on HAL Oscilloscope things seem ok.
Any thoughts?
Please Log in or Create an account to join the conversation.
02 Sep 2013 10:33 #38397
by PCW
Replied by PCW on topic Commanded Spindle Speed Is Incorrect
I would try PWM instead of PDM
and see if it improves the linearity
(at the expense of more ripple)
I'm guessing that the G540 uses a slow OPTO coupler
which will have very unsymmetrical on and off times
causing a large amount of non-linearity.
and see if it improves the linearity
(at the expense of more ripple)
I'm guessing that the G540 uses a slow OPTO coupler
which will have very unsymmetrical on and off times
causing a large amount of non-linearity.
The following user(s) said Thank You: jorsborn
Please Log in or Create an account to join the conversation.
02 Sep 2013 10:45 #38398
by jorsborn
Replied by jorsborn on topic Commanded Spindle Speed Is Incorrect
Thanks for the response! I actually started off with PWM and changed to PDM in hopes of it solving some problems. However, I find they operate identically (with respect to the problem I am having). The error seems to be right about 140% of my set point in a series of tests I performed. Is there a way to view the commanded value in HAL meter as a float? Meaning, I could verify that S12000 is indeed 0.5 and S18000 is indeed 0.75?
Please Log in or Create an account to join the conversation.
02 Sep 2013 10:59 #38399
by PCW
Replied by PCW on topic Commanded Spindle Speed Is Incorrect
What I would do is this:
Set the PWMGEN to PWM mode, set the spindle speed to 12000 and then look at pin 14 with HALScope. If the PWM waveform has 50% duty cycle the trouble is elsewhere.
Set the PWMGEN to PWM mode, set the spindle speed to 12000 and then look at pin 14 with HALScope. If the PWM waveform has 50% duty cycle the trouble is elsewhere.
Please Log in or Create an account to join the conversation.
02 Sep 2013 11:30 #38401
by jorsborn
Replied by jorsborn on topic Commanded Spindle Speed Is Incorrect
I'll try that again, but I believe I verified it looked correct at 50%. As I recall it was hard to be certain since the zoom feature would not allow me to zoom in on a single period. However, for the amount of error I am getting it should be quite obvious from the waveform.
I tend to agree with your initial thoughts regarding the optocoupler. I was thinking I'd try to lower the PWM frequency so that this effect was less evident. I was going to blindly adjust this but I'd rather have some understanding of how this relates to the base frequency so that I may pick a logical value for the frequency.
Also, if not specified, what is the default frequency? I thought this might be stated in man pwmgen but I was mistaken. Most of the spindle speed examples don't actually specify frequency.
I tend to agree with your initial thoughts regarding the optocoupler. I was thinking I'd try to lower the PWM frequency so that this effect was less evident. I was going to blindly adjust this but I'd rather have some understanding of how this relates to the base frequency so that I may pick a logical value for the frequency.
Also, if not specified, what is the default frequency? I thought this might be stated in man pwmgen but I was mistaken. Most of the spindle speed examples don't actually specify frequency.
Please Log in or Create an account to join the conversation.
02 Sep 2013 11:43 #38403
by PCW
Replied by PCW on topic Commanded Spindle Speed Is Incorrect
man pwmgen (in a terminal window) should help with most of these questions...
Please Log in or Create an account to join the conversation.
02 Sep 2013 13:43 #38408
by jorsborn
Replied by jorsborn on topic Commanded Spindle Speed Is Incorrect
You seem to be correct in your initial assumption. If I reduce the PWM frequency from 10k to 1k I get a much better result. I am going to leave it there. I lose some resolution but it's perfectly fine for what I need. In addition, I also enabled dithering which seems to help gain back some of that lost resolution.
In the quest for perfection I took the small DC offset out of the picture by adjusting the offset parameter for that PWM generator. The VFD reads EXACTLY what I command now.
In the quest for perfection I took the small DC offset out of the picture by adjusting the offset parameter for that PWM generator. The VFD reads EXACTLY what I command now.
Please Log in or Create an account to join the conversation.
02 Sep 2013 19:08 - 02 Sep 2013 19:09 #38427
by andypugh
I think the PWM on my mill runs at 50Hz PWM frequency.
10kHz from software pwm generation is a bit optimistic.
Replied by andypugh on topic Commanded Spindle Speed Is Incorrect
Actually, you will get better PWM resolution, at the expense of a lower bandwidth. But you are probably not trying to track fast setpoint changes with the VFD so it is probably fine.You seem to be correct in your initial assumption. If I reduce the PWM frequency from 10k to 1k I get a much better result. I am going to leave it there. I lose some resolution
I think the PWM on my mill runs at 50Hz PWM frequency.
10kHz from software pwm generation is a bit optimistic.
Last edit: 02 Sep 2013 19:09 by andypugh.
Please Log in or Create an account to join the conversation.
Time to create page: 0.083 seconds