Click here to Skip to main content
Click here to Skip to main content
Go to top

CAM simulator

, 19 Feb 2002
Rate this:
Please Sign up or sign in to vote.
This program shows how a CN machine works

Sample Image - CAM_simulator.gif

Introduction

After 6 months of work, here is finally my first MFC program release. This program is a CAM simulator. I am not a software engineer, so please forgive me for errors. If you have questions please let me know. I am sure that you will find them. The lecture of data files was a big problem to me at the beginning, so here is the implementation. I needed to read *.txt files, what the CNC machine generate. Here is an example M X25 Y23 Z25 SPEED1500. This is a block of data, needed to setup the machines. This is a kind of language that the machine use to move on the coordinates over the work space. So in this implementation you can read a full document, splitting the block in the necessary X Y Z and SPEED values. This is my first upload, I have more things to say about this program I will try to improve soon, this short commentary.

void CProgramaDoc::OnFileOpen() 
{
    CString fichero="archivo de Código G",temp;

    CFileDialog archivos(true,NULL,fichero,OFN_ALLOWMULTISELECT,
        "Codigo G (*.tap)|*.tap|Codigo G (*.act)|*.act||",NULL);

    if (archivos.DoModal() == FALSE) return;
    fichero=archivos.GetPathName();

    CFile cfFile (fichero, CFile::modeNoTruncate | CFile::modeRead);
    CArchive ar (&cfFile, CArchive::load); 

    if(!ar.ReadString(temp))  return;

    nl=0;
    do
    {
        if(temp.GetLength() == 0) continue;
        strcpy(linea[nl],temp);
        nl++;

    }while(ar.ReadString(temp));    

    
    // SEPARANDO COORDENADAS

    int i,j,k,d,sp;
    char aux[30];

    for ( i=0; i<5000; i++)
    {
        x[i] = y[i] = z[i] = 0;
    }    

    kn=0;
    for (i=0;i<nl;i++)
    {
        
        if (linea[i][0]=='S');
        {
            Inicio=1;
        }
        
        if (linea[i][0]=='M');
        {
        sp = 0;
        k = 0;
        d = strlen(linea[i]);

        for (j=0;j<d;j++)
        {
            if ((linea[i][j]=='-')|(isdigit(linea[i][j]))|
                                        (linea[i][j]=='.'))
            {
                aux[k] = linea[i][j];
                k++;
                continue;
            }

            if (linea[i][j]==' ')
            {
                sp++;
                if (sp==1) continue;

                aux[k]=0;

                if (sp==2)
                    if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.'))
                        x[kn] = atof(aux);
                    else
                        x[kn] = x[kn-1];

                if (sp==3) 
                    if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.')) 
                        y[kn] = atof(aux);
                    else
                        y[kn] = y[kn-1];

                if (sp==4)
                    if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.')) 
                        z[kn] = atof(aux);
                    else
                        z[kn] = z[kn-1];

                k = 0;
                continue;
            }            
        }

        kn++;
        j = d;
        }
    }
    
    presentar = 1;

    //    VERIFICANDO TORNO O FRESA

    sumz = 0;
    for (i=0; i<nl; i++)
    {
        sumz += abs(z[i]);
    }

    if (sumz == 0)
        torno = 1;
    else
        fresa = 1;

    UpdateAllViews(NULL);
    
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Diego Andrade
Engineer
United States United States
May 2001 – January 2002 MERCK SHARP & DOHME QUITO, ECUADOR
Project Assistant in the area of Engineering. I am in charge of project 02: Remodeling of the area of Liquids and Laundry: where the syrups Hemocyton and Aurimel are synthesized. I have received courses in Industrial Security and GMP (good manufacturing practices). I designed the systems for vapor, cold, and hot soft water for these areas.

2000 - 2001 GENCO DRAWING SERVICES QUITO, ECUADOR
I created this company that is devoted to the service of drawing of plans in AutoCAD through the Internet. I designed the web page and the promotion systems and publicity. I elaborated the operation procedures. Another part of this company is MiCotizador.com, a database of products and services for contractors and projects, in Quito.
August 1996 – November 2001 Escuela Politécnica del Ejército (ESPE), School of Mechanical Engineering (FIME) , QUITO, ECUADOR
• First prize in a competition of Structures
• Third prize in a Heat Transfer challenge (Adiabatic Processes)
• Attended a seminar on normalized procedures for the assembly of oil facilities
• I have complied with all courses and credits required by the ESPE for the termination of my degree. Upon defending my thesis in November, I was awarded my diploma. My thesis topic was: "Development of a Simulator for Milling and Lathe Machines by means of Numeric Control" for the laboratory of CAD/CAM of the Faculty of Mechanical Engineering.
 
August 2000 Occidental Petroleum Corporation

• One month internship with OXY, Block 15, Sucumbios (in the Ecuadorian Amazon); completed 337 hours of work.
• I spent time in the areas of mechanical maintenance, plant area and finally in automation and control.
 

1990 -1996 SAN GABRIEL HIGH SCHOOL
• I was on the basketball team.
• I actively participated in the competitions a
Follow on   Twitter

Comments and Discussions

 
Question"Unable to open this internet site" is the message I receive upon attempting to download project. PinmemberRedDk16-Apr-14 7:16 
AnswerRe: "Unable to open this internet site" is the message I receive upon attempting to download project. PinmemberRedDk21-Apr-14 10:42 
Generala GCode interpreter written in C/C++ Pinmembermushigang200623-Aug-08 5:55 
GeneralMfc42d.dll PinmemberMember 280963729-May-08 23:57 
GeneralAsk fo open source G code interpreter PinmemberFlower30311-Jul-04 23:41 
GeneralNot IEC or ISO Language PinmemberLFC6-Oct-03 6:18 
QuestionCAM? CN? PinmemberPhilippe Lhoste27-Feb-02 1:49 
AnswerRe: CAM? CN? PinsussAnonymous9-Feb-03 18:39 
GeneralRe: CAM? CN? PinmemberPhilippe Lhoste10-Feb-03 22:48 
GeneralNEW VERSION + OpenGL PinmemberDiego Andrade21-Feb-02 13:03 
GeneralRe: NEW VERSION + OpenGL Pinmemberjiang.j.q16-Feb-05 22:13 
GeneralInteresting work PinmemberJamie Hale21-Feb-02 10:38 
QuestionEnglish? PinmemberMatt Newman20-Feb-02 16:40 
AnswerRe: English? PinmemberMazdak20-Feb-02 20:01 
AnswerRe: English? PinmemberJamie Hale21-Feb-02 10:36 
GeneralRe: English? PinmemberMatt Newman21-Feb-02 11:31 
GeneralRe: English? PinmemberDiego Andrade21-Feb-02 13:00 
GeneralRe: English? PinmemberCathy28-Feb-02 12:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 20 Feb 2002
Article Copyright 2002 by Diego Andrade
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid