www.ideegeniali.it

CNC611 - Kit CNC a 3 assi
Cobra 2A
Proxxon MF70 CNC
KITT VoiceBox
Rumorella
Traforo polistirolo
ULP drill-aid per Eagle
GCode Rotator
Robot III
Telecomando per PC
Scacchi e scacchiera
Lampeggiatore 2 led
Alimentatore breadboard
Relais matrix
NiMh Fast Charger
Hdd activity
Molex w/Blue Led

Negozio online
GCode Rotator V0.1b (2005 04 06)

JavaScript GCode Rotator V0.1b (2005 04 06)

LICENSE
GCodeRotator - Offsets, Rotates and Scales GCode programs.
Copyright (C) 2005 Paolo Sancono
Check for updated versions on the WebSite http://www.ideegeniali.it/
Contact the author via email. Find my Email address on my Website

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


IMPORTANT
You should always preserve the above note, expecially the indication
of Paolo Sancono as the script's author and the web site
http://www.ideegeniali.it as the place where to find updated
version of this script if you redistribute copies of this script.
The easyest way is to redistribute this file WITHOUT ANY MODIFICATIONS
I would suggest to link to this instead of copying, so that everyone uses the most up-to-date version.
Remember: CNC Machines are not toys. They can harm you with unexpected movements.
I give no warranties this script will work for you. Use at your own risk.

To use the script, just experiment a little bit by yourself or read detailed info below.
I apologise for my poor English. Please report to me any mistakes. Email found on WebSite.
I apologise for the long intro. Here is the script:


JavaScript GCode Rotator V0.1b (2005 04 06)


Paste Original GCode here
Modified GCode will output here

Reference Point 1 (also center of rotation)
Coordinates in GCode file
X Y
Coordinates on machine
X Y
Delta
DeltaX DeltaY
Reference Point 2
Coordinates in GCode file
X Y
Coordinates on machine
X Y
Rotation Deg Rad
Scale Multiply Divide

Instructions

CNC Machines and GCode

A CNC Machine is a machine whose movements are controlled by numbers sent via a cable usually connected to a PC on which a program runs specifically designed to control the machine. CNC machines are usually used for auto-drilling or engraving purposes.
If you don't own a CNC machine, this script is useless to you. If you own a CNC machine, probably you already know GCode, wich is a simple language to describe machine movements.

I'll just describe some basic commands here, to give you an idea:
% Indicates the beginning of program
M03 Turns on machine's spindle
M05 Turns off machine's spindle
G00 Followed by coordinates indicates a fast movement toward that position
G00 X0.000 Y0.000 An example of G00
G01 Same as G00, but movements are slower (e.g. to allow engraving tool to do its job)
G01 Z-0.5 An example of G01
M30 Program end
T01 Choose Tool #1
... and much more, most of what depending on particular hardware/software!

Usually machines have three axis: X, Y, Z. X and Y are usually on the main plane of the machine, and X and Y axes are the only ones this script deals with. Z is usually the vertical axis, positive values means "ascending".

What will this script do

This script will Translate (offset), Rotate, and Resize GCode. It can do the three things at the same time by specifing coordinates for two reference points, (both old and new values) or by explicitily declaring offset, rotation and scaling factor. You can even choose to specify a mix of the different things. You can specify angles both in radiants and degrees. And you can specify resizing factor as a multiplying or dividing-by one.
Just experiment with Check Boxes (Check the one on side of the option you want to specify) and see values in the other text fields auto-calculated by the script. The button text will also dinamically change to reflect what operations (offset, rotate, resize) will be done with the set of options chosen.

What is this script useful for

