Hello Guest it is April 23, 2024, 07:23:40 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 - abarry54

Pages: 1
1
Mach4 General Discussion / Re: Change jog inc. With lua
« on: July 02, 2015, 09:37:01 PM »
I'm not sure if this is exactly what you are after but look at the thread I started a week or two ago

http://www.machsupport.com/forum/index.php/topic,30346.0.html

I asked for help doing something pretty similar, the Lua command is scr.SetProperty('DroName', 'Value', tostring(variable)) where DroName is what you named the DRO in the screen set and the variable is the value you want displayed. 'Value' should be left as is.

2
Mach4 General Discussion / Re: Custom DRO script
« on: July 02, 2015, 09:19:14 PM »
Well now that that is working... I have another question  :P

I have a macro that has some motion and does some stuff and at the end of it all, I want it to zero out the counter that was just made earlier in this thread.
I have a variable in the PLC script called boardZero which is in my scr.SetProperty to read out to a DRO so at the end of my new Macro script I tried to just put in boardZero = 0

I thought that since the PLC Script works in a loop it would just see that boardZero now is equal to 0 after the macro ran and update the DRO accordingly... but as usual, it doesn't seem to work that easy!
Any ideas?

Thanks!

Adam

3
Mach4 General Discussion / Re: Mach4 Executing Gcode from LUA
« on: July 01, 2015, 03:06:42 PM »
Thanks! Calling the m12() worked smurph (should have guessed that would work  :-[), the execute script function still crashed m4 unfortunately louie, not sure what exactly is the reason.

Is there a cleaner way of piecing together my code aside from:

Code: [Select]
if (state == 1)-- Check States for Board Loader
        then
            mc.mcCntlGcodeExecute(inst, 'G00 X1700.');
            m12();
            mc.mcCntlGcodeExecute(inst, 'G00 X0.');
    end

That code works totally fine, just seems clunky, especially when I have much longer macros planned  :D

4
Mach4 General Discussion / Re: Mach4 Executing Gcode from LUA
« on: July 01, 2015, 02:20:52 PM »
Have any of you run into problems when trying to call a custom M command through this method? I can get it to run regular gcode but the moment I put in say M10 (just activates an output signal) m4 locks up. I wonder if it is because of using a function within my new function..?

The code I am using looks like:
Code: [Select]
function m31() --  Load New Board
    local state, rc = mc.mcSignalGetState(mc.mcSignalGetHandle(0, mc.ISIG_INPUT3)) -- obtain loader signal state
    local inst = mc.mcGetInstance()
    if (state == 1) -- Check States for Board Loader Signal
        then
           --mc.mcCntlMdiExecute(inst, 'M12') -- used for testing (works for a button), freezes upon use
           mc.mcCntlGcodeExecute(inst, 'G00 X1700\nM10\nG00 X0\n') --goes to 1700, then freezes
        else
          -- do nothing
    end
end

m31();

if (mc.mcInEditor() == 1) then
    m31();
end

Any insight is greatly appreciated!

5
Mach4 General Discussion / Re: Custom DRO script
« on: June 30, 2015, 11:03:33 AM »
It works! The ( ' ) before tostring had to be taken out but that's it. 

I need to learn the formatting for Lua and m4, your solution was too simple!

Thanks a lot josh!

6
Mach4 General Discussion / Custom DRO script
« on: June 22, 2015, 04:46:59 PM »
Hi all,

I am looking for a way to create a custom output on a DRO. For instance, I have a bar puller that has two fixed drills attached to it, I would like to display the position of the bar puller (calling it the X Axis) and then on a separate DRO, display the position of the drill relative to the bar puller.

This should be a simple addition on each update: X Axis Position + Drill position relative to X axis 0 (which should never change so it can be hard-coded) but I am having trouble writing this value to the DRO. I was thinking it might be easier to make a few false axis' and do a mcGetAxisPos and then write it to the next axis (Y, Z and A that aren't being used) but I can't seem to get that to work either.

I am also assuming that this code would need to be placed in the DRO update script location, is this the correct place?

I have tried searching the forums and the API with no luck and I am still trying to get a handle on LUA script so any advice would be greatly appreciated!

Thanks!

- Adam


Pages: 1