Rls encoder and vfd calibration

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

WastedFreeTime
Posts: 4
Joined: Tue Sep 14, 2021 10:20 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 4462
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Rls encoder and vfd calibration

Post by WastedFreeTime »

I ran across this thread while I was looking to implement something similar so I’ll share my solution in case it helps someone in the future. This is a very easy thing to implement if you are comfortable editing the PLC. There is only a single line of code that needs to change.

Background: I run a PMDC treadmill motor as my spindle motor using the PWM output of the Acorn for spindle speed control. In order to calibrate my spindle speeds, I needed a spindle command in the y=mx+b format to be able to properly specify a zero speed bias. In my case, the PWM high period needed to be almost 20% of full scale just to get the spindle motor to spin at its minimum speed. As it stands today, there are no wizard settings that will allow you to calibrate the spindle speeds in such a scenario.

Disclaimer: I am in no way advocating the use of PMDC treadmill motors as spindle motors. Don’t waste your time. Get a 3 phase AC motor and a VFD.

On to editing the PLC. The PLC uses a variable called “TwelveBitSpeed_FW” that needs to end up in the range of 0-4095 (12 bit) in order to set the spindle speed for output to the DAC. 0 is the slowest, 4095 is the fastest. I’m no expert on the PLC code, but in my review I think if you can set this value properly, it won’t matter if you are using the PWM output or the 0-10V analog output. Either should work.

The code of interest starts around line 3655 in the src file. The original command is:
“IF True THEN TwelveBitSpeed_FW = SpinSpeedCommand_FW/RPMPerBit_FW”

Which effectively implements a y=mx style formula where the slope “m” is just your maximum spindle output speed divided by 4096.
You can comment out this line, and replace it with one that uses a y=mx+b format where “b” is the zero speed bias in 12 bit counts and “m” is the slope in number of 12 bit counts per RPM. In my case it looks like this:

“IF True THEN TwelveBitSpeed_FW = SpinSpeedCommand_FW * 0.57 + 645”

That’s all there is to it. Compile the code and break out your IR tachometer and run the spindle through the entire range. Adjust the hard coded bias and or slope as necessary to minimize your speed error. I was able to get my measured spindle speed within 3% of commanded over the range from 400 - 5000rpm with a simple y=mx+b linear relationship. In theory, you should be able to use whatever relationship you want on this line of code (i.e. higher order polynomial) if you really wanted to take out any non-linearities in your speed range.

Hope this helps someone out in the future.
---------------------------------------------------
My build: viewtopic.php?p=54318#p54318
cncsnw
Posts: 3763
Joined: Wed Mar 24, 2010 5:48 pm

Re: Rls encoder and vfd calibration

Post by cncsnw »

In your PLC program, approximately lines 3574-3632, you have:

Code: Select all

;------------------------------------------------------------------------------
;              Read commanded spindle speed, max & min
;
; ***NOTE***  SV_PC_COMMANDED_SPINDLE_SPEED already has override
;             factored in.
;------------------------------------------------------------------------------
IF True THEN CfgMinSpeed_FW = SV_PC_CONFIG_MIN_SPINDLE_SPEED,
             CfgMaxSpeed_FW = SV_PC_CONFIG_MAX_SPINDLE_SPEED
; Calculate #RPM's per bit of resolution
IF CfgMaxSpeed_FW > 0.0 THEN RPMPerBit_FW = CfgMaxSpeed_FW/4095.0
IF CfgMaxSpeed_FW <= 0.0 THEN RPMPerBit_FW = 1.0

; In auto mode, assuming M3 or M4 present, use given RPM from CNC11/CNC12
IF SpinAutoModeLED THEN SpinSpeedCommand_FW = SV_PC_COMMANDED_SPINDLE_SPEED
IF SpinSpeedCommand_FW > 1 THEN SET MEM999
IF SpinSpeedCommand_FW < 1 THEN RST MEM999

; In manual mode, assuming spindle is on, use speed scaled from CCFG max
IF !SpinAutoModeLED THEN SpinSpeedCommand_FW = CfgMaxSpeed_FW *
                                               SV_PLC_SPINDLE_KNOB / 200.0 *
                                               SpinRangeAdjust_FW

