CAM Postprocessor Customization/it: Difference between revisions

From FreeCAD Documentation
(Created page with "Il percorso in FreeCAD sarebbe simile a questo. Notate la piccola freccia blu che indica la direzione di partenza. Per un primo tentativo si può fornire solo un livello nel p...")
(Created page with "Puoi quindi dare un'occhiata al file e confrontarlo con l'output di postprocessori esistenti come {{FileName|linux_cnc_post.py}} o {{FileName|grbl_post.py}} e provare tu stess...")
Line 44: Line 44:
[[File:Path PostProcessorModel.png]]
[[File:Path PostProcessorModel.png]]


You can then have a look at the file and compare it to the output of existing postprocessors such as {{FileName|linux_cnc_post.py}} or {{FileName|grbl_post.py}} and try yourself to adapt them or you upload your to the Path forum https://forum.freecadweb.org/viewforum.php?f=15 to get some help.
Puoi quindi dare un'occhiata al file e confrontarlo con l'output di postprocessori esistenti come {{FileName|linux_cnc_post.py}} o {{FileName|grbl_post.py}} e provare tu stesso ad adattarli o caricare il tuo sul forum di Path https://forum.freecadweb.org/viewforum.php?f=15 per ricevere aiuto.


==Convenzione dei nomi==
==Convenzione dei nomi==

Revision as of 16:42, 15 July 2021

Tutorial
Argomento
Ambiente Path
Livello di difficoltà
Tempo di esecuzione
Autori
chrisb
Versione di FreeCAD
Files di esempio
Vedere anche
Nessuno

Introduzione

FreeCAD usa come rappresentazione interna dei percorsi generati i cosiddetti G-codes. Possono descrivere cose come: velocità e avanzamenti, arresto del motore, ecc. Ma la cosa più importante sono i movimenti che descrivono. Questi movimenti sono piuttosto semplici: Possono essere linee rette o archi di cerchio. Curve più sofisticate come le B-spline sono già approssimate dal di FreeCAD. Ambiente Path.

Cosa può fare il postprocessore per voi

Molti fresatrice usano anche i G-codes per controllare il processo di fresatura. Possono assomigliare quasi ai codici interni, ma ci possono essere alcune differenze:

  • la macchina può avere una sequenza di avvio speciale
  • può avere una speciale sequenza di arresto
  • gli archi possono essere definiti con un centro relativo o assoluto
  • può richiedere numeri di linea in un certo formato
  • Può utilizzare i cosiddetti cicli "canned" per sottoprocessi predefiniti come la foratura.
  • Si può preferire l'output del G-code in unità metriche o imperiali.
  • Potrebbe essere utile eseguire una serie di mosse prima di chiamare un cambio utensile per rendere l'azione più facile per l'operatore
  • Potreste voler includere commenti per la leggibilità o sopprimerli per mantenere il programma piccolo
  • Potresti voler includere un'intestazione personalizzata per identificare o documentare il programma per riferimenti futuri.
  • ...

Inoltre ci sono altri linguaggi per controllare un fresatrice, come HPGL, DXF o altri.

Il postprocessore è un programma che traduce i codici interni in un file completo, che può essere caricato sulla vostra macchina.

Preparazione per scrivere il proprio postprocessore

Puoi iniziare con un modello molto semplice che mostri come la tua macchina legge linee rette e archi. Preparalo con qualsiasi programma adatto alla tua macchina.

Un file per tali percorsi che iniziano a (0,0,0) e vanno verso Y sarebbe utile. Assicuratevi che sia l'utensile stesso a muoversi lungo questo percorso, vale a dire che non deve essere applicata alcuna compensazione del raggio dell'utensile.

Il percorso in FreeCAD sarebbe simile a questo. Notate la piccola freccia blu che indica la direzione di partenza. Per un primo tentativo si può fornire solo un livello nel piano XY.

Puoi quindi dare un'occhiata al file e confrontarlo con l'output di postprocessori esistenti come linux_cnc_post.py o grbl_post.py e provare tu stesso ad adattarli o caricare il tuo sul forum di Path https://forum.freecadweb.org/viewforum.php?f=15 per ricevere aiuto.

Convenzione dei nomi

For a file format <filename> the postprocessor should get the name <filename>_post.py. Please note that _post.py has to be in all lower case letters.

If you are testing, place it in your macro directory. If it functions well, please consider providing it for others to benefit (post it to the FreeCAD Path forum) so that it can be included in the FreeCAD distribution going forward.

Altri postprocessori esistenti

For comparison you may look at the postprocessors which come with your FreeCAD installation. They are located under the Mod directory in Path/PathScripts/post. Widely used are the linuxcnc and the grbl postprocessors. Studying their code can give helpful insights.

  • On Linux the path is /usr/share/freecad/Mod/Path/PathScripts/post

Programming your own postprocessor

This post discusses some internals from the linuxcnc postprocessors. The same strucure is used in other postprocessors as well.

Looking at linux_cnc_post.py, you'll see the export function (as of 0.19.20514 its at line 156)

def export(objectslist, filename, argstring):
    # pylint: disable=global-statement
    ...
    gcode = ""
    ...
    ...

it collects step by step in the variable "gcode" the processed G-codes and handles the overall exporting of post-processable objects (operations, tools, jobs ,etc). Export handles the high level stuff like comments and coolant but any objects that have multiple path commands (tool changes and operations) it delegates to the parse function (as of 0.19.20514 its at line 288).

def parse(pathobj):
    ...
    out = ""
    lastcommand = None
    ...
    ...

Similarly to the "export" function collects parse the G-codes in the variable "out". In the variable "command" the commands as seen in the Path workbench's "inspect G-code" function are stored and can be investigated for further processing.

for c in pathobj.Path.Commands:

            command = c.Name

It recognizes the different G, M, F, S, and other G-codes. By remembering the last command in the variable "lastcommand" it can suppress subsequent repetitions of modal commands.

Both parse and export are just formatting strings and concatenating them together into what will be the final output.

You'll see that both functions also call the "linenumber()" function. If the user wants line numbers, the linenumber function returns the string to stick in to the appropriate spot, otherwise it returns an empty string so nothing is added.

Relazioni

Template:Tutorials navi/it Template:Path Tools navi/it