Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: striplar on May 17, 2018, 04:35:56 PM

Title: Simple one line MDI required
Post by: striplar on May 17, 2018, 04:35:56 PM
Can someone point me in the direction of a simple one line MDI implementation like there was in Mach3? I much prefer the way you could type a single command and hit enter to execute it.

There doesn't seem to be a property that can be set to execute on Enter, or to limit the number of lines to 1

Any help would be much appreciated.
Title: Re: Simple one line MDI required
Post by: joeaverage on May 17, 2018, 07:54:15 PM
Hi,
the short answer is no.

As it stands you are required to type your MDI code in the MDI window. I presume you are happy with that,
its similar to going to the MDI tab in Mach3.
If you hit <enter> you will start a new line in the MDI window, so you can have multi-line MDIs, quite handy.
Once your MDI code is complete then you are required to issue a MDIExexcute() command and for that purpose
the Cycle Start button is provided.

If you find hitting the Cycle Start button on screen inconvenient it would be possible to assign a spare keyboard
key and have that key execute the MDI. Clearly <enter> is used in other manners would not suitable, every time
you hit it an MDI would execute whether you intended it not.

Does that sound like a reasonable work-around?

Craig
Title: Re: Simple one line MDI required
Post by: smurph on May 19, 2018, 03:08:40 AM
Ctrl-Enter will execute the MDI.

Steve
Title: Re: Simple one line MDI required
Post by: striplar on May 19, 2018, 03:54:06 PM
Hi,
the short answer is no.

As it stands you are required to type your MDI code in the MDI window. I presume you are happy with that,
its similar to going to the MDI tab in Mach3.
If you hit <enter> you will start a new line in the MDI window, so you can have multi-line MDIs, quite handy.
Once your MDI code is complete then you are required to issue a MDIExexcute() command and for that purpose
the Cycle Start button is provided.

If you find hitting the Cycle Start button on screen inconvenient it would be possible to assign a spare keyboard
key and have that key execute the MDI. Clearly <enter> is used in other manners would not suitable, every time
you hit it an MDI would execute whether you intended it not.

Does that sound like a reasonable work-around?

Craig

Thanks Craig. That's a real pain because I use the one line and hit enter MDI on Mach3 all the time and this just isn't that convenient. Heaven knows why they changed it, if I need something in several lines of g-code I use a temporary program.
I'll put in a feature request. All it needs is a single property that says single or multi line in the MDI component and then everyone it happy.
Title: Re: Simple one line MDI required
Post by: striplar on May 19, 2018, 03:54:36 PM
Ctrl-Enter will execute the MDI.

Steve
Thanks for that Steve.
Title: Re: Simple one line MDI required
Post by: joeaverage on May 19, 2018, 04:01:43 PM
Hi,

Quote
Heaven knows why they changed it, if I need something in several lines of g-code I use a temporary program.
Funnily I find exactly the opposite, I often stack several lines and let it rip....As a matter of reflex I often end up hitting <enter> only to remember
that it doesn't work in the manner that it used to, but so what, there are a lot of things which don't work like they used to but they work so much
better now!

Craig
Title: Re: Simple one line MDI required
Post by: striplar on May 19, 2018, 04:37:08 PM
Hi,

Quote
Heaven knows why they changed it, if I need something in several lines of g-code I use a temporary program.
Funnily I find exactly the opposite, I often stack several lines and let it rip....As a matter of reflex I often end up hitting <enter> only to remember
that it doesn't work in the manner that it used to, but so what, there are a lot of things which don't work like they used to but they work so much
better now!

Craig
As it happens, you can do that in the Mach3 single line MDI too, you don't need a dialog box for that functionality
Title: Re: Simple one line MDI required
Post by: joeaverage on May 19, 2018, 04:52:00 PM
Hi,
Quote
As it happens, you can do that in the Mach3 single line MDI too
Yes, I seem to remember stumbling over that when using Mach3 but it was quite a while ago now. I personally find the structured approach adopted by
Mach4s developers to be very much more comprehensible than the amorphous chunk of code that Mach3 became.

Indeed its my understanding that Mach3 having become on amorphous block of code made further development extremely difficult, you fix one fault only to find
that you have broken some other seemingly unrelated item, thence the decision to write a completely new program...Mach4.

Craig
Title: Re: Simple one line MDI required
Post by: striplar on May 19, 2018, 05:08:57 PM
I couldn't agree more about Mach3, it grew into a monster. Mach4 is a different animal, but it's frustrating to find that things I used to take for granted now can't be done that way. I'm also struggling to get the old pendant to work, despite a kind forum member writing a basic driver for it. Setting up used to be dead easy, and now it's a pain in the neck until I work out ways round these issues.

I foolishly thought I'd just download Mach4 and start using it, but it's been painful, what with the backlash compensation ESS only just being implemented correctly.

Such is life, at least you can customise Mach4 and rip out all the stuff you don't need. I don't mind putting a bit of effort in to get it how I need it to be, but I don't want to spend months on that when I have jobs that need machining. I might have to go back to Mach3 in the interim until I can beat Mach4 into the shape I want it.
Title: Re: Simple one line MDI required
Post by: joeaverage on May 19, 2018, 05:32:42 PM
Hi,

Quote
Mach4 is a different animal, but it's frustrating to find that things I used to take for granted now can't be done that way
That very much sums up the way many feel about transitioning to Mach4 from Mach3. What I remind people is that Mach4 is NOT Mach3 and
wont ever be so. Over a period of time there were all sorts of tricks and workarounds in Mach3 that were employed and we all became familiar with them
without realizing that they were a total 'kludge'.

