Hello Guest it is April 26, 2024, 02:24:25 PM

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 - thosj

141
Mach4 General Discussion / Re: Manual Spindle Start Switch?
« 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

142
Mach4 General Discussion / Re: Manual Spindle Start Switch?
« on: May 06, 2020, 09:24:48 AM »
Hmmmm.....no script in my PMC folder. I'll have to go look how they work!! Trouble with all this customization stuff is you struggle and get it working and two years later you don't remember how the hell you did it;) I'll be back.

143
Mach4 General Discussion / Re: Manual Spindle Start Switch?
« on: May 06, 2020, 07:27:22 AM »
I do it but with a PoKeys 57E which has inputs for analog pots, pins 44 and 45 if memory serves. So I just wired pots, one for spindle speed and one for feed override. I don't think I had to write any code, might just be in PoKeys plugin/software. The feed override also overrides rapid, so you can pretty easily control things!! I'm old fashioned and ran machines in the real world with pots to control feed/speed, so I will NOT run a machine without those two things. The new kids laugh, but I prefer sneaking up on the first part rather that replacing broken cutters. My Kurt vises don't have cutter marks on top!!!

144
Sound advice from Craig there, as usual. I go a step beyond. When I'm going to install a new version of Mach4, I rename the Mach4Hobby folder to something like Mach4Hobby_4322. Then I install the new version which creates a new Mach4Hobby directory. I then open two explorer windows and copy over my license, profile, screenset, plugins, docs, and maybe modules (I don't have any custom modules currently, tho'). If anything goes haywire, I can just rename folders to get back.

I go a step beyond and whenever I'm going to try something new, I copy the entire Mach4Hobby folder off to a different drive or network location for safe keeping. If I think of it I do this once in a while just for extra safety to always have a known, working copy of the entire Mach4Hobby directory I can simply copy back to C:\. Might be just me, but I fantasize that I NEED the machine to work so I do belt and suspenders!!

145
Mach4 General Discussion / Re: New Forum!
« on: April 29, 2020, 08:02:00 AM »
Try Mach General Discussion, back one level, the one tight above this one.

146
Mach4 General Discussion / Re: Manual Spindle Start Switch?
« on: April 27, 2020, 01:09:37 PM »
No.....that momentary button, with that code, toggles........like the code comment says.......one press, spindle on, next press, spindle off. You do need a speed active, and Mach4 starts up with zero speed. So an S1000 or some such via MDI or gcode. I actually put some code in my RefAllHome script to set the spindle speed as in Mach3 it was remembered between sessions and I never shook that, always assuming a speed was there on Mach4 startup and it isn't:)

147
Mach4 General Discussion / Re: Manual Spindle Start Switch?
« on: April 27, 2020, 08:43:14 AM »
I do it in the Screen Start Script, Signal Library. A button, momentary, is wired to an input, in my case a Pokeys 57E, and the code is in the Signal Library. It IS a toggle. You need to setup the input for whatever input you're using, BOB, PoKeys, whatever. PMC might be easier, you don't have to write the code, but the code ain't much!!

My code:

------------Mach4 Input 8 PoKeys Pin 8----------------
------------Toggle SpinCW-----------------------------
[mc.ISIG_INPUT8] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 1) then
         mc.mcSpindleSetDirection(inst, 0);
     else
         SpinCW()
     end
end

end,

Tom

148
I would think PWM would be good enough, but to be honest, I have not found enough quality guidance on how to properly configure this with the VFD.  My HY manual does not even reference PWM..........

Does your VFD manual mention control via 0-10v? The VFD isn't "controlled" by PWM, PWM on the BOB controls 0-10v output which, in turn, controls the VFD.

Tom

149
Mach4 General Discussion / Re: Screwcutting issue under Mach4
« on: March 31, 2020, 11:16:57 AM »
OP has the latest version of the ESS plugin, v253, which IS about 4 months old, so that's likely not going to fix him up.

150
Mach4 General Discussion / Re: MACH4 MACHINE Z WILL NOT ZERO ON HOMING
« on: March 20, 2020, 06:35:17 PM »
Can't help with the Z issue, but the best way to install a new version of Mach4 and NOT lose your settings is:

Rename the Mach4Hobby directory to something memorable.
Install the newest version from scratch, it will create a new Mach4Hobby directory.
Now go to your old directory, the one with the memorable name, and copy over your Profile, Screenset, any macros, anything else that's peculiar to your old setup over to the new directory.
Wallah, set to go with the new version.

I've done it dozens of times, works like a charm always, and...........you can revert by simply renaming directories if you need/want to. You might also consider making a backup of the entire Mach4Hobby directory to another hard drive or network location once in a while, like before updating to development versions or anything you might consider "risky". Belt and suspenders, don't you know!!!

Tom