Re: Rls encoder and vfd calibration
Posted: Thu Sep 16, 2021 10:51 pm
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.
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.