Hello Guest it is April 25, 2024, 11:38:10 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.


Topics - rrc1962

Pages: « 1 2 3 4 5 6 7 8 9 10 11 »
21
Mach4 General Discussion / Huge feedrate error
« on: June 12, 2016, 05:56:16 PM »
Consider the following M code.  It should read the feedrate from a DRO, which is does (300), set the feedrate to 300, move to X5Y5 then back to zero.

Code: [Select]
function m200()
    local inst = mc.mcGetInstance()
    local Feedrate = mc.mcProfileGetDouble(inst, 'PersistentDROs', 'droPLFeedRate', 1)
    mc.mcCntlSetLastError(inst, 'Set Feedrate')
    code2 = 'F ' .. Feedrate .. '\n'
    code2 = code2 .. 'G01 X5 Y5\n'
    code2 = code2 .. 'G01 X0 Y0\n'
    mc.mcCntlGcodeExecuteWait(inst, code2)
end

if (mc.mcInEditor() == 1) then
    m200()
end

It does not set the feedrate to 300IPM.  It sets it to 3IPM.  The Feedrate variable is correct.  Same thing happens if I replace Feedrate with a '300'.  So thinking that I just need to multiply the Feerate variable by 100, I try this...

Code: [Select]
function m200()
    local inst = mc.mcGetInstance()
    local Feedrate = mc.mcProfileGetDouble(inst, 'PersistentDROs', 'droPLFeedRate', 1)
    mc.mcCntlSetLastError(inst, 'Set Feedrate')
    code2 = 'F ' .. Feedrate * 100 .. '\n'
    code2 = code2 .. 'G01 X5 Y5\n'
    code2 = code2 .. 'G01 X0 Y0\n'
    mc.mcCntlGcodeExecuteWait(inst, code2)
end

if (mc.mcInEditor() == 1) then
    m200()
end

This sets the system Feedrate to 9IPM.  Do I have a setting wrong?  Seems like the only code that will run inside mc.mcCntlGcodeExecuteWait is simple.  This one is similar.  The G31 executes but the feedrate is a fraction what it is told to be.

Code: [Select]
function m200()
    local inst = mc.mcGetInstance()
    local Feedrate = mc.mcProfileGetDouble(inst, 'PersistentDROs', 'droPLFeedRate', 1)
    mc.mcCntlSetLastError(inst, 'Set Feedrate')
    code2 =  'G31 Z-2 F100\n'
    code2 = code2 .. 'G92 Z0\n'

    mc.mcCntlGcodeExecuteWait(inst, code2)
end

if (mc.mcInEditor() == 1) then
    m200()
end

The Feedrate is running at 1IPM.  Also can't get any of this to actually run by calling the M code.  It runs in the editor, but not when the M code is called.

22
Mach4 General Discussion / Teach file equivalent
« on: June 02, 2016, 06:17:44 PM »
Is there a tech file equivalent in M4?  Something like the function M3 to write to the teach file, then load it?  If not, I can just write a file using Lua file IO then load that file, but the teach file function in M3 made it real easy.

Thanks

23
Mach4 General Discussion / Run From Here
« on: June 02, 2016, 04:41:37 PM »
Is there a way to determine if the Run From Here button has been pushed?  I need to do that or initiate RFH with a script where I can trun on an LED at the same time.  Then later on I can look for the state of the LED.  I see RFH as an option for button actions, but can't find a function in the API for Run From Here.

Thanks

24
Mach4 General Discussion / Capturing errors
« on: May 29, 2016, 08:48:05 PM »
Is there a way to capture and display errors in a button script.  Problem is that when the script fails, it just doesn't do anything as if it never ran.  The reason why it failed would be immensely helpful.

25
Mach4 General Discussion / Using Modules
« on: May 29, 2016, 03:56:04 PM »
Can't seem to find any documentation covering the basics.  Lets say I have a module "Module1.lua" and it has a function in it called "theFunction()".  Heres what I have so far.  This is the module...

Code: [Select]
local Module1 = {}

function theFunction()
wx.wxMessageBox('Module Test')
end

return Module1

This is the code in a button event that I want to call "theFuntion()"

Code: [Select]
sw = require('Module1')
inst = mc.mcGetInstance()
sw.theFunction()

I suspect the reason it's not working is because the module is not in the right directory...or one or both files need a path specified...or the module needs to be loaded on screen load.  Maybe a combination of these.

Thanks

26
Mach4 General Discussion / M Code Parameters
« on: May 28, 2016, 02:48:05 PM »
Can any one explain why this is happening?  In the code below, it always jumps to ....

mc.mcCntlSetLastError(inst, 'Output out of range' .. 'A' .. x1 .. 'B' .. x2)

