Project:RELaserSoftware/MOL file format: Difference between revisions

From London Hackspace Wiki

Minor new findings, making the description sufficient to generate sane .MOL files. Used in VisiCut and soon in QCad.
(Minor new findings, making the description sufficient to generate sane .MOL files. Used in VisiCut and soon in QCad.)
Line 34: Line 34:
== Status ==
== Status ==


We have a pretty good understanding of the file format to the point that we can generate new MOL files from a dxf drawing, at least for cutting patterns on the test machine. This is for cutting only, no raster engraving and other features yet!
We have a pretty good understanding of the file format to the point that we can generate new MOL files from a dxf drawing, at least for cutting patterns on the test machine. This is for cutting only, no raster engraving and other features yet! The engraving process uses different commands, which I found surprising, because the commands for cutting would be sufficient. Raster engraving is not covered here,


== The File Format ==
== The File Format ==


The file format is binary, using LSB 4-byte words. The floating point format is not IEEE, so
The file format is binary, using LSB 4-byte words. The floating point format is not IEEE, so
a conversion is required. All files have four chunks at fixed locations:
a conversion is required. All files have four chunks at a location described in the header:


* the header chunk starts at 0 and contains 32 words, followed by 0's, followed by the locations of the following blocks
* the header chunk starts at 0 and contains 32 words, followed by 0's, followed by the locations of the following blocks
* the config chunk is at 0x00000200 and contains informations about the total artwork (this block may start somewhere else. See header.)
* the second chunk is the config chunk and is usually located at 0x00000200. It contains informations about the total artwork (this block may start somewhere else. See header.)
* the test chunk is at 0x00000400 and moves the laser head on the bounding box of the artwork (this block may start somewhere else. See header.)
* the third chunk is the test chunk and is usually at 0x00000400. It moves the laser head on the bounding box of the artwork (this block may start somewhere else. See header.)
* the draw chunk is at 0x00000A00 contains all commands to output the actual drawing and cutting commands (this block may start somewhere else. See header.)
* the fourth chunk is the cut chunk and is usually at 0x00000600. It cuts the artwork a few millimeters around the bounding box (this block may start somewhere else. See header.)
* the fifth chunk is the draw chunk and is usually at 0x00000A00. It contains all commands to output the actual drawing and cutting commands (this block may start somewhere else. See header.)
* the file is then patched to the next 512 byte boundary
* the file is then patched to the next 512 byte boundary


Line 58: Line 59:


This is called when the "Test" button is pressed on the panel. It moves the laser head around the bounding box of the artwork and is a great help for positioning the material. In this file, it is simply a bunch of line drawing commands.
This is called when the "Test" button is pressed on the panel. It moves the laser head around the bounding box of the artwork and is a great help for positioning the material. In this file, it is simply a bunch of line drawing commands.
== The Cut Chunk ==
This is called when the "Cut Outline" menu is selected and contains a setup part followed by a list of machine control commands that cut around the bounding box.


== The Draw Chunk ==
== The Draw Chunk ==
Line 95: Line 100:
* 00000010: 0x00000029 somehow related to the file size or the number of commands
* 00000010: 0x00000029 somehow related to the file size or the number of commands


Four booleans, setting the second value will make the artwork top right relative to the user-set origin. If it is zero, the origin is the center of the work table (not quite though!).
Four booleans, setting the second value will make the artwork relative to the user-set origin. If it is zero, the origin is the center of the work table (not quite though!).
* 00000014: 0x00000001 ?
* 00000014: 0x00000001 ?


