Hello Guest it is January 20, 2022, 08:49:17 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 - Tony Bullard

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 »
41
Mach4 General Discussion / Mach4 with Pokeys57CNC and FRO
« on: April 18, 2019, 01:39:05 PM »
I’m trying to set up an analog input in Mach4hobby by following this well written tutorial from Poscope.
https://blog.poscope.com/mach4-tutorial-fro-using-analog-input/   
The registers are setup and showing the analog value as 0 to 1 for 0 to 3.3 volts.
The device name = PokeysCNC_41744. Analog pin = 41.
I have this code in the screen load script.
Code: [Select]
--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)
end

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

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

This is the error I get when saving the screen edit. See picture

It looks like it’s trying to do arithmetic on a string. How can I correct this?

This post seems to use the same code with no problem.
https://www.machsupport.com/forum/index.php?topic=34051.msg238477#msg238477

Thanks for any help.


42
PoKeys / Re: Mach4 Pokeys57E Registers
« on: March 25, 2019, 11:17:07 AM »
Thank you Tom,
That answers all my questions. I should be able to change the value and state of most of those "pins" with code.

43
PoKeys / Mach4 Pokeys57E Registers
« on: March 24, 2019, 02:07:19 PM »
I haven’t installed the Pokeys57E plugin yet because I don’t have the device yet. Will the plugin show the Pokeys registers in the Mach4 Register Diagnostics? Like this picture below.

If so I assume I could get and set the value of the Pokeys pin with code like this:
Code: [Select]
function GetRegister(regname)
local inst = mc.mcGetInstance()
local hreg = mc.mcRegGetHandle(inst,string.format("iRegs0/%s", regname))
return mc.mcRegGetValueString(hreg)
end

--add TB 01-09-18 add Pirce Delay Register value
local inst = mc.mcGetInstance()
local val = mc.mcProfileGetString (inst, "Registers", "PierceDelay" , "nf")
local hreg = mc.mcRegGetHandle (inst, "iregs0/PierceDelay" )
mc.mcRegSetValueString(hreg, val)
--end add

Will changing the pin value change the pin state?

44
PoKeys / Re: PoKeys 57U, Mach4, Buttons and you.
« on: March 24, 2019, 11:15:01 AM »
Thanks Tom,
I just noticed in the Mach4 API there is 150 output and 185 input "pins". I guess I could use an unused function like ISIG_MOTOR31_HOME ,Motor 31 Home, for a custom function. I'm just trying to understand all this before I buy the Pokeys57E, PMDX424 controller, 4 Gecko G320X servo drives and Mach4 license.

Edit: Or is there a way in code to set and get the state of the Pokeys device pin directly? Example please.

45
PoKeys / Re: PoKeys 57U, Mach4, Buttons and you.
« on: March 24, 2019, 09:37:33 AM »
Here's some code for you! You'll need to setup your inputs in your device settings and Mach4 settings then code like this goes in the Screen Start script in the Signal Library section. I included ALL of mine, but it should give you a clue where to start. There's coolant/mist, spindle on, setting speed to 1000 (Mach4 doesn't remember the last speed when shut down so this is a work around for me trying to start the spindle with no speed set!!!) It's commented so you should be able to figure some stuff out for the basics.

Tom

Code: [Select]
---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
    machEnabled = state;
    ButtonEnable()
end,

-- PoKeys pin 9, Mach4 Input 0
-- Physical Cycle Start Button
[mc.ISIG_INPUT0] = function (state)
    if (state == 0) then
        CycleStart()
    end
end,

-- PoKeys pin 10, Mach4 Input 1
-- Physical Feed Hold Button
[mc.ISIG_INPUT1] = function (state)
    if (state == 1) then
        mc.mcCntlFeedHold (0)
    end
end,

-- PoKeys pin 11, Mach4 Input 2
-- Physical Stop Button
[mc.ISIG_INPUT2] = function (state)
    if (state == 1) then
        CycleStop()
    end
end,

--PMDX-108 Port 2 Pin 6 Mach4 Input 10
--HLFB_X ERROR
[mc.ISIG_INPUT10]= function(state)
    if (state==1) then
          mc.mcCntlCycleStop(inst)
          mc.mcCntlSetLastError(inst, "HLFB_X Servo Error")
    end
end,

