The configuration and HAL changes ended up taking over a day to figure out but in the end I managed to get spindle soft ramp up and ramp down in place along with encoder based RPM and actual spindle load displayed in Probe Basic.
I've attached my config files for Probe Basic in this post (note that the custom_tool_change.ngc file has to go in the subroutines folder). In this post I'll highlight the areas which were hardest to figure out. Hopefully Google picks them up this post so that other people searching for the same things find this post.
Here is current wiring schematics for reference:
I started with modifying my AXIS configuration using Pncconf. It has been virtually fool proof for generating configuration changes before but the values it generated when selecting a servo spindle in step/dir mode were for some reason not really spot on and it took me a while to figure what was going on as I was getting error about MAXVEL being too high right out of the box.
Currently I'm using the following values in the INI file for the spindle and the encoder:
Code:
[SPINDLE_0]
MAX_VELOCITY = 4500
MAX_REVERSE_VELOCITY = 4500
MAX_ACCELERATION = 15
STEPGEN_MAXVEL = 93.75
STEPGEN_MAXACCEL = 30
P = 0.0
I = 0.0
D = 0.0
FF0 = 1.0
FF1 = 0.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 4500.0
ENCODER_SCALE = -5000
DIRSETUP = 800
DIRHOLD = 800
STEPLEN = 1000
STEPSPACE = 1000
STEP_SCALE = 5000
The new spindle servo has a maximum RPM of 6000 rpm but I've set the limit at 4500 until I have replaced the spindle bearings.
The acceleration values are set very low to ensure a smooth ramp up/down as the servo motor has a lot of torque and makes a very violent starts otherwise.
I carefully matched the polarity for the differential encoder signals from the servo drive to the Mesa 7i96S board but for some reason I still hade to invert the encoder scale otherwise it was reading rotation in the wrong direction. It should also be noted that if you have for example a 1000 pulses per revolution (ppr) quadrature encoder the ENCODER_SCALE value set in the INI file needs to multiplied by four.
The 2kw Delta B3 servo drive for the spindle servo came with a default setting of 2500 ppr setting but I reconfigured it to 1250 ppr instead as 10 000 pulses per revolution felt a bit overkill.
I left the PID settings completely stock but as I'm using a close loop servo I'm not sure that PID should even be enabled as the drive handles that and even triggers a fault if there is too much deviation between the commanded position and the actual position.
When it came to the HAL file I had previously picked up on the fact that the stepgen on the Mesa board used to control the spindle should be enabled by machine-is-on and not spindle-enable as otherwise it would cause very abrupt stops of the spindle when using a servo.
Pncconf correctly generated the following line in my case:
Code:
net machine-is-on => hm2_7i96s.0.stepgen.03.enable
However I was still getting very abrupt spindle stops which I tracked down to the following line in the HAL file:
Code:
# --- SPINDLE-ENABLE ---
net spindle-enable => hm2_7i96s.0.7i84.0.0.output-01
That line controls the enable signal sent to the servo drive, without it the servo drive immediately stops.
I wanted the servo drive to ramp down slowly when stopped and then disable the drive so that I can rotate the spindle by hand when changing tools etc. I the end I solved this by using the great example posted by pippin88 in this thread (
forum.linuxcnc.org/10-advanced-configura...ep-dir-servo-spindle
).
Code:
# --- timedelay before disable spindle output for deceleration ramp --- #
loadrt timedelay names=timedelay.spindle-enable-soft-stop
addf timedelay.spindle-enable-soft-stop servo-thread
setp timedelay.spindle-enable-soft-stop.on-delay 0
setp timedelay.spindle-enable-soft-stop.off-delay 3
net spindle-enable => timedelay.spindle-enable-soft-stop.in
net spindle-enable-soft-stop <= timedelay.spindle-enable-soft-stop.out
net spindle-enable-soft-stop => hm2_7i96s.0.7i84.0.0.output-01
With these values set the spindle enable signal remains active for an additional 3 seconds when the spindle stop signal is given which allows the spindle to ramp down softly according to the values set in the INI file.
When I had the spindle working properly with both ramp up and down I turned my attention to the user interface of Probe Basic.
In order to get the actual spindle RPM from the encoder to work the following line had to be added to the post gui file, in my case the custom.hal.
Code:
#Spindle RPM from encoder
net spindle-vel-fb-rpm => qtpyvcp.spindle-encoder-rpm.in
Getting the spindle load bar to work took only the following 3 lines.
Code:
#Spindle load (torque)
setp hm2_7i96s.0.7i84.0.0.analogin0-scalemax 453.75
net spindle-load <= hm2_7i96s.0.7i84.0.0.analogin0
net spindle-load => qtpyvcp.spindle-load-indicator.in-f
The really magic part in those lines is the scalemax parameter which I would never have guessed existed or figured out how it worked if it wasn't for a few excellent posts from PCW on this forum.
As far as I have understood it the analog inputs on the 7i84 board by default scale from 0 to 36.3v. By changing the scale to go from 0 to 453.75 the max 8 volts which the servo drive analog output gives is translated to 100. This makes the spindle load bar in Probe Basic go from 0% to 100% as the voltage to the analog input varies from 0 to 8 volts.
I know that it would probably be better to have the spindle load bar in Probe Basic go from 0% to something like 150% or 200% to allow for higher peak loads to be displayed but I put that on the todo list for another day