It happens often that you want to engrave your object, but it's misaligned with CNC Machine's axes, or it'is a little smaller or bigger than the engraving program you wrote. This is not a concern any more! The easyest way to proceed is this:
  1. Joggle your machine to a reference point on the object (e.g. if it's a PCB board to drill, align your driller with a pad to drill)
  2. Tell the script reference Point 1 coordinates on GCode (i.e. the coordinates for that point in the GCode program) and on Machine (i.e. the coordinates for that point displayed in machine's or controller software's LCD displays).
  3. Joggle your machine to a second reference point on the object. Try to use a point far away from the first one both along X and along Y axis.
  4. Tell the script reference Point 2 coordinates on GCode and on Machine.
  5. Please note that the script auto-calculated DeltaX, DeltaY, Angle of Rotation and Resizing Factor you need.
  6. If there weren't scaling issues but only rotation & offset ones, the computed resize factor should be very close to 1. Probably it's not exactly 1 due to Pc's finite arithmetic (numbers rounding issues) and machine's steps or your eyes finite resolution in pointing the second reference point by joggling. You can just click on "Rotation" check box, so that only rotation and no resizing will be performed on your program, and resizing will be considered to be exaclty 1.
  7. Copy/Paste your original GCode on the left TextArea
  8. Click on the Go! Button and watch your modified GCode on the right Textarea as is being generated by the script.
  9. Wait for the completion message "No errors" or "Errors at lines#".
  10. If there are errors, correct them and click on the Go! Button again.
  11. Copy/Paste your new GCode in your controlling program.

JavaScript

This script is written in JavaScript and tested with Internet Explorer 6.0.
I used only very early standardized JavaScript and Html constructs, so I'm confident that this script should run fine on every Netscape Navigator Version 3+, IE version 3+, Opera version 1+, but I coulnd't test this. Please report to me any browser complaints on my script.

Known issues (Will be fixed in next versions)

I will try to fix known issues in next versions. They are related to parsing and interpreting GCode (i'm not so good at programming parsing algorythms, and don't know all the different fashions GCode can be presented in), rather than actual coordinates conversion (i'm quite sure coordinates conversion is done 100% right by my script).
Here is the list of known issues, with suggested workarounds. Please report to me other bugs I didn't discover yet, or feature request, and I'll try to fix or add them too.
  1. The script considers all coordinates as absolute ones. If your program uses relative coordinates, please convert them to absolute with other programs prior to running this script on it. If you don't, the script will mess up your program
  2. The parser is very simple, and will consider any string containing exactly one X and one Y as a valid command with coordinates to translate. This means, for example, that a script line like "xrays are useful", wich happens to contain exactly one x and one y, will be misinterpreted as a correct GCode and messed up by my script into "xNaNsNaN are useful", where NaN stays for "Not a Number", the predefined JavaScript value for non-number constants forced to be treated as numbers. In such cases, no errors will be reported, because the implemented simple parser at the moment doesn't check for errors.
  3. The script will not handle G command with single axis movements, i.e. GCode lines with only X or Y specified (such movements after rotating coordinates would convert in both X and Y movements, but my script cannot handle them at the moment). The script will leave those lines unchanged but will report as errors lines in which there is a X without Y specified or vice-versa, and will invite you to explicitily specify the missing coordinate for these movements, by manually modifing your GCode program, so that the script can process it correctly.
  4. The parser expects one single command (dealing with X and Y coordinates) on each line, so if your code contains more than one command per line, add carriage returns to your code.
  5. If there's invalid data on the textfields (i.e. not numeric data) expect the script to produce unpredictable results and eventually mess up your code.
  6. The script supports only dots . and not commas , as the decimal separator. You may want to preprocess and postprocess your GCode with a text editor's find and replace to work around this.
  7. The script will produce GCode only 3 digits after decimal point. This has been chosen becouse no CNC machine (afaik) is able of more precision and most GCode interpreters cannot recognize more than 3 digits after decimal point.

Learn more about the way the script works

The name and usage of the parameters should be obvious, but here there are some things you may not grasp at first sight.
  1. Offset (Delta) amount will be auto-calculated if you specify Reference point 1 coordinates on CNC Machine, and this is the easyest way to calculate how much offset you need. However you can work the opposite way: specify the Offset (Delta) you need, and have Ref. point 1 coordinates on CNC machine calculated by the script, just check the checkbox you prefer
  2. Please note that even if you don't need offset adjustment, Ref point 1 coordinates on GCode program must be specified to serve as center of rotation and scaling, if you are using these two features. This means that rotation will be calculated around Ref. point 1 and not origin
  3. You can specify (or let script compute) angles in radiants or degrees, and can have them converted into each others by simply clicking on the corresponding radio-buttons.
  4. Providing coordinates (both on GCode files and on machine) for a second reference point is the easyest way to auto-calculate the amount of rotation and scaling you need. If you prefer, you may however specify directly rotation degrees and scaling factor.
  5. Please note that positive rotation angles are counterclockwise, negative ones are clockwise.
  6. Please note that Resize factor cannot be zero or infinite (common error is to tell the script to trasform the same Ref point's coordinates, specified for Ref#1 and Ref#2, into 2 different points: obviously it's impossible). This is always true, regardless if you are using a multiplying or dividing-by factor.
  7. Always use a dot . as the decimal separator (never use ,) both in GCode and on TextFields. You can preprocess and post-process code with a text editor's search-and-replace functions to work around this.

Greetings

Have fun with this script. And if you find this useful, please seek the time to visit my website www.ideegeniali.it, look for my email address and drop me a few lines. If you had the time to read throughout until now, I'm sure you'll seek the time.









Sito in costruzione