Yet x1 does equal 1.  I've tried converting to and from string and number and I either get the same result or M4 just crashes when the M code is called.  The code below runs, but it doesn't recognize that x1 == '1'.  If I change x1 == '1' to x1 == 1, M4 crashes.   mc.mcCntlGetLocalVar is retrieving the correct parameters.  Just can't seem to use them.


Code: [Select]
   if (args ~= nil) then
        x1  = mc.mcCntlGetLocalVar(inst, args, mc.SV_A)
        x2  = mc.mcCntlGetLocalVar(inst, args, mc.SV_B)
        if (x1 == '1') then
            if (x2 == '1') then
                mc.mcSignalSetState(mc.OSIG_OUTPUT1, true)
            else
                mc.mcSignalSetState(mc.OSIG_OUTPUT1, false)
            end    
        else
            mc.mcCntlSetLastError(inst, 'Output out of range' .. 'A' .. x1 .. 'B' .. x2)
        end
    else
        mc.mcCntlSetLastError(inst, 'No Arguments Found')
    end

27
Mach4 General Discussion / M Codes in MDI
« on: May 27, 2016, 05:29:25 PM »
I'm trying to test some M codes in MDI without much luck.  M codes that trigger outputs seem to work fine, but anything to create motion does not work.  See code below.  I tried all of the code execute functions with no luck.  The function is running because last error is updating correctly, just not getting an movement.  If I hit run in the editor, it runs fine.  If I step through the code it runs fine.  It does not work by typing M101 in MDI or by calling M101 in a Gcode file.  The file name is m101.mcs.  What could be wrong to make it run fine in the editor and fail in MDI and gcode?


Code: [Select]
function m101()
    ---------------------------------------------------------------------
    -- GoTo Safe Z
    ---------------------------------------------------------------------
    inst = mc.mcGetInstance()
    mc.mcCntlSetLastError(inst, 'Move to SafeZ')
    local SafeZ = scr.GetProperty('droSafeZ', 'Value')
    local CodeLine1 = 'G00 Z' .. SafeZ
    mc.mcCntlGcodeExecute(inst, CodeLine1)
    --mc.mcCntlMdiExecute(inst, CodeLine1)
    --mc.mcCntlGcodeExecuteWait(inst, CodeLine1)
end

if (mc.mcInEditor() == 1) then
 m101()
end

28
Mach4 General Discussion / Writing to machine.ini
« on: May 26, 2016, 11:48:00 PM »
I'm writing to the ini file for saving persistent DRO's and it works great.  I'm setting up some check boxes using toggle buttons and images and I'm trying to save the state of the button to the ini file on screen unload.  It doesn't work.  It should be saving the button state in the Preferences section, but it's not.  I inserted a message box and it is capturing the button state, just not writing it to the ini.  Code is below.  What am I doing wrong?

inst = mc.mcGetInstance()
val = scr.GetProperty('togCheck1', 'Button State')
mc.mcProfileWriteString(inst, "Preferences", "togCheck1", string.format (val))

29
Mach4 General Discussion / Random Fixture Offsets
« on: May 24, 2016, 09:08:24 PM »
So I set out to make a zero all button and came up with this code....

local inst = mc.mcGetInstance()
rc = mc.mcAxisSetPos(inst,0,0)
rc = mc.mcAxisSetPos(inst,0,1)
rc = mc.mcAxisSetPos(inst,0,2)
rc = mc.mcAxisSetPos(inst,0,3)

What happens is after I make sure that everything is zero and machine is referenced (IE: current pos and machine coord = 0), I run this code and it sets a work offset on X at -3.000 and does not affect Y, Z or A at all.  If I repeat without making sure machine coord is at zero, it will set random numbers as offsets for all axes. 

Anyone seen anything like this?  I don't ever use offsets.  When I run mc.mcAxisSetPos(inst,0,0) it should set current position on X to zero.  Why does it always set X current pos to 3.000 and also set a fixture offset on X to -3.000?  Strange part is that this seems to work on my M4 PC at work, which is licensed, but not here at home, which is in demo mode.

What I want to do is create a button to set current position on all axes to zero, then another button the set machine zero to the same point.

Thanks

30
General Mach Discussion / How does spindle output work?
« on: May 24, 2016, 05:16:42 PM »
I'm setting up the spindle output for something other than a spindle and just need a user variable PWM output to the spindle step pin.  

What triggers Mach3 to begin the PWM pulse train?  

Once the pulse train is started, would I change it using the S word or by entering a value in the spindle speed DRO?

Thanks

Pages: « 1 2 3 4 5 6 7 8 9 10 11 »