Position of the artwork in steps (divide by 208.33 to get millimeters? This seems to be 0 at all tested files, and seems to have no impact on the cutting.
Extent of the artwork to the top right from the origin in steps (divide by 208.33 to get millimeters). This is only used to verify that the artwork fits the machine and will cause an alarm if origin plus this value is outside of the work surface.
* 00000018: 0x00000000
* 00000018: 0x00000000
* 0000001c: 0x00000000
* 0000001c: 0x00000000


Size of the artwork in steps (divide by 208.33 to get millimeters (depending on the machine configuration))
Extent of the artwork to the bottom left from the origin in steps.
* 00000020: -20833 artwork width in steps
* 00000020: -20833 artwork width in steps
* 00000024: -20833 artwork height in steps
* 00000024: -20833 artwork height in steps


Unknown, fixed value
Unknown!
* 00000028: 0x00481095 ?
* 00000028: 0x00481095 ?


Unknown, fixed value
Unknown!
* 0000002c: 0x471a0000 ?
* 0000002c: 0x471a0000 ?


Line 115: Line 120:
* 00000030 - 0000006c
* 00000030 - 0000006c


Location of the 200 block. This is the n'th block, block size is 512 bytes. The 200 block contains general data about the artwork.
Location of the config chunk. This is the n'th block, block size is 512 bytes. The 200 block contains general data about the artwork.
* 00000070: 0x00000001  
* 00000070: 0x00000001  


Location of the 400 block. This block is called when the user presses "Test" on the CMD03 and outlines the artwork.
Location of the test chunk. This block is called when the user presses "Test" on the CMD03 and outlines the artwork.
* 00000074: 0x00000002 ?
* 00000074: 0x00000002 ?


Location of the 600 block. This block is called when the users selects "Cut File" (or so) from the menu.
Location of the cut chunk. This block is called when the users selects "Cut File" (or so) from the menu.
* 00000078: 0x00000003 ?
* 00000078: 0x00000003 ?


Location of the A00 block. This block is called when the users presses "Start".
Location of the draw chunk. This block is called when the users presses "Start".
* 0000007c: 0x00000005 ?
* 0000007c: 0x00000005 ?


Line 152: Line 157:
* arg4 is the acceleration value to get to the above speed (space acc)
* arg4 is the acceleration value to get to the above speed (space acc)
* arg5 is the value for acceleration from the settings
* arg5 is the value for acceleration from the settings
* arg6 is unknown and nowhere to be found, probably the slow acceleration default
* arg6 is the acceleration when going from vector to vector
* 0000022c: : unknown 05:  603, 1041(5.00%), 41666(200.00%), 145833(700.00%), 104166(500.00%), 72916(350.00%)
* 0000022c: : unknown 05:  603, 1041(5.00%), 41666(200.00%), 145833(700.00%), 104166(500.00%), 72916(350.00%)


Line 166: Line 171:


Object origin. Cutting a 100x100 object on a 900x600 table would move the laser head
Object origin. Cutting a 100x100 object on a 900x600 table would move the laser head
to the top right corner of a centered work piece. (772 see "move rel")
to the top right corner of a centered work piece.
* 00000264: : unknown 07: 772, x:500.005mm, y:350.002mm
* 00000264: : unknown 07: use x/y Axis, x:500.005mm, y:350.002mm


Motion parameters:
Motion parameters:
Line 176: Line 181:


Object size. Our test object is 100x100, so this command moves to the bottom left corner.
Object size. Our test object is 100x100, so this command moves to the bottom left corner.
* 00000284: : unknown 09: 772, x:-100mm, y:-100mm
* 00000284: : unknown 09: use x/y Axis, x:-100mm, y:-100mm


Unknown, fixed value
Unknown, fixed value
Line 202: Line 207:
* move relative -100, 0
* move relative -100, 0


The next  8 commands are needed to draw a single line. There are three phases:
The next  8 commands are needed to draw a single line. There are three optional phases:
acceleration, constant speed(optional), deceleration. All three put together move the head from a to b along a straight line. If the angle of two consecutive lines is below some threshold, the end speed of the previous line and the initial speed of the current
acceleration, constant speed, deceleration. Only one of these phases need to exist. All three put together move the head from a to b along a straight line. If the angle of two consecutive lines is below some threshold, the end speed of the previous line and the initial speed of the current line may be significantly higher.
line may be significantly higher.


TODO: Curves are probably done differently, but also from line segments? Future.
Curves are done using short line segments.


Accelerate: the following command will accelerate the head along the given line
Accelerate: the following command will accelerate the head along the given line
Line 216: Line 220:
Move the head on a straight line to the new position. The position is given in steps relative to the current position. The meaning of 772 (0x0304) is unknown but could very well be the index of the stepper that is requested to move (3=Y, 4=X - remember that this is LSB, so in the  binary file, we see 0x04 0x03 0x00 0x00 - maybe we can move Z as well, or even up to four axes at the same time? (2=Z))
Move the head on a straight line to the new position. The position is given in steps relative to the current position. The meaning of 772 (0x0304) is unknown but could very well be the index of the stepper that is requested to move (3=Y, 4=X - remember that this is LSB, so in the  binary file, we see 0x04 0x03 0x00 0x00 - maybe we can move Z as well, or even up to four axes at the same time? (2=Z))


TODO: is 722 the axes parameter? If so, can we move Z?
TODO: 03/04 (722 in decimal) is the axes parameter (x and y). This can probably be used to move in Z as well.
* 00000448: : move rel 772, x:-28.5509mm, y:0mm
* 00000448: : move rel 772, x:-28.5509mm, y:0mm


Line 303: Line 307:
* 00000a50: : laser power corner:40.00%, straight:40.00%, p3:30.00%, p4:50.00%, startspeed:1041(5.00%), speed:20833(100.00%), ??:0
* 00000a50: : laser power corner:40.00%, straight:40.00%, p3:30.00%, p4:50.00%, startspeed:1041(5.00%), speed:20833(100.00%), ??:0


Motion Command Block. These blocks seem to divide the file into 2kByte chunks at command boundaries. Command blocks never contain more than 510 (512?) words (<=2kBytes). This subroutine can ahve many command blocks. Motion Commands are switching periphery (laser,  lower), setting acceleration and deceleration, and moving the head.
Motion Command Block. These blocks divide the file into 2kByte chunks at command boundaries. Command blocks never contain more than 510 (512?) words (<=2kBytes). This subroutine can have many command blocks. Motion Commands are switching periphery (laser,  lower), setting acceleration and deceleration, and moving the head.
* 00000a70: : command block follows, 290 words (form 00000a78 to 00000f00)
* 00000a70: : command block follows, 290 words (form 00000a78 to 00000f00)


Line 324: Line 328:
* 00000ae8: : move rel 772, x:9.97936mm, y:0mm
* 00000ae8: : move rel 772, x:9.97936mm, y:0mm


Switch the laser off already. Even though the next line requires no repositioning, LaserCut has switched off the laser, just to turn it right back on. This does no harm, but makes the file bigger then needed. It also explains why we should always "connect lines" in LaserCut. If lines are connected, we would simply add movement commands here until we reach the end of the cut.
Switch the laser off already. Even though the next line requires no repositioning, LaserCut has switched off the laser, just to turn it right back on. This does no harm, but makes the file bigger than needed. It also explains why we should always "connect lines" in LaserCut. If lines are connected, we would simply add movement commands here until we reach the end of the cut.
* 00000af8: : laser off
* 00000af8: : laser off


17

edits