AXIS G-code user input - can Glade do it?

More
04 Sep 2014 05:09 #50715 by KGHN
INTRODUCTION TO GLADELOOP PROJECT
My business retrofits electric guitars with a patented joystick volume-selector control circuit. Part of the job is cutting a custom pickguard with the proper hole to serve as the joystick surround, properly placed holes for the pickups, and so on. I am using the GIMP to design the pickguards and export design paths as SVG files, and Inkscape to transform those SVG files into g-code. I then hand-edit the g-code to pause for manual tool changes, issue processing messages, and so on. The router is powered on/off manually, too.
We built a CNC machine (router table 13x13 from Solsylva plans, controller from HobbyCNC connects to PC parallel port), and I am running AXIS 2.6.2 under Ubuntu/linuxcnc.
I have cut a number of pieces and have had to do a fair amount of code-edit kluging. Stop the program, adjust which paths will cut, adjust the depth of the cut, reload & rerun - it's tedious, and easy to lose my place when I'm interrupted.
Some of the cuts are done with conical bits, so precision of cut depth is important. Also, I'm working with acrylic, so to get a smooth beveled edge it works best to do several passes at successive depths.
What I would like to do is have the program ask "Go around again slightly lower?" in some form or another. I need...

USER INPUT WHEN RUNNING G-CODE
LinuxCNC g-code run by the AXIS GUI has no READ command.
User-defined M-codes are M100 .. M199. Haas machines have M109 USER INPUT, but Haas is not willing to sell me a copy.
I tried writing my own M-code module in Bash, but input is redirected when the module is run from g-code.
I looked into writing an M-code module in python. In looking for python tips, I found the PyVCP in the LinuxCNC_Integrator_Manual. It apparently can't be active while g-code is running, but looked like a nice approach, so I looked into a Glade Virtual Control Panel.

Per The Integrator manual p.131(PDF151/361) I opened a terminal, ran linuxcnc, asked for a gladvcp_panel from the configuration selector, copied it to /home/kghn/linuxcnc/configs/sim.axis.gladevcp. This sample setup creates a panel to the right of the preview, and seems active while g-code is running, but is hidden quickly by my g-code's messages. (The tab configuration - gladevcp_tab.ini see p.132 - takes over the Preview pane, and is also hidden by messages. I can stretch window width, but the preview stretches, not the panel. As a refinement later, I hope to try a standalone window.)
I tried making some Glade panels, but got errors trying to launch LinuxCNC with them. I discovered that a compatible .hal needed to be loaded to support them. I made some modifications, and they would launch, but I was unable to access the HAL variables from AXIS. I found some help on the topic:
linuxcnc.org/docs/html/remap/structure.html
has sample code for displaying the HAL (and INI) variables, but my g-code reported that they didn't EXIST. The same document said I needed to turn on a feature of the RS274NGC interpreter in the INI file.
[RS274NGC]
# Use INI (4) and HAL (8) variables from g-code
FEATURES = 12

Now I could read the variables in AXIS, both with MDI commands and displayed by an .ngc program. I have put pauses in the g-code when the operator is supposed to adjust the panel values, then the g-code can be unpaused. This should make it possible to toggle Yes/No rerun a path, and to set how much deeper to go.

However, while a g-code .ngc program is running, it does not seem to read values updated by the panel. The hal values gladevcp.scale-value and so on are read when the program launches, and don't change as the panel is used. When a program isn't running, MDI sees the changes just fine.

Can anyone help me find a "refresh panel values", or create a setup that will update these values along with the regular AXIS set? (The HAL Configuration window displays an updated value if the item is re-selected, but the g-code is still using the old value.)

Please Log in or Create an account to join the conversation.

More
04 Sep 2014 07:01 #50724 by andypugh
Would it be possible to create a GladeVCP button that calls the second loop?
ie, one button for "run the normal cut" and a second one for "if necessary, cut again" ?

(it ought to be possible to enable/disable the buttons using cleverness)

LinuxCNC does tend to get a bit single-minded when running G-code, though I thought that HAL pin values were read-in live when referenced in the G-code.
The following user(s) said Thank You: KGHN

Please Log in or Create an account to join the conversation.

