Hello Guest it is March 28, 2024, 06:52:17 PM

Author Topic: Feed Rate Override Absolute Value?  (Read 4180 times)

0 Members and 1 Guest are viewing this topic.

Re: Feed Rate Override Absolute Value?
« Reply #10 on: December 22, 2016, 10:13:01 AM »
I have three DRO's; one for X move value, one for Y move, and one for feed rate. The feed rate entered is an absolute feed rate so the feed rate is determined as a percentage of 150in/min(100% jog speed on my setup)
After calculating the diagonal distance needed to travel, feed rate values are calculated for the X and Y so that the motors move together and arrive at the same point at the same time. the values are factors of the Hypotenuse so as to create the right triangle.

For some reason I was originally having issues with setting slow feed rates because the motors were running at rapid feed rates and the PMDX BOB was sending strange signals resulting in the motors moving abnormally slowly(up to 10x slower than was entered). After the jog rate was corrected in the configurations it ran smoothly.

The script is all in the "left up" section, there are probably more tonumber() functions than are necessary, but I was having some problems and haven't gone back to remove extras as they don't cause any issues.

Code: [Select]
--"Move To" Script

local inst = mc.mcGetInstance()
local hypLength = 0                                
local rateH = scr.GetProperty("droSpeed", "Value")  --Requires DRO named "droSpeed"
local rateX = 0
local rateY = 0
local xJog = scr.GetProperty("droXmove", "Value")   --Requires DRO named "droXmove"
local yJog = scr.GetProperty("droYmove", "Value")   --Requires DRO named "droYmove"
local xNeg = 1
local yNeg = 1

hypLength = tonumber(hypLength)
rateH = tonumber(rateH)
rateX = tonumber(rateX)
rateY = tonumber(rateY)
xJog = tonumber(xJog)
yJog = tonumber(yJog)
xNeg = tonumber(xNeg)
yNeg = tonumber(yNeg)



--Determining if negative values
if(xJog < 0) then
xNeg = -1
math.abs(xJog)
end

if(yJog < 0) then
yNeg = -1
math.abs(yJog)
end


--X Y Rates Calc
hypLength = math.sqrt((xJog^2)+(yJog^2))

rateX = xJog/hypLength
rateX = rateH*rateX

rateY = yJog/hypLength
rateY = rateH*rateY


--Feed rate calcs if single asix travel(100% = 150in/min)
if(xJog or yJog == 0) then
rateH = rateH/1.50
rateH = tonumber(rateH)
rateX = rateH
rateY = rateH
end

--Set jog rate for each axis
rateX = tonumber(rateX)
rateY = tonumber(rateY)
mc.mcJogSetRate(inst, 0, rateX)
mc.mcJogSetRate(inst, 1, rateY)


--Input distance to travel for each axis
xJog = tonumber(xJog)
yJog = tonumber(yJog)
xJog = xJog*xNeg
yJog = yJog*yNeg
mc.mcJogIncStart(inst, 0, xJog)
mc.mcJogIncStart(inst, 1, yJog)

Thanks again for all the help, I hope this can be of use to others as well

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Feed Rate Override Absolute Value?
« Reply #11 on: December 22, 2016, 02:41:24 PM »
Nice! I'lll check out your script later today. Thanks for posting your solution. 
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Feed Rate Override Absolute Value?
« Reply #12 on: January 06, 2017, 04:56:37 PM »
I realized there were some errors in the code posted earlier. Here is an update.


Code: [Select]
--"Move To" Script

local inst = mc.mcGetInstance()
local hypLength = 0                                 
local rateH = scr.GetProperty("droSpeed", "Value")  --Requires DRO named "droSpeed"
local rateX = 0
local rateY = 0
local xJog = scr.GetProperty("droXmove", "Value")   --Requires DRO named "droXmove"
local yJog = scr.GetProperty("droYmove", "Value")   --Requires DRO named "droYmove"
local xNeg = xJog
local yNeg = yJog

hypLength = tonumber(hypLength)
rateH = tonumber(rateH)
rateX = tonumber(rateX)
rateY = tonumber(rateY)
xJog = tonumber(xJog)
yJog = tonumber(yJog)
xNeg = tonumber(xNeg)
yNeg = tonumber(yNeg)
rateH = rateH/1.50


--Determining if negative values
if(xJog < 0) then
--xNeg = xJog
math.abs(xJog)
end

if(yJog < 0) then
--yNeg = yJog
math.abs(yJog)
end


--X Y Rates Calc
hypLength = math.sqrt((xJog^2)+(yJog^2))

rateX = xJog/hypLength
rateX = rateH*rateX

rateY = yJog/hypLength
rateY = rateH*rateY

--Set jog rate for each axis
rateX = tonumber(rateX)
rateY = tonumber(rateY)
mc.mcJogSetRate(inst, 0, rateX)
mc.mcJogSetRate(inst, 1, rateY)


--Input distance to travel for each axis
xJog = xNeg
yJog = yNeg
mc.mcJogIncStart(inst, 0, xJog)
mc.mcJogIncStart(inst, 1, yJog)