Hello Guest it is March 28, 2024, 03:07:36 PM

Author Topic: Simple one line MDI required  (Read 6512 times)

0 Members and 1 Guest are viewing this topic.

Re: Simple one line MDI required
« Reply #10 on: May 19, 2018, 05:50:59 PM »
Hi Craig,
That's fair comment, and Mach4 is a massive piece of work that's going to take decades before it repays the effort put into writing it.

I only use the most basic of functions on Mach3, I don't trust it. So far I've had very few accidents, the worst being caused by the way that Mach3 restarts part way through a program. That's just plain dangerous in my opinion and I avoid it if at all possible since I'm never certain what's going to happen.

I need to get my head around the scripting and how to get that to work. I'm struggling to set jog increments and such like to be set from button scripts at the moment, hence another thread about that. I also need to set and clear LED components to work like Radio buttons, but I can't see how to access their properties from other components. Maybe you can't do that, who knows. All the other examples I'm looking at don't attempt to do anything like these things so I don't have much to go on.
Re: Simple one line MDI required
« Reply #11 on: May 19, 2018, 06:12:17 PM »
Hi,

Quote
I only use the most basic of functions on Mach3, I don't trust it. So far I've had very few accidents, the worst being caused by the way that Mach3 restarts part way through a program. That's just plain dangerous in my opinion and I avoid it if at all possible since I'm never certain what's going to happen.
I used Mach3 for making circuit boards and prior to me using Autoleveller, a software utility which is just the best thing for PCB making, would need to replace broken cutters part way
through a job and found like you that I had problem with Run-From-Here. I did eventually cotton on to the logic behind it and thereafter had no problems with PROVIDED you are well and truly
awake and thinking about what you are doing!

You may have noted that Mach4 has a Run-From-Here button. I have refrained from using it. You may also have seen in the API:
Quote
rc = mc.mcCntlDryRunToLine(
      number mInst,
      number line)
I have used that to write my own very VERY simple script to do the same thing but I'm in control of the logic. As it turns out using  Autoleveller has resulted in very few if any broken
cutters so I can decide when to stop the job to replace a worn cutter, which when you choose when it happens is so much easier than responding to something that has already gone
wrong.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Simple one line MDI required
« Reply #12 on: May 20, 2018, 02:50:58 AM »
It's strange that you should have used Mach3 for PCB making because that's the industry I came from. I spent about 15 years designing a dedicated PCB drilling and routing CNC control which is still making circuit boards today. It's a far cry from today's offerings though, it all being based on dedicated Motorola 68000 hardware before PCs were mainstream. I'm no stranger to CNC control.

I'll take a look at the restart setup for Mach4 at some point. At least there's the chance that I could make my own version that wasn't as scary. I'm lucky in that I have a separate quill on my mill, so I can retract that out of the way prior to the restart and then pause to set it back to the right level. It's not ideal, but if I'm desperate then it can be done.
My old CNC has several strategies for restarting, none of which resulted in things getting trashed!

Thanks for the heads up on the API call, I'll take a look when I've got it all running.

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Simple one line MDI required
« Reply #13 on: May 20, 2018, 02:32:01 PM »
What is wrong with Mach4's "Run From Here"?  It works fine for me.  Let me explain what it does.

1.  The first thing it does is do a dry run to and including the line before the selected restart line.  Why?  To get the interpreter state correct.  So if cutter comp was in effect, it would start at the correct offset.  Or any offset, for that matter. 
2.  The dry run is for the interpreter state only, not necessarily the machine state.  If you turned the spindle off, you had better have turned it back on.  Why?  Because you turned it off.  You are master and commander of the machine tool.  And there might not be a line in the G code to tell the control to restart the spindle.  Otherwise, you will drag the cutter through the part and you WILL break something.  At this point, you really can't blame it on the machine control.  :)
3.  Execution will start at the beginning point of the desired line.  If the machine is not already at those coordinates, it will do a feed move to get there.  This includes Z.  This may seem contradictory to the statement above.  But is it?  The last line of the dry run set the starting point of the line.  If the machine is not there, you basically have told the machine to get there. 

Mach doesn't "automatically" restart spindles and such because it has no way of knowing the reason for the run from here.  It could be used to restart a program.  Or it could be used to start a program at a certain place.  You, the operator, know this and it is your responsibility to make sure the machine is in a state to accomplish this.

It is all about understanding what goes on in automatic vs. manual mode.  There is nothing magical about Run From Here.  It will do the same things every time.

