Hello Guest it is March 28, 2024, 05:39:57 PM

Author Topic: Manual Spindle Start Switch?  (Read 2043 times)

0 Members and 1 Guest are viewing this topic.

Offline thosj

*
  •  532 532
    • View Profile
Re: Manual Spindle Start Switch?
« Reply #10 on: May 06, 2020, 09:59:06 AM »
PoKeys 57E analog pots. This is in the PLC script, last thing at the end of the file. The two .lua files I have in my Profiles directory so they get copied in with the profile when updating Mach4. They can be anywhere, just point the dofile to the right place.

-------------------------------------------------
--My Stuff!!
-------------------------------------------------
--Runs the PoKeys FRO and SRO lua files as shown!

dofile("C:\\Mach4Hobby\\Profiles\\ESS_New\\PoKeys_analog_FRO.lua")
dofile("C:\\Mach4Hobby\\Profiles\\ESS_New\\PoKeys_analog_SRO.lua")

---------------------------------------------------------------------------

FRO/RRO .lua file

--Function to read value from analog register
function ReadRegister(device, analogPin)
    local inst = mc.mcGetInstance()
    local hreg = mc.mcRegGetHandle(inst, string.format("%s/Analog input %s", device, analogPin))
    return mc.mcRegGetValueString(hreg)
end

--Function to set FRO value
function SetFRO(analog)
    local percent = analog/1*250 --calculate percentage from 0% to 250%
    local inst = mc.mcGetInstance()
    mc.mcCntlSetFRO(inst, percent)
    mc.mcCntlSetRRO(inst, percent) --sets RRO 0% to 250% to follow FRO
end

--Main
local device = "PoKeys57" --Change this to the name of your PoKeys device
local analogPin = "45" --Analog input pin number

analogVal = ReadRegister(device, analogPin) --Save analog register value in variable
SetFRO(analogVal) -- Set FRO value in %

-------------------------------------------------------------------------------

SRO .lua file

function ReadRegister(device, analogPin)
    local inst = mc.mcGetInstance()
    local hreg = mc.mcRegGetHandle(inst, string.format("%s/Analog input %s", device, analogPin))
    return mc.mcRegGetValueString(hreg)
end

--Function to set SRO value
function SetSRO(analog)
    local percent = analog/1*1.0+0.5 --calculate percentage
    local inst = mc.mcGetInstance()
    mc.mcSpindleSetOverride(inst, percent)
end

--Main body -
local device = "PoKeys57" --Change this to the name of your PoKeys device
local analogPin = "44" --Analog input pin number on PoKeys

analogVal = ReadRegister(device, analogPin) --Save analog register value in variable
SetSRO(analogVal) -- Set SRO value in %

I could upload the two .lua files if you'd prefer that!!

I've now made a notepad file to remind me two years from now how I did this!!!

Tom
« Last Edit: May 06, 2020, 10:01:17 AM by thosj »
--
Tom
Re: Manual Spindle Start Switch?
« Reply #11 on: May 06, 2020, 12:27:08 PM »
OK, no longer need a script. PoKey has added pots to the last page of their config dialog. You just select the pin numbers and it works.

Well, it almost works. On my system the Feed pot works, bout only to 100%. The rapid pot is configured the same way and wired the same way, but does not move the slider. I didnt try the spindle, I dont have spindle output on my system.

So again, a Mach feature almost works.

Offline thosj

*
  •  532 532
    • View Profile
Re: Manual Spindle Start Switch?
« Reply #12 on: May 06, 2020, 04:11:41 PM »
You SURELY meant a PoKeys feature that almost works!!! My coded Mach feature works like a champ and is programable for your desired percentage at the same time. Use that;)
--
Tom
Re: Manual Spindle Start Switch?
« Reply #13 on: May 07, 2020, 06:58:41 AM »
Hi Ron,
They are configurable to match what the slider in Mach says. I have SRO, and FRO setup and configured to match the screen sliders, and they both work. When I add a third pot I will setup RRO. It was easy to do but I don't remember exactly where I did the edit to get them to match.

If they give me trouble I will set them up like Thosj has done.

Mike
We never have the time or money to do it right the first time, but we somehow manage to do it twice and then spend the money to get it right.