MechMate CNC Router Forum

Go Back   MechMate CNC Router Forum > Computing, Software & Programming > Utility software
Register Options Profile Last 1 | 3 | 7 Days Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old Wed 24 November 2010, 19:37
PEU
Just call me: Pablo
 
Buenos Aires
Argentina
The simplest 4th Axis Wrapper and FREE

I just posted this at CNCzone, I'm sure it will be enjoyed here too

Here you go, the simplest 4th axis wrapper that does the conversion in just one line of piped code, it uses GNU commands, so any user with ANY operating system can use the wrapper.
Since I'm a windows user I used GNUwin version and made a batch file that does some validation on the input parameters, but the gist of the program is just ONE LINE!!!

How do you use it?

Simple: dump all the files in any folder, put the text file with the Gcode in the same folder and launch the wrapper.cmd file with these parameters:

PHP Code:
wrapper <InputFile> <axis> <diameter> <OutputFile
Do not expect fancy windows, this script runs from a DOS box (cmd)

Here is the code:

PHP Code:
@REM WRAPPER.CMD v1.0 2010-11-23 
@REM
@REM Heavylifting (parsingby Daniel Sentinelli
@REM Ideamath and errorchecks by Pablo EUntroib (PEU)
@
REM
@REM USAGEwrapper <InputFile> <axis> <diameter> <OutputFile>

@echo 
off
@SETLOCAL  ENABLEEXTENSIONS

@REM Check if all required parameters are present
  
if [%1]==[] goto :MissingParameter
  
if [%2]==[] goto :MissingParameter
  
if [%3]==[] goto :MissingParameter
  
if [%4]==[] goto :MissingOutput

@REM Check for valid source file
  
if NOT EXIST %goto :MissingInput else 
(
@
REM Check for G2 or G3 movements (these are not allowed)
      
grep -iq G[23] %1
      
if errorlevel 1 goto :MoreChecks
        
goto :NoG2G3
)

:
MoreChecks
@REM Check if axis is X or Y
  
if /[%2]==[Y] (goto :OkProcess) else goto :CheckX

:CheckX
  
if /[%2]==[X] (goto :OkProcess) else goto :WrongAxis


@REM Here we do the heavy lifting (parsingto replace X or Y
:OkProcess

  cat 
%tr [:lower:] [:upper:] | sed "s/\([A-Z]\)/ \1/g ; s/ \+/ /g ; s/^ //g" gawk "{ for (n=1 ; n<=NF ; n++) if (substr($n,1,1)==toupper(\"%2\")) {printf \"A%%f \",substr($n,2)*(114.59155902616464175359630962821/%3) } else {printf \"%%s \", $n}; print \"\" }" >%4
goto :success


@REM Error messages
:NoG2G3
   
echo.
   echo 
ERRORNo G2 or G3 movements allowed
   grep 
-i G[23] %1
   
goto :ProperSyntax

:WrongAxis
   
echo.
   echo 
ERRORAxis should be X or Y
   
goto :ProperSyntax

:MissingParameter
   
echo.
   echo 
ERRORMissing parameters
   
goto :ProperSyntax

:MissingInput
   
echo.
   echo 
ERRORMissing Input Filename
   
goto :ProperSyntax

:MissingOutput
   
echo.
   echo 
ERRORMissing Output Filename
   
goto :ProperSyntax

:ProperSyntax
   
echo Syntaxwrapper ^<InputFile^> ^<or Y^> ^<Diameter^> ^<OutputFile^>
   echo.
goto :
EOF

:success
   
echo.
   echo 
FILE: %4 successfully created!
   echo. 
I tried many files directly out of CAM and they wrapped perfectly, no ARC movements are allowed (g2 or g3) so if your gcode is only g0 and g1 it will work for sure.

If you want to backplot the file in mach3 remember to set the A axis as angular in the general config section and in the settings screen (Alt-6) set the correct rotating radius (diameter/2)


Enjoy!

Download Link: http://dl.dropbox.com/u/3624504/WrapperByPEU.zip (it contains all the needed GNUwin files)


Pablo
Reply With Quote
Reply

Register Options Profile Last 1 | 3 | 7 Days Search Today's Posts Mark Forums Read

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the Y-axis square to the X-axis Gerald_D 20. Gantry 10 Fri 12 October 2012 00:44
Setting A-axis terminal as X2-axis in EMC2 KenC CNC motion control software 2 Wed 27 January 2010 05:40
Cheap wrapper for indexer normand blais CAM 0 Sun 24 January 2010 13:14
CNC Wrapper Software Quiff The Market Place 9 Thu 29 October 2009 09:12
Rotary axis (4th Axis) or Indexer software smreish Graphics & CAD 0 Tue 28 July 2009 06:02


All times are GMT -6. The time now is 16:33.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.