More
04 Sep 2014 07:22 #50726 by KGHN
Thanks, Andy.
>Would it be possible to create a GladeVCP button that calls the second loop?
ie, one button for "run the normal cut" and a second one for "if necessary, cut again" ?
Yes, that's what I'm aiming for, toggling a Run Again? Y/N button. But the running g-code seems to be ignoring any change in the glade panel button's state, even though the HAL Configuration window displays an updated value if the item is re-selected WHILE the program is running (paused). The g-code just keeps using the value it saw when the .ngc program was launched.

>LinuxCNC does tend to get a bit single-minded when running G-code, though I thought that HAL pin values were read-in live when referenced in the G-code.
I gather that specific HAL pin values are read in live (AXIS' default ones), but not the gladevcp group, for example gladevcp.scale-value. I bet there's a list somewhere that I could add the gladevcp pin names to, to make the pin values be updated for the g-code's use, but I haven't found documentation on it yet... Hmmm, perhaps a string search of the linuxcnc files would reveal something.

Please Log in or Create an account to join the conversation.

More
04 Sep 2014 15:25 #50739 by cncbasher
perhaps look at a program called cut2d from vectric , so much easier than all that messing around kludgin this and that , all you need is a decent drawing to cam package
unfortunately iv'e not found a free one

Please Log in or Create an account to join the conversation.

More
04 Sep 2014 22:41 - 05 Sep 2014 04:23 #50769 by KGHN
Hello, cncbasher. I looked at Vectric's products (vectric.com), which produce g-code but require another application, like LinuxCNC, to run it. I have sent them an inquiry about interactive g-code.

I'm producing g-code just fine, and LinuxCNC is working well for me on the non-interactive tasks. What I need is a way to have some interaction with the running g-code program.

Thanks for your suggestion - maybe Vectric will surprise me with a convenient solution.

...edit:
Here's Vectric's answer:
"Thank you for your inquiry.
I am afraid that none of our programs have the interactive feature that you are
looking for.
I am afraid that I am not aware of any CAM programs with this feature.
What you are describing would seem to be more suited to MDI programming."
Last edit: 05 Sep 2014 04:23 by KGHN.

Please Log in or Create an account to join the conversation.

More
03 Oct 2014 07:44 #51743 by KGHN
FOLLOWUP ON INTERACTIVE G-CODE

Hello again, everyone. I'm making progress on my g-code CNC router project, and thought I could share major points I have learned about the interactive use of LinuxCNC programs. (...while I'm still seeing it from a student's perspective.)

It's true: While a g-code .ngc program is running, it ignores value updates made on a Virtual Control Panel (VCP). So, I've turned the relationship inside out, and my GladeVCP panel now launches my g-code. (I have an ENGAGE button that "O<oword> call [{parameter}]" calls the gcode, heh.) The panel-launched g-code program looks at radio button pin values from the panel to see which path I want, and at numeric spinners selecting fudge factor (change depth by how much), and dual-state buttons picking ignore/honor the depth adjustment, fudge lower/higher, do single/gradual cut, and various other treats. That way the panel options can be set as wanted, and a single path carved. Control returns to the panel, which can be adjusted and a rerun initiated, or used to ask for the next path to cut.

I discovered that making the panel wider allows for seeing my important indicators & settings along the left edge while the right edge is covered by processing messages, which limit themselves to a fixed width by wrapping. AXIS' convenient ignore-"/"-lines lets me have a convenient "debug" mode with lots of messages and pauses, and a "production" mode with minimal clutter and delay.

To be able to run a cut multiple times gradually deeper, of course I am using subroutines. G-code can't handle more than one subroutine per disk file. To avoid subroutine files proliferating like rabbits in the disk directory, and being consequently tedious to maintain, I put them all into a single subroutine, that my main program can pass a parameter to indicating which IF - ELSEIF - ELSEIF - ENDIF module I want to run. (Several of these modules also have a tool radius path offset passed.) Values of variables from the "parent" (calling) program can be used by the "child" (called) program. (Global variables can also bring information back to the main program, I think. I'll be testing that soon...)

