Anonymous

Project:RELaserSoftware/MOL file format: Difference between revisions

From London Hackspace Wiki
Got rid of shout-y headings and tidied up line breaks
(Got rid of shout-y headings and tidied up line breaks)
Line 21: Line 21:
The following stuff was added by [[user:Wonko]]:
The following stuff was added by [[user:Wonko]]:


= DESCRIPTION =
= Description =


== ABOUT ==
== About ==


The .MOL files are generated from CAD drawings (dxf import) using a proprietary library  
The .MOL files are generated from CAD drawings (dxf import) using a proprietary library  
Line 32: Line 32:
basic functions and manage file up- and download. This protocol is not documented here!
basic functions and manage file up- and download. This protocol is not documented here!


== 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 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
Line 47: Line 47:
* the file is then patched to the next 512 byte boundary
* the file is then patched to the next 512 byte boundary


== THE HEADER ==
== The Header ==


The header chunk contains the parameters of the destination machine, version numbers,
The header chunk contains the parameters of the destination machine, version numbers, and general information including file size. All data is at fixed positions.
and general information including file size. All data is at fixed positions.


== THE CONFIG CHUNK ==
== The Config Chunk ==


This block has all the information about the position and size of the artwork. It uses, like the  
This block has all the information about the position and size of the artwork. It uses, like the following chunks, a number of binary commands, most of them deciphered below.
following chunks, a number of binary commands, most of them deciphered below.


== THE TEST CHUNK ==
== The Test Chunk ==


This is called when the "Test" button is pressed on the panel. It moves the laser head
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.
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 DRAW CHUNK ==
== The Draw Chunk ==


This is called when the "Play" button is pressed and contains a setup part followed by
This is called when the "Play" button is pressed and contains a setup part followed by a list of machine control commands that cut and draw the artwork.
a list of machine control commands that cut and draw the artwork.


== BINARY COMMANDS ==
== Binary Commands ==


Every command starts with three bytes describing the command itself, plus one byte containing
Every command starts with three bytes describing the command itself, plus one byte containing the number of parameters following. The parameters are always 4-byte words in LSB integer or floating point format, or four individual bytes. The FP format differs slightly from the IEEE standard, but can be converted by shifting a few bits around.  
the number of parameters following. The parameters are always 4-byte words in LSB integer
or floating point format, or four individual bytes. The FP format differs slightly from the IEEE  
standard, but can be converted by shifting a few bits around.  


The same command can have a different number of arguments!
The same command can have a different number of arguments!


The size byte can be 0x80 in which case, the actual number of arguments is give in the 4-byte
The size byte can be 0x80 in which case, the actual number of arguments is give in the 4-byte integer that follows.
integer that follows.


A special command (0x46 0x09 0x00 0x80 0xnnnnnnnn) encapsulates n motion commands.  
A special command (0x46 0x09 0x00 0x80 0xnnnnnnnn) encapsulates n motion commands. The motion commands follow the same scheme as all other binary commands. This is likely used for multiple prints of the same drawing in a matrix layout.
The motion commands follow the same scheme as all other binary commands. This is likely  
used for multiple prints of the same drawing in a matrix layout.


= SAMPLE FILE =
= Sample File =


== Header ==
== Header ==


The header describes the parameters of the machine for which the data was created.
The header describes the parameters of the machine for which the data was created. We find information about the file size and the stepper resolution. There should not be any information how to map channels to motors, etc., as that is likely done in a separate configuration file.
We find information about the file size and the stepper resolution.
There should not be any information how to map channels to motors, etc., as that is
likely done in a separate configuration file.


Size of entire file in bytes
Size of entire file in bytes
Line 105: Line 91:
* 0000000c: 0x00000001 ?
* 0000000c: 0x00000001 ?


This word changes when the size of the file changes, i.e. when lines are added
This word changes when the size of the file changes, i.e. when lines are added. This line corresponds to the number of "move relative" commands in the entire file counting "unknown 07" and "unknown 09" as well. Is that coincidence? What would this value be good for? perhaps estimating the cutting time?
This line corresponds to the number of "move relative" commands in the entire file counting
"unknown 07" and "unknown 09" as well. Is that coincidence? What would this value be good for? perhaps estimating the cutting time?


* 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
Line 147: Line 131:
== Data Block at 0x00000200 ==
== Data Block at 0x00000200 ==


The configuration chunk still has a bunch of unknown commands, few of them seem to change
The configuration chunk still has a bunch of unknown commands, few of them seem to change for a single machine configuration.
for a single machine configuration.


Unknown, fixed value
Unknown, fixed value
Line 167: Line 150:
Unknown
Unknown
* arg1 is unknown, but repeats in 'unknown 11'
* arg1 is unknown, but repeats in 'unknown 11'
* arg2 is the start speed for all head movements as describen in the settings
* arg2 is the start speed for all head movements as described in the settings
* arg3 is the maximum speed for moving around "quickly"
* arg3 is the maximum speed for moving around "quickly"
* 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)
Line 208: Line 191:
== Data Block at 0x00000400 ==
== Data Block at 0x00000400 ==