Steve
Re: Simple one line MDI required
« Reply #14 on: May 21, 2018, 05:47:26 AM »
+1 on Mach4 start from here. Works much better than Mach3.
As Smurph said, make sure you know where you are and where you want to be before using it.


Mike
We never have the time or money to do it right the first time, but we somehow manage to do it twice and then spend the money to get it right.
Re: Simple one line MDI required
« Reply #15 on: May 28, 2018, 04:23:27 PM »
Just picking up on this, I'd like to at least change the behaviour of the MDI for a number of reasons.

1) I think the combined Cycle Start for both the G-Code and MDI is frankly dangerous because the code is left in the MDI space and can be accidentally executed.
2) I personally don't need multiple lines, I'd much prefer to use Return to execute this, but I appreciate that this probably isn't possible.

So I'm reducing the height of the MDI box and adding a dedicated Run button for that.
The Cycle start button will be stripped of the MDI execute function so it only runs the G-Code when that's visible and never run the MDI
I'd also like to implement a Clear button and possibly clear the MDI box automatically.

The question I have is how can I clear the MDI box from a Button? I think I can now do the rest.
Re: Simple one line MDI required
« Reply #16 on: May 28, 2018, 05:54:19 PM »
Hi,
as you are discovering Mach4 can be customised almost endlessly.

If the MDI is executed from a button script like all Lua functions it will return. You could use the return
event to clear the MDI panel.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Simple one line MDI required
« Reply #17 on: May 29, 2018, 10:41:48 AM »
To give you a little boost try using a Lua Panel from the editor menu and insert the code below

Code: [Select]
local inst = mc.mcGetInstance()
local panel = mcLuaPanelParent
local MyMdi = wx.wxTextCtrl( panel, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxSize( 200,40 ), wx.wxTE_PROCESS_ENTER )

MyMdi:Connect( wx.wxEVT_COMMAND_TEXT_ENTER, function(event)
local mdiCode = MyMdi:GetValue()
--wx.wxMessageBox(mdiCode)
mc.mcCntlMdiExecute(inst,mdiCode)
event:Skip()
end )

Tested and working ;-)

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Simple one line MDI required
« Reply #18 on: May 29, 2018, 04:37:14 PM »
Hi,
as you are discovering Mach4 can be customised almost endlessly.

If the MDI is executed from a button script like all Lua functions it will return. You could use the return
event to clear the MDI panel.

Craig

Hi Craig,
Yes indeed, after a shaky start I'm gradually getting to grips with it. I suppose I'm trying to run before I can walk, but that's the way I tend to do things!

I'm taking a two pronged approach for my screen so that I can have the best of both worlds with a single line MDI and a modified multi-line MDI

For the existing MDI, I'm not quite sure what you mean by your comment.

Do you mean use this script...

scr.ExecMdi('mdi1')

... to execute the MDI? What would the 'return event' be, the next line in the script? Events to me are the things in the Properties Events tab, and I can't see which of those you might mean.

I can't find any documentation about the MDI anywhere except there being an mcCntlMdiExecute() function. There are no events in the MDI Properties->Events so you can't affect the MDI there.

This is the general problem I'm finding with Mach4, there doesn't seem to be much by way of documentation so it's really hard to know how to do something simple like Clear the MDI
On other visual programming environments, things like the MDI box have a List property that you can interact with but there doesn't appear to be anything like that.

Perhaps you could direct me to any MDI documentation I'm missing or perhaps show me the code necessary to clear the MDI box?
Re: Simple one line MDI required
« Reply #19 on: May 29, 2018, 04:41:37 PM »
To give you a little boost try using a Lua Panel from the editor menu and insert the code below

Code: [Select]
local inst = mc.mcGetInstance()
local panel = mcLuaPanelParent
local MyMdi = wx.wxTextCtrl( panel, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxSize( 200,40 ), wx.wxTE_PROCESS_ENTER )

MyMdi:Connect( wx.wxEVT_COMMAND_TEXT_ENTER, function(event)
local mdiCode = MyMdi:GetValue()
--wx.wxMessageBox(mdiCode)
mc.mcCntlMdiExecute(inst,mdiCode)
event:Skip()
end )

Tested and working ;-)

DazTheGas

Hi Daz,
That's absolutely brilliant, I've done that and it pretty much does what I need. I can't see how you would clear the text though after the line has been executed.
I'd also like to know how to read what's in the box when enter is pressed so I can display what was last executed.

I've not used a panel yet, so I need to have a really good look at your code and try to figure out how it works.

Roger