Hello Guest it is April 18, 2024, 01:05:30 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 - thespindoctor

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 »
1
Mach4 General Discussion / Re: activate script on button from script
« on: September 30, 2021, 01:58:04 PM »
Thanks Steve

2
Mach4 General Discussion / Re: activate script on button from script
« on: September 30, 2021, 09:11:11 AM »
This is the proper script!

function WaitForIdle()
   local inst = mc.mcGetInstance()
   local state = mc.mcCntlGetPoundVar(inst, mc.SV_MSTATE)--Returns the Machine State
   --Idle will return 0
      if (state == 0) then
      return true
   else
      return false
   end
end

3
Mach4 General Discussion / Re: activate script on button from script
« on: September 28, 2021, 01:03:57 PM »
function WaitForIdle()
    local inst = mc.mcGetInstance()
    local state = mc.mcCntlGetState(inst)
    if (state == mc.MC_STATE_IDLE) then
         return true
    else
    return false
   end --added end here
end

is this better but I think it still fails I will try both

4
Mach4 General Discussion / Re: activate script on button from script
« on: September 28, 2021, 12:58:36 PM »
function WaitForIdle()
    local inst = mc.mcGetInstance()
    local state = mc.mcCntlGetState(inst)
    if (state == mc.MC_STATE_IDLE) then
         return true
    end
    return false
end

I think I tried the inst without success, but will try again   thanks

5
Mach4 General Discussion / Re: activate script on button from script
« on: September 28, 2021, 08:32:14 AM »
function WaitForIdle()
    local state = mc.mcCntlGetState()
    if (state == mc.MC_STATE_IDLE) then
         return true
    end
    return false
end

cant get this to work  tried lots of stuff but it will not compile

thanks

6
Mach4 General Discussion / Re: activate script on button from script
« on: September 23, 2021, 12:46:04 PM »
How about using register flags like switches on the old machines before CNC

have reg1, reg2, reg3.  0=off 1=on

reg1 on and reg2 and reg3 off means automatic testing started go ahead and do G code move

reg1on and reg2 on and reg3 off means G code move finished so ok to record from analog inputs then when finished recording turn reg3 on

reg1,2,3 on means done and now save data and switch reg2 and 3 off indicating back to G code move


7
Mach4 General Discussion / Re: activate script on button from script
« on: September 20, 2021, 06:55:59 PM »
Steve and Daz, Back in 2016 I was helped with the same issue of how to set up an Mcode in Mach4. Steve has listed the steps again but it does not work for me.  I am not sure where I am failing but back in 2016, Daz listed putting the require line into a module load file in the profile/macros directory which Steve did not mentioned this time.  Is this an omission or a change in the version of Mach4? I think I have done everything else correctly but the Mcode programmed M100 never does anything.  I have stepped away from Mach4 and Lua for several years and am back trying to get proficient again, sorry.

I updated to the newest version today since I was running on a version from 2016 but that has not helped.  The post dealing with the topic was topic=33849.20  This time, we are taking about a toolbox which I would like to implement.  Should I start a new topic or continue here. I also am working on Steve's last help for machine state, but not successful yet.

Thanks

8
Mach4 General Discussion / Re: activate script on button from script
« on: September 19, 2021, 01:57:47 PM »
Thanks so much Steve!  Trying to wrap my head around it. Still hampered by lacking some basic skills.
There are 3 events to deal with
  1.) Move the plate with Gcode in degrees then after completed
  2.) turn on recording - then turn it off after 5 seconds
  3.) Save the data collected to the open array and save the file
repeat

Each step has to be completed before the next.  I will start as simple as possible to see if I can get the machine states concept to work.

Still not getting Mcode to work either despite following your explicit example.  Not sure what I am doing wrong.  Just trying to get a wx.messagebox to activate through an M code.  Set up my own ToolBoxmodule but not successfully.  Lots of trial and error and gradually getting familiar.

9
Mach4 General Discussion / Re: activate script on button from script
« on: September 18, 2021, 10:39:04 AM »
So far not having luck with the basic problem.  I see how to put functions into the script load which works fine and is definitely a better way to organize my programming.  However the issue now is that I need to move the motor which tilts a plate that a person is standing on.  Then the motor pauses and waits in that position while recording values from analog sensors in the PLC program.  When the recording is done, the array is added to an open file.  Now repeat a motor move and record again.

So I need to move to 0 degrees, let the PLC record for 5 seconds, save the data array to the open file, move 2 degrees and repeat.  What happens is in the script, all the G code moves execute so the plate goes on to 0,2,4,6 degrees without stopping to let the PLC record and at the end of all the moves, the recording starts.  No matter what I have tried from G4, while loop, to timer it will not wait.  I figured the while loop would be perfect to have the G move the while the global variable startrecording = "on" do nothing then save the values when startrecording = "off" but it just goes through all the programmed G moves. 

What am I missing?  Seems like a simple issue I am not understanding.

So PLC has the routine to sample the analog sensors 10 times a second for 5 seconds.  startrecording is a global variable controlled from a screen button with startrecording="on" and PLC turns it off after 5 seconds controlled by monitoring sweeps.  It all works great when I use separate buttons to control each move and record but combining everything into one script in one button is not working.

Thanks

10
Mach4 General Discussion / Re: activate script on button from script
« on: September 17, 2021, 05:04:50 AM »
Thanks so much Steve! I am devouring your post to understand and it will definitely up my game..

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 »