This is the block that is called when the user presses "Test" on the panel. It moves the  
This is the block that is called when the user presses "Test" on the panel. It moves the laser head on the bounding box around the artwork.
laser head on the bounding box around the artwork.


Begin of the subroutine. I don't know if the ID has a specific meaning, or if the file position
Begin of the subroutine. I don't know if the ID has a specific meaning, or if the file position of this block is sufficient to make it the test block. Just don't change it.
of this block is sufficient to make it the test block. Just don't change it.
* 00000400: : begin subroutine 1
* 00000400: : begin subroutine 1


Line 218: Line 199:
* 00000408: : unknown 05:  603, 1041(5.00%), 41666(200.00%), 145833(700.00%), 104166(500.00%), 72916(350.00%)
* 00000408: : unknown 05:  603, 1041(5.00%), 41666(200.00%), 145833(700.00%), 104166(500.00%), 72916(350.00%)


This command encloses all following draw commands. It may be used for multiple
This command encloses all following draw commands. It may be used for multiple rendering of the drawing commands at different location to keep file size small. The commands inside the block follow the same scheme as those outside.  
rendering of the drawing commands at different location to keep file size small. The commands
inside the block follow the same scheme as those outside.
* 00000428: : command block follows, 112 words (form 00000430 to 000005f0)
* 00000428: : command block follows, 112 words (form 00000430 to 000005f0)


Line 226: Line 205:


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 phases:
acceleration, constant speed(optional), deceleration. All three put together move the  
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
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.


Line 239: Line 216:
* 00000438: : set speeds a:1041(5%), b:41666(200%), c:145833(700%)
* 00000438: : set speeds a:1041(5%), b:41666(200%), c:145833(700%)


Move the head on a straight line to the new position. The position is given in steps relative
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))
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: is 722 the axes parameter? If so, can we move Z?
* 00000448: : move rel 772, x:-28.5509mm, y:0mm
* 00000448: : move rel 772, x:-28.5509mm, y:0mm


Even though we still are in acceleration mode, setting the initial speed equal to the  
Even though we still are in acceleration mode, setting the initial speed equal to the maximum speed will make this a constant speed motion.
maximum speed will make this a constant speed motion
* 00000458: : set speeds a:41666(200%), b:41666(200%), c:145833(700%)
* 00000458: : set speeds a:41666(200%), b:41666(200%), c:145833(700%)
* 00000468: : move rel 772, x:-42.9175mm, y:0mm
* 00000468: : move rel 772, x:-42.9175mm, y:0mm


Set the next speed parameters so that they are used for deceleration from the maximum
Set the next speed parameters so that they are used for deceleration from the maximum speed (b) to the ending speed (a), using the deceleration parameter (c)
speed (b) to the ending speed (a), using the deceleration parameter (c)
* 00000478: : decelerate
* 00000478: : decelerate
* 00000480: : set speeds a:1473.12(7%), b:41666(200%), c:145833(700%)
* 00000480: : set speeds a:1473.12(7%), b:41666(200%), c:145833(700%)
Line 334: Line 305:
* 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  
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.
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, blower), 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)


Switch on the blower. The numerical values here probably correspond to the output
Switch on the blower. The numerical values here probably correspond to the output ports on the controller board. If we find the pattern, we can control additional devices, like switching the Y axis to control a rotary device, or starting the roller of a laser sintering setup.
ports on the controller board. If we find the pattern, we can control additional devices,
like switching the Y axis to control a rotary device, or starting the roller of a laser sintering
setup.
* TODO: find the command-to-port mapping for this
* TODO: find the command-to-port mapping for this
* TODO: verify that this really is the blower, since our machine has no switched blower
* TODO: verify that this really is the blower, since our machine has no switched blower
Line 362: Line 326:
* 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
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.
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.
* 00000af8: : laser off
* 00000af8: : laser off


Line 383: Line 343:
(...)
(...)


Leaves the head just where it's at. In case of a repetition, the controller will likely know where  
Leaves the head just where it's at. In case of a repetition, the controller will likely know where to move next and continue with the next cutout.
to move next and continue with the next cutout.
* 00000ef0: : blower off
* 00000ef0: : blower off
* 00000ef8: : blower off
* 00000ef8: : blower off
Line 392: Line 351:
* 00000f00: : end subroutine 3
* 00000f00: : end subroutine 3


The rest of the file is filled with 0x00 to the next 512 byte boundary, probably to avoid reading
The rest of the file is filled with 0x00 to the next 512 byte boundary, probably to avoid readingerrors when buffering from the USB stick to internal RAM.
errors when buffering from the USB stick to internal RAM.


= HEXDUMP =
= Hexdump =


<pre>
<pre>