Hello Guest it is March 29, 2024, 05:28:42 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Cal892

Pages: 1 2 »
1
For references here is my code to change from X,Y axes to X,Y,A,B axes

Code: [Select]
------------4 Axis Mapping-----------
inst = mc.mcGetInstance()
local xAxis = 0
local yAxis = 1
local aAxis = 3
local bAxis = 4
xAxis = tonumber(xAxis)
yAxis = tonumber(yAxis)
aAxis = tonumber(aAxis)
bAxis = tonumber(bAxis)

--motorId, rc = mc.mcAxisGetMotorId(number mInst, number axis, number childId)
local motorIdX, rc = mc.mcAxisGetMotorId(inst, 0, 0);
local motorIdY, rc = mc.mcAxisGetMotorId(inst, 1, 0);
local motorIdA, rc = mc.mcAxisGetMotorId(inst, 0, 1);
local motorIdB, rc = mc.mcAxisGetMotorId(inst, 1, 1);


--rc = mc.mcAxisUnmapMotor(number mInst, number axisId, number motor)
mc.mcAxisUnmapMotor(inst, 0, motorIdX) --Unmap from X axis
mc.mcAxisUnmapMotor(inst, 1, motorIdY) --Unmap from Y axis
mc.mcAxisUnmapMotor(inst, 0, motorIdA) --Unmap motor 2 from X axis
mc.mcAxisUnmapMotor(inst, 1, motorIdB) --Unmap motor 3 from Y axis

--rc = mc.mcAxisMapMotor(number mInst, number axisId, number motorId)
mc.mcAxisMapMotor(inst, 0, 0)    --Map motor 0 to X axis
mc.mcAxisMapMotor(inst, 1, 1)    --Map motor 1 to Y axis
mc.mcAxisMapMotor(inst, 3, 2)    --Map Motor 2 to A axis
mc.mcAxisMapMotor(inst, 4, 3)    --Map motor 3 to B axis

--rc = mc.mcAxisEnable(number mInst, number axisId, number enabled)
mc.mcAxisEnable(inst, 3, true)  --Enable A axis
mc.mcAxisEnable(inst, 4, true)  --Enable B axis

--rc = mc.mcProfileSave(number mInst)
mc.mcProfileSave(inst)


Code: [Select]
-------------2 Axis Mapping-------------
inst = mc.mcGetInstance()
local xAxis = 0
local yAxis = 1
local aAxis = 3
local bAxis = 4
xAxis = tonumber(xAxis)
yAxis = tonumber(yAxis)
aAxis = tonumber(aAxis)
bAxis = tonumber(bAxis)


--rc = mc.mcAxisUnmapMotor(number mInst, number axisId, number motor)
mc.mcAxisUnmapMotor(inst, xAxis, 0) --Unmap motor 0 from X axis
mc.mcAxisUnmapMotor(inst, yAxis, 1) --Unmap motor 1 from Y axis
mc.mcAxisUnmapMotor(inst, aAxis, 2) --Unmap motor 2 from A axis
mc.mcAxisUnmapMotor(inst, bAxis, 3) --Unmap motor 3 from B axis

--rc = mc.mcAxisMapMotor(number mInst, number axisId, number motorId)
mc.mcAxisMapMotor(inst, xAxis, 0)    --Map motor 0 to X axis
mc.mcAxisMapMotor(inst, yAxis, 1)    --Map motor 1 to Y axis
mc.mcAxisMapMotor(inst, xAxis, 2)    --Map Motor 2 to X axis
mc.mcAxisMapMotor(inst, yAxis, 3)    --Map motor 3 to Y axis

--rc = mc.mcAxisEnable(number mInst, number axisId, number enabled)
mc.mcAxisEnable(inst, aAxis, false)  --Disable A axis
mc.mcAxisEnable(inst, bAxis, false)  --Disable B axis

--rc = mc.mcProfileSave(number mInst)
mc.mcProfileSave(inst)

2
So after working with Mach support I've found that it is possible to use the mcAxisMap and mcAxisUnmap to modify the axis mappings.
The trick is to save or flush the profile at the end of the script using either mcProfileSave() or mcProfileFlush()

Unfortunately it is not possible to edit the pins that each motor has assigned for homing. As I am using a PMDXsmartBOB this is necessary to change from a 2 axis home to a 4 axis.

I've been continually working on this and found that mach can be homed with the 4 axis configuration and then switched to 2 axis without issue (unless you try to home it without changing back)

The problem there is that the changes must be done manually as far as I can tell. Every time I try to home in the middle of a script I can't get it to wait until the homing is complete before continuing. any code after the fact is run immediately and my attempts at pausing/waiting until it's complete with loops seem to cause it to disregard the remaining code entirely.

Does anyone have any tips on how to automatically run code after the homing is complete. I've also tried editing the PLC script and the screenload script to no avail.

3
Mach4 General Discussion / Re: Feed Rate Override Absolute Value?
« 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)

4
Thanks Craig,
I've been experimenting as well, but without much luck.
I haven't been able to successfully un-map or re-map the axis yet. Also running into difficulties with modifying the home switch input values.

I'm going to open a support ticket and see if Mach can offer any help. I'll update the thread with Mach's suggestions.

Cal

5
Thanks Craig, I wasn't aware of the mcAxisMotor. It's not listed in the motor commands in the API.
I'll give it a shot and update after.

6
Mach4 General Discussion / Re: Feed Rate Override Absolute Value?
« 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

7
Mach4 General Discussion / Re: Feed Rate Override Absolute Value?
« on: December 21, 2016, 04:13:04 PM »
Thanks for the help Daz and Chaoticone, got it working well now

8
I'm running a CNC hotwire and require all axes to be homed independently (essentially gantry squaring). The PMDX Smart BOB unfortunately does not support homing slaved motors so we currently have to run two separate profiles of Mach4, one just for homing of all the axes every day. I read in the forums that someone had tried to create a script to decouple the motors and re-map them but haven't found anything past the rumors.

I looked through the API and found mcMotorGetAxis(), however I don't see any method of setting or changing the axis label. Is it possible to edit the axis that motors are assigned to through lua scripting? Possibly through some other sort of IO commands?

I haven't been able to do testing on modifying the home switch labels, however I believe I can do it using mcIoSetState() to modify the "Home 2 Motor" input. Please correct me if I am wrong, I'm new to lua but understand scripting and coding.

Any input is appreciated.

9
Mach4 General Discussion / Re: Feed Rate Override Absolute Value?
« on: December 16, 2016, 02:25:51 PM »
Thanks for the tips however I'm not looking to change the jog rate, just the feed rate. Perhaps I'm not seeing what you're trying to tell me. I'm aware that I can edit the go to zero function to have any specific feed rate I like, but I need to change that feed rate frequently so coding it into the button isn't the best option.

Your example seems to show that I can pull a user entered value from a DRO, but I'm not sure how to change the feed rate with that value. I don't think I can edit the mcCntlSetFRO function to accept an absolute value instead of a percentage. I also don't think I'm able to use a variable in an mdi code.

The only option that I'm seeing is to create individual buttons with mdi commands for each feed rate I would like to use. A possibility, but not an ideal solution.

10
Mach4 General Discussion / Re: Feed Rate Override Absolute Value?
« on: December 16, 2016, 01:25:03 PM »
Thanks for the help,

I didn't fully understand Daz's original suggestion, I'm not used to being able to edit the pre-defined functions at will.

Pages: 1 2 »