Generating G Code from MDI history log

More
31 Mar 2012 16:18 - 31 Mar 2012 16:21 #18889 by ArcEye
Hi,

'To build a better mousetrap' ( or just do the same thing differently for the sake of it! )

I decided to take a different tack and added some functionality which hopefully will come in useful for other things too.

In the unknown but definitely irregularly spaced holes, each requiring multiple drilling operations, scenario, it works thus.

Manually jog to each hole position in turn and when aligned press pyvcp button [Mark Co-ordinates].
This will save the current co-ords to a file /tmp/cords.txt. Repeat for each hole.

Clear the MDI history and enter the g code commands necessary to drill a single hole (either for real or in fresh air).
Last command needs to be a movement to a Safe Z height.

In ~/emc2/ngc there should be 2 files header.ngc and footer.ngc. These contain the standard preparatory and terminating g code for your operations.
The header can contain the spindle start up, speed and coolant commands followed by a move to Safe Z, to save having this all in MDI history and repeating each hole.

Pressing the pyvcp [Generate] button creates a file consisting of header, move to first co-ords, mdi commands for operation, move to next co-ords, operation ... etc until all co-ords used and finally footer.

The engine behind the file creation is a C++ QT3 program I called 'splice' which takes all the file names as command line arguments and splices them together to make the final g code file. (this could be a bash script or python prog. I just find it easier to think in C / C++)

[Mark Co-ordinates] button is linked to halui.mdi-command.0 ,which calls <writecords> a g code subroutine to get co-ords, then calls M152 to write them to file.

[Generate] button is linked to halui.mdi-command.1, which calls M153, which calls splice with all the relevant file names as arguments

Screen capture 1 shows MDI window with code for one hole and trace where hole co-ords have been captured.



Screen capture 2 (next post) shows resulting plot from generated file.

Overall just demonstrates the power and flexibility of both LinuxCNC and Linux itself, using a combination of HAL, g code, user M codes and a binary to achieve a degree of automation.

I think I may be building upon the co-ordinate capture at some point in the future to do basic 'teach' routines.

Feel free to 'borrow with pride' if any of it appeals.

regards

File Attachment:

File Name: splice.zip
File Size:7 KB
Attachments:
Last edit: 31 Mar 2012 16:21 by ArcEye.
The following user(s) said Thank You: susam

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

More
31 Mar 2012 16:22 #18890 by ArcEye
Screenshot 2
Attachments:

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

More
04 Mar 2013 19:44 #30828 by susam
Hi,

I am quite new to linuxCNC. I was looking for a way to record jog positions. Somewhat similar to what you have mentioned. However, I am unable to use the solution you provided. When I press the "Mark Co-ordinates" or "Generate" buttons, nothing happens. No .txt file is generated in the temp folder etc. It will be of great help if you could provide with a more detailed step by step guide to use this.

Thanks a lot!

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

More
04 Mar 2013 20:43 - 04 Mar 2013 21:00 #30830 by BigJohnT
The changes_to.ini has POSTGUI_HALFILE = custom_postgui.hal listed under [DISPLAY] and it should be in the [HAL] section.

The sub writecoords.ngc calls M122 and I don't see that file in the zip.

The M153 file has what looks like some hard coded directories to ~emc2/ngc/header.ngc etc. I assume that needs to be changed to where the files are...

John
Last edit: 04 Mar 2013 21:00 by BigJohnT.

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

More
04 Mar 2013 20:52 #30831 by susam
The changes_to.ini has POSTGUI_HALFILE = custom_postgui.hal listed under [DISPLAY] and it should be in the [HAL] section.

- It is under [HAL] section too. The error I get is:

" Unable to open file <writecords> "

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

More
04 Mar 2013 21:05 #30832 by BigJohnT
I created a directory called splice and placed all the files in there. I changed the ini to point to that location.
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
SUBROUTINE_PATH = /home/john/linuxcnc/splice
USER_M_PATH = /home/john/linuxcnc/splice

I edited the writecords.ngc file and changed M122 to M152.

John

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

More
04 Mar 2013 21:10 - 04 Mar 2013 21:11 #30833 by BigJohnT
Running M153 I get splice: command not found... so I assume that needs to be copied to a bin or changed to ./splice...

That works now to change the paths to the header and footer files...

John
Last edit: 04 Mar 2013 21:11 by BigJohnT.

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

More
04 Mar 2013 21:13 #30834 by BigJohnT
I changed the M153 file to:
#!/bin/bash
./splice header.ngc footer.ngc /tmp/cords.txt ~/.axis_mdi_history /tmp/op.ngc
exit 0

and it now runs... now to find the output file...

John

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

More
04 Mar 2013 21:16 - 04 Mar 2013 21:19 #30835 by BigJohnT
Ok, the last parameter is the output file so set it to the location and name you want.

For some reason the generate button does not work yet but running ./M153 from a terminal does.

John
Last edit: 04 Mar 2013 21:19 by BigJohnT.

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

More
04 Mar 2013 21:51 #30836 by susam
Thanks John. I did it according to your instructions. However, not when I want to launch the linuxCNC stepconfig does created, it gives and error and doesn't launch. I guess I still have some issues with the .ini file.

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

Time to create page: 0.103 seconds
Powered by Kunena Forum