; In manual or auto, if no M3/M4 or spindle run, then use zero instead
;;; but note that SpindleDisable_M only applies to G540....
IF SpindleDisable_M THEN SpinSpeedCommand_FW = 0.0

;------------------------------------------------------------------------------
; If commanded spindle speed is < Min Spin Speed * SpinRangeAdjust
; & commanded spindle speed > 0, force to commanded spindle speed
; = min spin speed value * SpinRangeAdjust.
;------------------------------------------------------------------------------
IF (SpinSpeedCommand_FW > 0.0) &&
   (SpinSpeedCommand_FW < (CfgMinSpeed_FW * SpinRangeAdjust_FW))
  THEN SpinSpeedCommand_FW = (CfgMinSpeed_FW * SpinRangeAdjust_FW),
       InfoMsg_W = MIN_SPEED_MSG

;------------------------------------------------------------------------------
; If SpinSpeedCommand_FW > Max Spin Speed * SpinRangeAdjust, force
; SpinSpeedCommand_FW = max spin speed value * SpinRangeAdjust.
;------------------------------------------------------------------------------
IF SpinSpeedCommand_FW > (CfgMaxSpeed_FW * SpinRangeAdjust_FW)
  THEN SpinSpeedCommand_FW = (CfgMaxSpeed_FW * SpinRangeAdjust_FW)

;------------------------------------------------------------------------------
; Convert Spindle "S" command to 12 bit value for output to DAC
;------------------------------------------------------------------------------
; Commanded Spindle speed (includes override factor) is sent down from CNC12
; in SV_PC_COMMANDED_SPINDLE_SPEED.  This value needs to be converted to a
; 12 bit value (0-4095) where full scale = SV_PC_CONFIG_MAX_SPINDLE_SPEED.

;Convert RPM to 12 bit value
IF True THEN TwelveBitSpeed_FW = SpinSpeedCommand_FW/RPMPerBit_FW

; Factor in gear range
IF True THEN TwelveBitSpeed_FW = (TwelveBitSpeed_FW/SpinRangeAdjust_FW)

;Convert to integer word for DAC & I/O display
IF True THEN TwelveBitSpeed_W = TwelveBitSpeed_FW

This is the section in which the PLC calculates the DAC output (analog voltage) required to get the drive to run at the desired RPM.

"RPMPerBit_FW" is the slope that Acorn expects the drive to exhibit.
The calculations in this section implicitly assume 0V = 0RPM (i.e. there is no "bias" or "offset" added).
Ultimately, "TwelveBitSpeed_FW" is the value sent to a 12-bit DAC, and must range from 0 (at 0V output) to 4095 (at 10V output).

Suppose you wanted to add an offset term, from Machine Parameter 701; and a gain multiplier, from Machine Parameter 702. Parameters 701 and 702 have no pre-defined meaning, and so are available for you to use however you please.

First, you could apply your gain parameter (P702) to the calculation of RPMPerBit_FW:

Code: Select all

IF CfgMaxSpeed_FW > 0.0 THEN RPMPerBit_FW = CfgMaxSpeed_FW/4095.0
IF CfgMaxSpeed_FW <= 0.0 THEN RPMPerBit_FW = 1.0
IF SV_MACHINE_PARAMETER_701 != 0 THEN RPMPerBit_FW = RPMPerBit_FW * SV_MACHINE_PARAMETER_702
Then, later, you could add your offset value to TwelveBitSpeed_FW, after the gear-range adjustment has been made:

Code: Select all

; Factor in gear range
IF True THEN TwelveBitSpeed_FW = (TwelveBitSpeed_FW/SpinRangeAdjust_FW) + SV_MACHINE_PARAMETER_701

;Convert to integer word for DAC & I/O display
IF True THEN TwelveBitSpeed_W = TwelveBitSpeed_FW
Your starting point (no changes compared to the stock program) would be with P702 = 1.0 and P701 = 0.0.

Your sketch indicates a steeper RPM/bit slope, so you might need to set P702 to something closer to 2.0.
Your sketch also indicates maybe a 20% offset required before you get any speed at all. 20% of 4095 is around 820, so you might try P701 near there.

Edit these changes into your copy of "acorn_mill_plc.src" in your c:\cncm directory, then either recompile it yourself, or get the Wizard to recompile it for you.
Post Reply