Generating G Code from MDI history log

More
13 years 7 months ago - 13 years 7 months ago #30854 by ArcEye
Hi JT

splice simply splices together 4 different files to make one .ngc output file

It inserts the header, and then reads the co-ordinates file.
For each set of co-ordinates, it moves to that position and carries out whatever moves were programmed in the mdi_history fragment
When there are no more co-ordinate pairs, it appends the footer, writes out and exits

I used it for multiple drilling operations at pretty random co-ordinates that would not easily fit into a canned cycle.
I just had to map the co-ordinates by moving to the centre punch marks, optically aligning and saving them.

Then I did the first drilling operation in MDI and saved that

Then run splice and it creates the file to do the same operation at each co-ordinates

It is not a polished routine, just what I needed at the time and a demonstration of something that is possible

The code is below

regards

Code:
#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 <fcntl.h> /* File control definitions */ #include <errno.h> /* Error number definitions */ #include <qfile.h> #include <qstring.h> #include <qtextstream.h> int main(int argc, char **argv) { QString cord_file, mdi_file, ngc_file, header, footer; // these are just to make debugging easier, not really used if(argc < 5) { puts("Usage: splice header footer co-ordinates mdi-history output-file"); return(1); } QFile hdr(header = argv[1]); QFile ftr(footer = argv[2]); QFile cfile( cord_file = argv[3] ); QFile mfile( mdi_file = argv[4] ); QFile nfile( ngc_file = argv[5]); if ( hdr.open( IO_ReadOnly ) && ftr.open( IO_ReadOnly) && cfile.open( IO_ReadOnly ) && mfile.open( IO_ReadOnly ) && nfile.open( IO_WriteOnly )) { QTextStream hstream( &hdr); QTextStream fstream( &ftr); QTextStream cstream( &cfile ); QTextStream mstream( &mfile ); QTextStream nstream( &nfile ); while(!hstream.atEnd()) nstream << hstream.readLine() << "\n"; while(!cstream.atEnd()) { nstream << "G00 " << cstream.readLine() << "\n"; while(!mstream.atEnd()) { nstream << mstream.readLine() << "\n"; } mstream.device()->at( 0 ); } while(!fstream.atEnd()) nstream << fstream.readLine() << "\n"; hdr.close(); ftr.close(); cfile.close(); mfile.close(); nfile.close(); } else { puts("Error: Unable open a specified input file"); return(1); } return(0); }
Last edit: 13 years 7 months ago by ArcEye.

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

More
13 years 7 months ago #30862 by BigJohnT
Ok, that is what confused me my MDI history has a bunch of stuff in it.

Thanks
John

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

More
13 years 7 months ago #30871 by susam
Hi,

Thanks to both of you. It is really helpful. This is the exact objective I want to achieve using linuxCNC.

1. To create a .ngc file by recording the MDI history and jog positions for a single module (this module is actually a PCB with IC's that are to be grinded on the surface).
2. Now this module repeats along both axes (X and Y). Thus, there is a big board with a number of models that repeat.
3. So, basically I want to jog around the path for the initial grinding operation (on the first module) and automatically generate a .ngc file to repeat it along both axes with a gap of say around 12mm (that is each module is say located at 0mm, 12mm, 24mm etc along X and along Y)

Please let me know if this will be possible with the current scope of the algorithm that you constructed.

Thanks.

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

More
13 years 7 months ago #30898 by susam
The 'Generate' button still isn't working. I changed the directories in M153, however no files seem to be generated yet. Could you advice me on this?

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

More
13 years 7 months ago #30901 by ArcEye
Without seeing what you have done I have no idea.

Run M153 from the commandline, does it work?
If not your paths are wrong or permissions or the binary is not in the PATH, error message will give a clue

Run M153 from the MDI commandline in Axis, does that work?
If not, permissions are wrong, is not in the PROGRAM_PREFIX= directory, you are entering m153 and it is called M153 or similar
Again error messages.

If these work your button is not connected, or connected properly.

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

More
13 years 7 months ago #30903 by ArcEye

So, basically I want to jog around the path for the initial grinding operation (on the first module) and automatically generate a .ngc file to repeat it along both axes with a gap of say around 12mm (that is each module is say located at 0mm, 12mm, 24mm etc along X and along Y)


What you describe sounds like a canned drilling cycle where you grind away some PCB instead of drilling

If the distances are regular, you can achieve what you want with a couple of subroutines in G Code, one to increment along the axes and the other to do the grinding operation.

My use for this set up was with completely random hole centres, copy punched through from an original that I was replicating.

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

Time to create page: 0.078 seconds
Powered by Kunena Forum