--PMDX-108 Port 2 Pin 7 Mach4 Input 11
--HLFB_Y ERROR
[mc.ISIG_INPUT11]= function(state)
    if (state==1) then
          mc.mcCntlCycleStop(inst)
          mc.mcCntlSetLastError(inst, "HLFB_Y Servo Error")
    end
end,

--PMDX-108 Port 2 Pin 8 Mach4 Input 12
--HLFB_A ERROR
[mc.ISIG_INPUT12]= function(state)
    if (state==1) then
          mc.mcCntlCycleStop(inst)
          mc.mcCntlSetLastError(inst, "HLFB_A Servo Error")
    end
end,

--PMDX-108 Port 2 Pin 9 Mach4 Input 13
--HLFB_Z ERROR
[mc.ISIG_INPUT13]= function(state)
    if (state==1) then
          mc.mcCntlCycleStop(inst)
          mc.mcCntlSetLastError(inst, "HLFB_Z Servo Error")
    end
end,

----------Mach4 Input 17 PoKeys Pin 17-----
----------Toggle Coolant M8----------------
[mc.ISIG_INPUT17] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,1)
         mc.mcCntlSetLastError(inst, "Coolant On")
     else
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,0)
         mc.mcCntlSetLastError(inst, "Coolant Off")
     end
end
   
end,

----------Mach4 Input 14 PoKeys Pin 14--
----------Toggle Mist M7----------------
[mc.ISIG_INPUT14] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
         mc.mcSignalSetState(OSigMist,1)
         mc.mcCntlSetLastError(inst, "Mist On")
     else
         local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
         mc.mcSignalSetState(OSigMist,0)
         mc.mcCntlSetLastError(inst, "Mist Off")
     end
end
   
end,

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

------------Mach4 Input 7 PoKeys Pin 7------------
------------Set S1000-----------------------------
[mc.ISIG_INPUT7] = function (state)
    if (state == 1) then   
        mc.mcCntlGcodeExecuteWait(inst, "S1000");
mc.mcCntlSetLastError(inst, 'Speed Set to 1000')
    else
        --mc.mcCntlFeedHold (0)
    end

end,

--sample input use that was originally in here!!
[mc.ISIG_INPUT60] = function (state)
   -- if (state == 1) then   
--        CycleStart()
--    --else
--        --mc.mcCntlFeedHold (0)
--    end

end,

Thank you Tom I see how Pokeys pins are associated with and read as Mach4 I/O pins but Mach only has 64 pins. If I had 80 pins on my Pokeys devices how would one read input pin 75?

Thanks for any help.
Tony


46
PoKeys / Re: Mach4 Pokeys 57E with FRO
« on: February 26, 2019, 04:45:14 PM »
Thank you Craig. I see now that SetFRO is the call to the function.

47
PoKeys / Re: Mach4 Pokeys 57E with FRO
« on: February 26, 2019, 01:28:03 PM »
I see now the that the analog value is 0 to 1, not the 12 bit  value of 0 to 4096 so the math is correct.

But what about the last two lines are they VB script for Mach3?

48
PoKeys / Mach4 Pokeys 57E with FRO
« on: February 26, 2019, 12:57:39 PM »
I got the following code from a very well written example in the Pokeys Pluglins manual here:

https://www.poscope.com/wp-content/uploads/downloads/Pokeys/LibrariesAndPlugins/Mach4%20plugin%20user%20manual%20(5.2.2017).pdf

The code is from here:
blog.poscope.com/wp-content/uploads/2016/04/PoKeys_analog_FRO.zip

Code: [Select]
--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)
end

--Main
local device = "CNC controller" --Change this to the name of your PoKeys device
local analogPin = "41" --Analog input pin number

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

The instructions say to put this code almost at the end of the PLC script.
If all is set up properly in Mach4 does this code look like it might work? I’m new to coding but the variables don’t seem to match and the math is incorrect among other things.
Any help would be appreciated.

49
Mach4 General Discussion / A and Y axis machine setup on Mach4 Mill
« on: December 10, 2018, 11:22:32 AM »
The Gcode for the A axis is in degrees and Y axis linear in inches.
The A motor Counts per unit are Counts per degree and the Y motor is Counts per inch. A correct feed rate can’t be established with different types of units. Other software like Mach3 and Haas use the diameter or radius of the A axis work surface to calculate a linear feed rate.  They also have a place in the software to enter that parameter. Is there a way to do this in Mach4?

I’d appreciate any help.
Tony
 

50
Thanks Stuart I just scrolled down to the first one I found.

Tony

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 »