Generating G Code from MDI history log

More
04 Mar 2013 22:04 #30839 by susam
It worked only when I copied all files to the folder of a particular stepconfig that I launch. Where exactly is the .ngc file generated when the "generate" command is executed?

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

More
04 Mar 2013 22:14 - 04 Mar 2013 22:18 #30840 by ArcEye
Hi

Thanks for looking after this John, I've been out.

There are a couple of typos, as you discovered, the attached .zip has them corrected.

However, not when I want to launch the linuxCNC stepconfig does created, it gives and error and doesn't launch.


Not entirely sure what this means you are going to have to post the errors.
You need to edit the .ini file and .hal file manually, and add the custom_postgui.hal file or its contents to your existing file.

I am probably assuming too much knowledge, so a brief run down

splice is a binary and needs to be in your PATH, /usr/local/bin/ is traditional for non-standard executables

The custompanel.xml file creates the buttons and must be named in your .ini file (as per the changes_to_ini file)

The custom_postgui.hal connects the buttons to halui-mdi commands, this file must be named in the .ini and the MDI commands must be in the .ini (as per the changes_to_ini file)
and custom_postgui.hal and custompanel.xml must be in your config folder

The M152 and M153 scripts must be in the directory named in PROGRAM_PREFIX= in your .ini file and must be executable (chmod 755)
For some reason the permissions on M152 keep getting changed when it is zipped.

header.ngc footer.ngc writecords.ngc should all be in that directory too
(You will need to edit M153 so that the paths in the commandline match yours - my directory is ~/emc2/ngc/ but yours may be ~/linuxcnc/nc_files/ or similar)

Work your way through and you will probably find the solution in the above

regards


File Attachment:

File Name: splice.zip
File Size:7 KB
Attachments:
Last edit: 04 Mar 2013 22:18 by ArcEye.

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

More
04 Mar 2013 22:16 #30841 by ArcEye

It worked only when I copied all files to the folder of a particular stepconfig that I launch.


Yeah, that's what you need to do, as per above

Where exactly is the .ngc file generated when the "generate" command is executed?


See M153, both files are generated in /tmp

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

More
04 Mar 2013 22:39 #30846 by BigJohnT
What does slice do exactly? The generated file has a bunch of M100 commands and other stuff in it when I ran it.

John

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

More
05 Mar 2013 00:04 - 07 Mar 2013 00:14 #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

#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: 07 Mar 2013 00:14 by ArcEye.

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

More
05 Mar 2013 01:08 #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
05 Mar 2013 02:26 #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
05 Mar 2013 14:54 #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
05 Mar 2013 16:04 #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
05 Mar 2013 16:10 #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.091 seconds
Powered by Kunena Forum