Mach4 has done away with all those hacks. In most cases you can replicate, or come close to replicating, the same behavior with Mach4 by programming
it so. The programming itself imposes a structure based set of restrictions and so you are extremely unlikely to break something else as would be the case
in Mach3.

To date there are few manufacturers who have invested the time and effort (read....money) into writing Mach4 plugins for their pendants. CNCVista is the only
one I know of where the business did it of their own volition. The XHC plugin was written by a couple of enthusiasts, no doubt with XHC support but not
the business itself.

Have a look at Daz's Xbox 360 plugin, it might fit the bill really well. In addition you have the ability to contribute to the ongoing development of it rather than
purchasing from a business.

Craig
Title: Re: Simple one line MDI required
Post by: striplar 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.
Title: Re: Simple one line MDI required
Post by: joeaverage 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
Title: Re: Simple one line MDI required
Post by: striplar 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.
Title: Re: Simple one line MDI required
Post by: smurph 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
Title: Re: Simple one line MDI required
Post by: TOTALLYRC 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
Title: Re: Simple one line MDI required
Post by: striplar 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.
Title: Re: Simple one line MDI required
Post by: joeaverage 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
Title: Re: Simple one line MDI required
Post by: DazTheGas 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
Title: Re: Simple one line MDI required
Post by: striplar 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?
Title: Re: Simple one line MDI required
Post by: striplar 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
Title: Re: Simple one line MDI required
Post by: DazTheGas on May 29, 2018, 05:41:56 PM
MyMdi:SetValue("") after mc.mcCntlMdiExecute(inst,mdiCode) will clear the txt and mc.mcCntlSetLastError(inst,mdiCode) will add the txt to the message box.

DazTheGas
Title: Re: Simple one line MDI required
Post by: striplar on May 30, 2018, 05:20:00 PM
MyMdi:SetValue("") after mc.mcCntlMdiExecute(inst,mdiCode) will clear the txt and mc.mcCntlSetLastError(inst,mdiCode) will add the txt to the message box.

DazTheGas
Many thanks Daz, I'll try that out as soon as my current job is finished and I can tinker with it.

Is there a list of all the MyMidi: function calls? I couldn't really see how this works if I'm being honest. It's a lot to take in having only been playing with this for a couple of weeks.
Roger
Title: Re: Simple one line MDI required
Post by: DazTheGas on May 30, 2018, 05:47:18 PM
MyMidi is not a function as such, its just a name that has been assigned to an instance of wxTextCtrl, things like GetValue and SetValue are functions of this class, so to get a list of the functions contained in this class you would need to look at something like http://docs.wxwidgets.org/3.1/classwx_text_ctrl.html
Although this is for C++ the function names etc are the same for wxLua.

DazTheGas
Title: Re: Simple one line MDI required
Post by: striplar on May 31, 2018, 06:24:46 AM
Thanks for that Daz, more bedtime reading for me then. That site looks like a good resource, I've bookmarked that.

The code does exactly what I want, it's even better than the Mach3 MDI which wouldn't take any notice of what you typed unless the pop up box was visible. This works straight away with whatever you type, and it's ready for the next command to be typed as soon as the previous one has executed. It ignores anything you type and press enter if the previous command isn't complete which is fine.
I've kept the default mulit-line MDI for anything that might benefit from more than one line being executed. It's just a pity that you can't hit a check box along side the MDI to select single or multi line mode.

There's just one more MDI modification I'd like to do. I'd like a Clear button next to the Multi-Line MDI to clear out the text. Is there a way to do that?

Title: Re: Simple one line MDI required
Post by: striplar on May 31, 2018, 06:37:47 AM
Anyway, moving on to the next bug which is in the Feedrate and Spindle realtime DROs on the Mach4Mill screen.

Both of these have the same issue. All the time the machine is moving and the spindle is running, both of these flicker all the time, mostly reading zero, but you can just make out that they're also flashing up the correct values from time to time.

The dro144 component has DRO Code set to Current Feed Rate, and the droTrueSpindle component has DRO Code set to Spindle True RPM

I've searched through the ScreenScript for the component name and also anything to do with the words DRO and feed and there's nothing in there.

So my guess is that this is another bug and the variable is repeatedly set back to zero for some reason.

I'm using an ESS, so maybe that's somehow involved.

I've looked in dignostic->Regfile to see if I can see a variable there that represents this value, but I don't see one or anything flicking.  Again, a lack of documentation about these variables makes it difficult to check something like that.
I can see the first #variables but I have no idea whether it's one of those or not.

Any ideas how to fix this?
Title: Re: Simple one line MDI required
Post by: DazTheGas on May 31, 2018, 02:08:43 PM
It ignores anything you type and press enter if the previous command isn't complete which is fine


I have given you the bare min to get you started, consider adding to the code things like if the controller state is not idle disable the ability to execute another command, as for clearing any control of txt you can use the scr. api commands to do this.

DazTheGas
Title: Re: Simple one line MDI required
Post by: striplar on May 31, 2018, 03:55:07 PM
It ignores anything you type and press enter if the previous command isn't complete which is fine


I have given you the bare min to get you started, consider adding to the code things like if the controller state is not idle disable the ability to execute another command, as for clearing any control of txt you can use the scr. api commands to do this.

DazTheGas
Thanks Daz, will do.