Hello Guest it is April 20, 2024, 10:56:29 AM

Author Topic: Executing Macros during GCode-Runtime  (Read 9584 times)

0 Members and 1 Guest are viewing this topic.

Executing Macros during GCode-Runtime
« on: December 14, 2010, 11:02:52 AM »
Hello Everybody,

iam new to Mach3 and i´ve some simple questions, ok?

1. Is a complete overview or something like that available for the visual elements of the mach3 screens? Or what is the trick to adress(read and write values) fields which are not available via OEM-Code?

2. I need the possibility to execute a macro on every line (or even better a predefined string in a Codeline) of a GCODE(Because we do not want to manipulate the Code before adding it to Mach3). How will i do that? My Idea is to analyse the execution of the gcode via the macropump script. IF GCODE-Line >X the execute my macro. How can i call a seperate macro through the macropump or must be the whole within the macropump-script?
- How will i best do some certain tasks like moving on the Zaxis ->mechanical press action(is this the right term, don´t know it in english)? ---- via "executing new Gcode-Commands" - if so, how will i do that? Can i use the mdi for that? Or is it better to create my own button and press this via macro/macropump?
- How will i do a "break" after each step of the gcode, before executing my task/code? First press Stop-Button, then execute my code, wait for response of machine and the press start button?
- Is it to dangerous to execute external macros via macropump?
- What are the alternatives?
..... iam confused......

Thanks for your help!

Glenn

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Executing Macros during GCode-Runtime
« Reply #1 on: December 14, 2010, 05:54:27 PM »
1. In the VB macro enviroment IF it is not an oem/user  element as defined in the manual then you cannot access that element.

2. You can run a macro on every line if you like. It is a bad idea to call a macro from inside another macro. To run a predifined Gcode segment use the subprogram  approach.

axis motion is controlled via Gcode

You cannot break after each line of code easily. Remember MACH is a Gcode CNC motion controller . It does not always make a good general purpose motion controller.

Yes it can be dangerous to execute an external macro from inside the macro pump. Depends on the machine.  The macro called from the macro does not have time sync and the results can be irratic and unpredictable at times.

Sound like you need a general purpose motion controller.

Just a thought, (;-) TP
Re: Executing Macros during GCode-Runtime
« Reply #2 on: December 15, 2010, 08:54:27 AM »
Hello TP,

first of all - thanks for your answer! But i´ve some further question - can you please help me with that?

1. Manual - ok, what document exactly did you mean? Do you have a link?
2. How can i access(read) the element "Line" in the 1024.set- Screen? It shows the actual gcodeline, but when i open it with the screendesigner, it shows nothing how to access this element (oem: 0, ScanCode:0) only the button "Current G-Codeline" is active -->but how to access that without any ID? Via internal Mach3-functions? But how are their names?
3. What are the differences between elements with oemnumbers and scancodes?
4. Why can´t i break after every gcode-line easily? Via macropump? I think there must be an event or something like that, when a codeline is ended or a new line begins, or not? Or how recognises the above mentioned "Currentline"-Element the lineswitches? Then i can manually stop that gcode from further processing and can execute my code(macro or sub), wait for an answer or signal or something like that, end my sub/macro and start the original gcode-execution - or is there something missing. Isn´t is possible to start an interrupted gcode from the last position?
5. how exactly is a macro called from within the macropump? I think you are right to do it with subs, but it can be interesting generally.
6. General Purpose Controller - no i think Mach3 can do it!
7. do you know a free cam-software(which you prefer), which can be used to extend gcode with some extra lines(After every line, there must be inserted a extra Gcodeline(Axismovment)). I don´t want to write my own VB/C#-Programm to add these lines in a second process. This is my second approach to solve my problems:-)

Thanks in advance!
Glenn

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Executing Macros during GCode-Runtime
« Reply #3 on: December 15, 2010, 10:08:11 AM »
1 the mach3 manual look at teh documentation on the main page

2 you need to look in the Mach VB programmers manual and the Mach customizing manual for details

3 you need to use the OEM/user codes as they are the only ones accessable from VB

4 Breakinbg after each line is NOT easy as mach calculates the line then SENDS it to the buffer. there can be many lines of data in the buffer and once there YOU Have little to no control of the process. LIKE I said mach is a GCODE CNC controller and is designed with that exact process in mind. NOT general motion control. MACH is not a realtime motion controller so there ARE things that cannot be synced properly like a normal realtime motion controller can do.

5 Check the manual

6  Anything is possible to a point BUT is it effective and does it work well (;-) Been there many times just to say it could be done but was not effective in the real world.

7 No, Most cams were dwesigned to interput a drawing into Gcode not solve motion control problems(;-) Even then you would need to develope a custom POST to do the insertion of your additional gcode.

Hope it helps, (;-) TP
« Last Edit: December 15, 2010, 10:11:52 AM by BR549 »
Re: Executing Macros during GCode-Runtime
« Reply #4 on: December 15, 2010, 10:43:00 AM »
Hello TP,

ok.ok.ok.ok....... understand that and keep your words in mind! Thanks!
Two last questions before i read the whole mentoined documentation;-)
1. Even in the Mach3_V3.x_Macro_Prog_Ref.pdf is no reference to the function, how to get the active, processed line from the gcode -->Field "Line" in 1024.set -->how can i read values from it?
2. You said "Mach is not a realtime motion controller" - what does that exactly mean? If i break the processing of the gcode at the end of the e.g. line6 - via macropump(10 times per second, right?) - then process is stopped, right? Or is the process further than i think, because of the buffer etc.? -->will it be better to run in singlestep-mode? Is there a possbility to check via macropump, that gcode-execution is in singlestep-mode and one step is over? Is there a dro that i can use for that? And what will it be?

Thanks in advance
Glenn



Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Executing Macros during GCode-Runtime
« Reply #5 on: December 15, 2010, 11:15:50 AM »
Glen as far as I know you cannot get the processed " line " that is an internal function and we don't have access to it.

To make sure I understand you , you want the current Gcode line of code? before it is processed into moves and loaded into the buffer?

Note:starting and stopping and starting and stopping the Gcode process can be loaded with problems. Mach is not as good at the restarting midprogram thing as it could be. I does work but "I "would NOT trust it as an automated process controlled by VB. For it to work correctly a lot of things need to be recycled as to modal values and such to be successfull.



(;-) TP

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Executing Macros during GCode-Runtime
« Reply #6 on: December 15, 2010, 11:51:24 AM »
Perhaps a better way to do this would be to create a WIZARD that could compile what you need into a Gcode program then run it.

Wizards are covered in the Mach2 customising manual (;-)

Just a thought, (;-) TP