The PMC is a place where we can run some code on your machine to customize the machine. It is loaded in the screen edit mode.. Anyway that part is easy ! The hard part is to make the code ... I just happen to have made the code this morning for fun
What can I say I don't get out much LOL
Here is the code :
-- Fit Spindle Speed with linear interpolation
function buildtbl()
rpmtbl = { points = 0,
addPoint = function (self, commandRPM, trueRPM )
self[tonumber(self.points)] = {}
self[tonumber(self.points)].commandRPM = commandRPM
self[tonumber(self.points)].trueRPM = trueRPM
self.points = self.points + 1
end,
linearInterp = function(self, RPM)
local low = -1
local high = -1
for i=0, self.points-1,1 do-- loop through the points and get the high and the low around the requested RPM
if (self[i].commandRPM <= RPM) then
low = i
end
if (self[i].commandRPM >= RPM) then
high = i
break
end
end
--check to see if the point is on the table, if not simply return what was input
if(high == -1 or low == -1)then
return RPM
end
if(high == low) then
return self[low].trueRPM
end
--y = y1 + ((x – x1) / (x2 – x1)) * (y2 – y1)
--time to figure it out!
local NewRPM = self[low].trueRPM + ( (RPM - self[low].commandRPM) / ( self[high].commandRPM -self[low].commandRPM )) * (self[high].trueRPM - self[low].trueRPM )
return NewRPM
end,
}
--To add a point call the addPoint function with the Requested PRM, Than the True RPM (this must be done without this function active)
-- Example Command 500 RPM Spindle is teally going 750
-- The following call would be made rpmtbl:addPoint(500 ,750)
rpmtbl:addPoint(100,10)
rpmtbl:addPoint(200,100)
rpmtbl:addPoint(2000,2500)
rpmtbl:addPoint(3000,5000)
end
function calcRPM(rpm)
-- take the requested RPM and adjust based on the table fitting points
if(rpmtbl == nil) then--build a global table on the first scan
buildtbl()
end
local adjRPM = rpmtbl:linearInterp(101)
end
local SpindleRPM = 2500
local outputRPM = calcRPM(SpindleRPM)
I know this is scary to see the code but all you really need to do is look at the following lines:
rpmtbl:addPoint(100,10)
rpmtbl:addPoint(200,100)
rpmtbl:addPoint(2000,2500)
rpmtbl:addPoint(3000,5000)
The first number is the RPM you asked for the 2nd one is what you got for an RPM. You can add as many points as you would like. This thing expands every time you add a point. If you ask for an RPM outside of the range it will just return what you sent . You think you can get that data ? I think you had it in your graph
Thanks
Brian