Since subroutines can be called recursively, I considered including the subroutine modules in the main program, but the panel is passing so many pin value parameters already to the main program, I ran into the 254 character line limit of g-code. (That's a good reason to prefer short pin names in the .ui GladeVCP panel and .hal configuration files.) So I have oword.ngc and owordmodule.ngc to go with GladeProg.ui and GladeProg.hal .

Finally, I realized that doing things this way prevents AXIS from drawing a preview, as the preview predicts what a loaded program will do. (...given the current panel?) Further, the program called by my GladeVCP is not actually Opened by (loaded into) AXIS under normal use.
_ _ Also, even when I comment out the main program's sub/endsub statements and add bracketing %s and load it into AXIS, I don't get a preview of all the cuts that I would like to see.
_ _ So, I have added one further refinement. I created a variable named _display. This is hardcoded =0 in oword.ngc, but I can change it to =1, comment out the bracketing sub/endsub statements, and add bracketing %s. (This variation of the main program is thus hardcoded to be a non-subroutine program.) The 1 value (interpreted as True) triggers an otherwise unused program branch that calls the various path subroutines as single cuts one after another. I Save As the file in this configuration as Display.ngc. When I (Open) load Display.ngc into AXIS, I see my multi-path preview, and it helps AXIS to figure out what space I want it to be looking at in its display area while using this panel. Also, I set the movement speed high on that branch, and can run it as a *simulator* to efficiently check entry and exit points, path shapes and relationships, and so on.

I am hoping to post the set of five files when they are usably functional (more debugged), for others to modify for their own use.

AXIS, GladeVCP and g-code are reliable enough to be really fun. They don't yet have "mature" error messages and documentation to support easy debugging. Programs may just stop running when they hit a syntax error, and sometimes AXIS gives me an undocumented error message. Still, by keeping track of a "known working" example or simple system, and gradually adding individual features and testing after small changes, patience furthers. (Simple test programs to check language features and syntax are also helpful.)

LinuxCNC is really amazingly sophisticated already. The GladeVCP panel looks awesome, and the g-code interpretation software works beautifully to cut our custom electric guitar pickguards. I hope my description of a programming approach will contribute to others' use of this remarkable resource.

Please Log in or Create an account to join the conversation.

More
03 Oct 2014 16:50 #51749 by andypugh

It's true: While a g-code .ngc program is running, it ignores value updates made on a Virtual Control Panel (VCP).


This is a side-effect of the fact that the machine movements are worked out ahead of time so that the machine can keep within acceleration and velocity limits.
Quite often the entire multi-hour run of a program will be completely calculated and queued within seconds of pressing "go". In that framework it is hard to decide when the updated value should be applied.

The way round this, if you want to change a value at run-time is to use the M62-M65 G-code commands to read an input at a specific point in the G-code program. This makes it unambiguous where in the code the new value needs to be read and updated.
The following user(s) said Thank You: KGHN

Please Log in or Create an account to join the conversation.

More
03 Oct 2014 21:14 #51758 by cncbasher
KGHN,
Perhaps post your changes , and show others , might also be a good idea to look at GCMC .
certanly sounds interesting in the way your looking at a problem , and how to solve it .

Please Log in or Create an account to join the conversation.

More
04 Oct 2014 02:25 #51767 by KGHN
Thanks, Andy. Your "why it happens" about the gcode program's not reading the panel is very clear. I looked up M62-M65 in the User Manual and am not able to understand it sufficiently to set up a test program. The manual is talking about outputs, not inputs. I intend to look for some examples when I get a chance, and check the Integrator Manual. I see that something needs to be done in the .hal (and maybe in the panel .ui?) to support the .ngc use. Your post makes me hopeful that there is indeed a way to ask for panel value reads.

Please Log in or Create an account to join the conversation.

More
04 Oct 2014 02:26 #51768 by KGHN
Also thank you, too, cncbasher. What is GCMC? Wikipedia lists five links but none seem applicable. The Startpage search engine also found a number of irrelevant items, and the search on this page also didn't find anything obvious. Would you kindly provide a link, or otherwise clue me in?

Please Log in or Create an account to join the conversation.

Moderators: mhaberlerHansU
Time to create page: 0.153 seconds
Powered by Kunena Forum