Closed Loop Spindle with parametric encoder scale
02 Sep 2016 22:39 #79944
by barsam
Closed Loop Spindle with parametric encoder scale was created by barsam
Hi Everyone.
I have managed to install pathpilot on my retrofitted Optimum BF20 Mill, and I have managed to setup pretty much everything so far.
What I have not managed to figure out, after straggling for couple of days, is how to make my spindle work closed loop and take into account the HI LO spindle range change.
For convenience reasons I have installed an encoder at the top of my motor but the motor drives the spindle using 2 speeds (HI 1:1 and LO 1.56:1).
The index of the encoder is bypassed with the one on the spindle, so the index is pulsing per revolution regardless the speed selection.
Obviously the reported velocity is accurate when the HI speed is selected and the belt is on the high pulley, but it is not the case when the belt is on the low speed position.
Is there a way to configure pathpilot to take into consideration the ratio change on the encoder side?
Can I close the loop of the spindle in pathpilot? If so, can you please provide me with a sample HAL file so that I can adapt the code?
I have seen couple of discussions on this but what confuses me is the fact that pathpilot uses a module called tormachspindle for the spindle control and I have no idea hot to use it in combination to a closed loop setup.
Also be advised that I am new to the linuxcnc world, so some things may not be clear to me.
Thank you in advance for any help.
I have managed to install pathpilot on my retrofitted Optimum BF20 Mill, and I have managed to setup pretty much everything so far.
What I have not managed to figure out, after straggling for couple of days, is how to make my spindle work closed loop and take into account the HI LO spindle range change.
For convenience reasons I have installed an encoder at the top of my motor but the motor drives the spindle using 2 speeds (HI 1:1 and LO 1.56:1).
The index of the encoder is bypassed with the one on the spindle, so the index is pulsing per revolution regardless the speed selection.
Obviously the reported velocity is accurate when the HI speed is selected and the belt is on the high pulley, but it is not the case when the belt is on the low speed position.
Is there a way to configure pathpilot to take into consideration the ratio change on the encoder side?
Can I close the loop of the spindle in pathpilot? If so, can you please provide me with a sample HAL file so that I can adapt the code?
I have seen couple of discussions on this but what confuses me is the fact that pathpilot uses a module called tormachspindle for the spindle control and I have no idea hot to use it in combination to a closed loop setup.
Also be advised that I am new to the linuxcnc world, so some things may not be clear to me.
Thank you in advance for any help.
Please Log in or Create an account to join the conversation.
03 Sep 2016 18:43 #79984
by barsam
Replied by barsam on topic Closed Loop Spindle with parametric encoder scale
Just an update.
I have managed to manipulate the encoder scale according to my needs by modifying the python code of pathpilot. So now the encoder is reporting the correct data according to the selected spindle range.
So now what is left to sort out, is the closed loop part. Any help will be much appreciated.
I have managed to manipulate the encoder scale according to my needs by modifying the python code of pathpilot. So now the encoder is reporting the correct data according to the selected spindle range.
So now what is left to sort out, is the closed loop part. Any help will be much appreciated.
Please Log in or Create an account to join the conversation.
04 Sep 2016 11:39 #80009
by andypugh
Replied by andypugh on topic Closed Loop Spindle with parametric encoder scale
I am surprised that it is possible to get what you want by editing Python (non-realtime) code.
To do what you need with standard HAL blocks you could use a "mux2" to feed the alternate scales to a "scale" HAL function and use that to modify the reported encoder velocity before passing to to the PID that closes your velocity loop.
You _might_ be able to use the "gearchange" comp. There is no reason that the init has to be spindle command and the output VFD command, the input could be encoder velocity and the output actual spindle velocity.
To do what you need with standard HAL blocks you could use a "mux2" to feed the alternate scales to a "scale" HAL function and use that to modify the reported encoder velocity before passing to to the PID that closes your velocity loop.
You _might_ be able to use the "gearchange" comp. There is no reason that the init has to be spindle command and the output VFD command, the input could be encoder velocity and the output actual spindle velocity.
Please Log in or Create an account to join the conversation.
04 Sep 2016 12:18 - 04 Sep 2016 12:18 #80014
by barsam
Replied by barsam on topic Closed Loop Spindle with parametric encoder scale
Thank you for your response.
Actually the problem I had, which might be because I was doind something wrong, it was that I was not able to assign a signal, or pin to a parameter. What ever I tried it was giving me an error that it is an invalid float type.
So I ended up changing the parameters from the code by calling "halcmd setp".
Is this possible in a HAL file, or is it a restriction? I mean assigning values that are not constants to parameters.
Actually the problem I had, which might be because I was doind something wrong, it was that I was not able to assign a signal, or pin to a parameter. What ever I tried it was giving me an error that it is an invalid float type.
So I ended up changing the parameters from the code by calling "halcmd setp".
Is this possible in a HAL file, or is it a restriction? I mean assigning values that are not constants to parameters.
Last edit: 04 Sep 2016 12:18 by barsam.
Please Log in or Create an account to join the conversation.
04 Sep 2016 14:01 #80017
by andypugh
Replied by andypugh on topic Closed Loop Spindle with parametric encoder scale
You can't link to parameters in HAL.
The very existence of parameters is actually something of a hangover from when memory was much smaller. There is a general trend towards turning them into pins.
Which parameters were you trying to link to? I a pretty sure that the inputs of mux and scale are pins?
The very existence of parameters is actually something of a hangover from when memory was much smaller. There is a general trend towards turning them into pins.
Which parameters were you trying to link to? I a pretty sure that the inputs of mux and scale are pins?
Please Log in or Create an account to join the conversation.
04 Sep 2016 14:12 - 04 Sep 2016 14:20 #80021
by barsam
Replied by barsam on topic Closed Loop Spindle with parametric encoder scale
I was trying to link these parameters:
hm2_5i25.0.encoder.03.scale
hm2_5i25.0.pwmgen.00.scale
What I did finally was to change tormach_mill_ui.py at the lines where the spindle range button is updated (as the image has to change), and did the following at lines 1521 and 3683 where the if statements are:
hm2_5i25.0.encoder.03.scale
hm2_5i25.0.pwmgen.00.scale
What I did finally was to change tormach_mill_ui.py at the lines where the spindle range button is updated (as the image has to change), and did the following at lines 1521 and 3683 where the if statements are:
if self.hal['spindle-range']:
# high
self.set_image('spindle_range_image', 'Spindle_Range_HI_Highlight.png')
encoder_scale = self.ini_float("SPINDLE", "HI_ENCODER_SCALE", 0.0)
pwm_scale = self.ini_float("SPINDLE", "HI_RANGE_MAX", 0.0)
else:
# low
self.set_image('spindle_range_image', 'Spindle_Range_LO_Highlight.png')
encoder_scale = self.ini_float("SPINDLE", "LO_ENCODER_SCALE", 0.0)
pwm_scale = self.ini_float("SPINDLE", "LO_RANGE_MAX", 0.0)
halcmd_list = ['halcmd', 'setp', 'hm2_5i25.0.encoder.03.scale', str(encoder_scale)]
run_mdi_admin_program(self, halcmd_list)
halcmd_list = ['halcmd', 'setp', 'hm2_5i25.0.pwmgen.00.scale', str(pwm_scale)]
run_mdi_admin_program(self, halcmd_list)
Last edit: 04 Sep 2016 14:20 by barsam.
Please Log in or Create an account to join the conversation.
04 Sep 2016 14:24 #80022
by andypugh
Replied by andypugh on topic Closed Loop Spindle with parametric encoder scale
Yes, encoder scale is a parameter and can't be linked. This is probably for the best, because if you did change the scale with a few thousand turns completed the sudden change in position would lead to all sorts of trouble. Especially if the spindle is part of a closed position loop. (it would probably only be a momentary blip to a velocity loop)
It is probably better to simply scale the velocity output pin for closed-loop speed control.
If you want spindle-synchrnonised motion it gets more difficult. One solution might be to use two encoder counters sharing the same physical encoder. But you can probably only realistically use the motor-mounted encoder for spindle-synched moves in the 1:1 gear anyway.
It is probably better to simply scale the velocity output pin for closed-loop speed control.
If you want spindle-synchrnonised motion it gets more difficult. One solution might be to use two encoder counters sharing the same physical encoder. But you can probably only realistically use the motor-mounted encoder for spindle-synched moves in the 1:1 gear anyway.
Please Log in or Create an account to join the conversation.
Moderators: cncbasher
Time to create page: 0.220 seconds