- Posts: 16
- Thank you received: 0
Generating G Code from MDI history log
13 years 7 months ago #31272
by susam
Replied by susam on topic Re:Generating G Code from MDI history log
Hi, I'v got another small query. I created the following pyvcp elements to go along with 'mark co-ordinates' and 'generate'(as seen in the attachment).
Now, when I click on the 'Mark Coordinates', apart from writing the coordinates to the text file, is it possible to display it in the labelframe - 'Last Mark-Coordinate' (please refer to the attached screenshot)?
If yes, I guess it is through accessing connections as in the custom_postgui.hal file through an external command. Please advice on this.
Thanks.
Now, when I click on the 'Mark Coordinates', apart from writing the coordinates to the text file, is it possible to display it in the labelframe - 'Last Mark-Coordinate' (please refer to the attached screenshot)?
If yes, I guess it is through accessing connections as in the custom_postgui.hal file through an external command. Please advice on this.
Thanks.
Please Log in or Create an account to join the conversation.
13 years 7 months ago #31273
by susam
Replied by susam on topic Re:Generating G Code from MDI history log
Please Log in or Create an account to join the conversation.
13 years 7 months ago - 13 years 7 months ago #31277
by ArcEye
Replied by ArcEye on topic Re:Generating G Code from MDI history log
Hi
Well as far as implementing the number displays, I think you need to use 3 number display widgets inside a hbox
linuxcnc.org/docs/2.5/html/hal/pyvcp.html#_number_displays
I think the label text is pretty well static and you want something that displays formatted floating point automatically.
This is getting to a point where it would be easier to write a single user-space program to do it all, rather than try to cobble on another bit
of G Code / halui / bash script.
You would still use a pyVCP panel but the pins are directly connected to a program that does the actions
I will have some time tomorrow, leave it with me and I will see what emerges.
regards
Well as far as implementing the number displays, I think you need to use 3 number display widgets inside a hbox
linuxcnc.org/docs/2.5/html/hal/pyvcp.html#_number_displays
I think the label text is pretty well static and you want something that displays formatted floating point automatically.
This is getting to a point where it would be easier to write a single user-space program to do it all, rather than try to cobble on another bit
of G Code / halui / bash script.
You would still use a pyVCP panel but the pins are directly connected to a program that does the actions
I will have some time tomorrow, leave it with me and I will see what emerges.
regards
Last edit: 13 years 7 months ago by ArcEye.
Please Log in or Create an account to join the conversation.
13 years 7 months ago - 13 years 7 months ago #31333
by ArcEye
Replied by ArcEye on topic Re:Generating G Code from MDI history log
Hi
I have written a user space component for you called plot, which will considerably simplify the setup and usage of the co-ordinate logging and creating a gcode file from them using splice
The zip file has the different elements set out as if in a tarball, ie you need to navigate to the directory named and deposit the contents into it.
Then start Linuxcnc and select the entry called plot from the config-picker dialog.
This will start a simulator with the elements installed.
All that is required then is to copy the gcode routine you wish to be carried out at each co-ordinates to a file called /tmp/operation.ngc
Then jog to wherever you want to start and click 'Mark Co-ordinates' and again at each point required.
Then click 'Generate File' and then 'Load' and the created gcode file will be loaded into Axis.
(NB click the buttons deliberately and move the mouse off them afterwards, pvVCP can sometimes 'stick' a button if the mouse remains on it)
Screenshot shows output, if you want to preserve it, need to save as something else in your gcode directory before you close the computer, contents of /tmp are volatile.
Once you have tried the sim you can use the files as a guide to integrate into your own config.
Hope it does what you want
regards
I have written a user space component for you called plot, which will considerably simplify the setup and usage of the co-ordinate logging and creating a gcode file from them using splice
The zip file has the different elements set out as if in a tarball, ie you need to navigate to the directory named and deposit the contents into it.
Then start Linuxcnc and select the entry called plot from the config-picker dialog.
This will start a simulator with the elements installed.
All that is required then is to copy the gcode routine you wish to be carried out at each co-ordinates to a file called /tmp/operation.ngc
Then jog to wherever you want to start and click 'Mark Co-ordinates' and again at each point required.
Then click 'Generate File' and then 'Load' and the created gcode file will be loaded into Axis.
(NB click the buttons deliberately and move the mouse off them afterwards, pvVCP can sometimes 'stick' a button if the mouse remains on it)
Screenshot shows output, if you want to preserve it, need to save as something else in your gcode directory before you close the computer, contents of /tmp are volatile.
Once you have tried the sim you can use the files as a guide to integrate into your own config.
Hope it does what you want
regards
Last edit: 13 years 7 months ago by ArcEye.
Please Log in or Create an account to join the conversation.
13 years 7 months ago - 13 years 7 months ago #31334
by ArcEye
Replied by ArcEye on topic Re:Generating G Code from MDI history log
Code for plot component for those interested
Warning: Spoiler!
Code:
/*
Component for use with the splice utility to produce gcode from
a set of co-ordinates marked with pyVCP button
*/
component plot;
pin in float xposition "Receives current position from Xpos";
pin in float yposition "Receives current position from Ypos";
pin in float zposition "Receives current position from Zpos";
pin in bit trigger = 0 "Triggers writing co-ordinates to file";
pin out float lastx "Outputs last X position plotted";
pin out float lasty "Outputs last Y position plotted";
pin out float lastz "Outputs last Z position plotted";
pin in bit splice = 0 "Triggers splicing together gcode";
pin in bit load = 0 "Triggers loading of generated gcode";
option singleton yes;
option userspace yes;
author "ArcEye";
license "GPL";
;;
#include <stdio.h> /* Standard input/output definitions */
#include <stdlib.h>
#include <stdint.h> /* Standard types */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <errno.h> /* Error number definitions */
#include <signal.h>
int done = 0;
void adios(int sig)
{
done = 1;
}
void user_mainloop(void)
{
char coordfile[] = "/tmp/cords.txt";
FILE *fptr1;
int triggered, spliced, loaded;
signal(SIGINT, adios);
signal(SIGTERM, adios);
// prevent cycling whilst button depressed
triggered = spliced = loaded = 0;
while(!done)
{
usleep(100000);
FOR_ALL_INSTS()
{
if(trigger && !triggered)
{
fptr1 = fopen(coordfile, "a");
fprintf(fptr1, "X%08.03f Y%08.03f Z%08.03f\n", lastx = xposition, lasty = yposition, lastz = zposition );
fclose(fptr1);
triggered = 1;
}
else if(splice && !spliced)
{
system("splice /usr/share/splice/header.ngc /usr/share/splice/footer.ngc /tmp/cords.txt /tmp/operation.ngc /tmp/output.ngc");
spliced = 1;
}
else if(load && !loaded)
{
system("axis-remote /tmp/output.ngc");
loaded = 1;
}
else // ensure button released before zeroing flag to allow pressing it to register again
{
if(!trigger && triggered) triggered = 0;
if(!splice && spliced) spliced = 0;
if(!load && loaded) loaded = 0;
}
}
}
exit(0);
}
Last edit: 13 years 7 months ago by ArcEye.
The following user(s) said Thank You: susam
Please Log in or Create an account to join the conversation.
13 years 7 months ago - 13 years 7 months ago #31544
by susam
Replied by susam on topic Re:Generating G Code from MDI history log
Thanks!..
I am writing a G-code generator in java...(as I'm more comfortable with it). I will try to integrate these elements through that piece of code. I hope it works out....to integrate java into such an environment.
Regards
I am writing a G-code generator in java...(as I'm more comfortable with it). I will try to integrate these elements through that piece of code. I hope it works out....to integrate java into such an environment.
Regards
Last edit: 13 years 7 months ago by susam.
Please Log in or Create an account to join the conversation.
Time to create page: 0.081 seconds