Replies: 60 comments 46 replies
-
Main Idea The idea is to "initialize" the machine to a raster mode in which the mode is defined (modulates time or modulates power) the pitch (distance between two points) the direction (horizontal or vertical, increasing or decreasing) and then sending an entire line of points only giving the percentage of gray (0-255). All bytes sent are treated as dots to engrave, with the exception of all characters used as immediate commands (realtime commands) the character "\n" for newline, and the "G" character which can be used to change mode and/or to exit raster mode, which all must be passed preceded by an escape character to avoid confusion. The machine autonomously manages the movement between one point and the next and the engraving of the dot, until a g-code like G0 or any other G codes which brings out of raster mode is sent. |
Beta Was this translation helpful? Give feedback.
-
Example of implementation
Then follow a stream of bytes that represent the colors of each point of the scan-line. For each of that bytes the machine will have to turn on the laser for 3 milliseconds, at a power that will be computed by this formula:
In order not to overload the reception buffer, the streamer must not send more than 127 bytes in a single line, which is why the byte stream must be broken up into blocks followed by a "\n" that allow GRBL to send "ok" commands back to confirm data receive. At the end of the line the streamer will send |
Beta Was this translation helpful? Give feedback.
-
Industry standard for g code is RS-274. I would really suggest not changing the standard g-codes. M codes are not standardized and exist for this purpose, although if you add a lot of custom M codes your solution will become unwieldly very quickly for others to use. There are several active ports of GRBL to 32 bit platforms, GRBLHAL in particular is capable streaming g-code at very high rates over Ethernet on the Teensy4.1 platform. FluidNC and GRBL Advanced are also under active development. It is also very easy to implement completely custom command protocols with GRBLHAL, see here for an example HGPL implementation that was done without modifying core code: https://github.com/grblHAL/Templates/tree/master/my_plugin/hpgl Really suggest digging into GRBLHAL as I think it could be what you are looking for. It has been ported to many different 32 bit platforms. |
Beta Was this translation helpful? Give feedback.
-
One possibility for optimizing the bandwidth of the raster byte stream is base-64 encoding. It uses 4 bytes of ASCII to represent 3 bytes of binary data, so a 120-character line gives 90 S values from 0..255. There are also some simple and relatively efficient run-length encoding schemes to further reduce the bandwidth in the common case where there are long runs of unchanging values. That said, the encoding is probably not the most important first task. First we need to decide on the best way of folding this mode into GCode. |
Beta Was this translation helpful? Give feedback.
-
The current implementation is not very inefficient and difficult for controllers to implement. Basically every increment is a new move that must run through the planner. Each line could be sent as a single move. You would need to buffer the power information before the move. The concept of "dwelling" at a point does not work. The machine must run at a constant speed. If your resolution is 0.1mm and you want 3ms of time over that area that should simply be the speed. 0.1mm / 0.003sec = 33.333 mm/sec. Some lasers use an overtravel method. That puts the acceleration/deceleration outside of the image area. Currently the controller must try to compensate for the acceleration. Not all lasers are perfectly linear in power and the edges can show artifacts due to that. This does impact the usable work area slightly, so it might be optional. I personally don't think sticking to strict gcode rules is important. Controllers will need to make major changes to support this, so it is better to create a new and efficient protocol. We should not rule out binary transfers. |
Beta Was this translation helpful? Give feedback.
-
I totally agree with you, and I am happy to listen someone with your experience. I have tried to write an implementation to help the reader understand what I have in mind, and it has been very helpful to me in focusing on the various critical points I will have to address. The main critical points that jumped my eye are:
Point 2 and 3 lead me to think that using pure binary data is not the best option (lot of escape characters, different firmware by firmware). |
Beta Was this translation helpful? Give feedback.
-
Re point 4, we probably want to insist on a non-optional checksum or CRC for the raster data. |
Beta Was this translation helpful? Give feedback.
-
Bart said "Each line could be sent as a single move. You would need to buffer the power information before the move." Let's expand on that. In conventional CNC, you send an S word to set the spindle speed/power, and that applies to subsequent moves until changed by another S word. Suppose that we extend that modality so that, instead of a constant power, we have an array of power values that apply to any subsequent move, interpolated across the extent of the moves along one axis. We can come up with a more efficient encoding and error checking, but for ease of discussion, let's use a simple hex encoding for now.
This example illustrates several points:
:X is just an example syntax for talking. We will ultimately want something more expressive. |
Beta Was this translation helpful? Give feedback.
-
In your example above, you used I and J as the black and white points that correspond to 0 and 255 in the raster space. Most GRBL setups already have some way to map S values to the hardware signal that controls the actual spindle speed or laser power. I think it is best to have this spec deal with S values from 0..255 and leave the mapping of those to hardware values up to the firmware. FluidNC has a speed map that can apply to any spindle type, converting a range of S word values to the hardware control variable, with dead zones and piecewise linear interpolation. Other controller firmwares have some way of specifying that mapping. |
Beta Was this translation helpful? Give feedback.
-
Hi @bdring and @andrewmarles
This is what LaserGRBL currently does in its conversion from image to gcode: it produce segments of specified S value (optimizing multiple dots of homogeneous color with a longest segment) and run them at constant speed. This produces a decent result, but this generates lines, not points. I know that standard grbl G4 dwelling at point is limited by firmware implementation (read gnea/grbl#960) but i think it's possible to obtain microsecond accurate timing in most common microcontrollers. However please not focus on this point! The same raster protocol could support different variant: lines at constant speed and power modulation, points with constant dwell and power modulation, points with constant power and dweel modulation etc.
Of course, that's something I was thinking too. However, it must also be taken into account that if multiple raster data block are sent (and these are buffered in the controller as in the character count protocol) when one of that block is recognized as corrupted, he and the following ones should be discarded by the controller (and re-sent by the sender), otherwise all that mechanisms are useless. The alternative is to use a "synchronous + repeat on error" type stream mechanism (among other things already implemented in LaserGRBL). |
Beta Was this translation helpful? Give feedback.
-
Yes, I am totally aware of this. Grbl, as example, use $30 to define the S-value that correspond to 100% of PWM signal.
The I and J in my example have exactly this purpose! In my protocol I want to send "pure bitmap grayscale bytes" from 0 (white) to 255 (black) but if I want to use half of the laser power I should tell the controller that 255 correspond to S500 (if $30=1000) and this is why I define I and J. This will produce a double conversion: from 0-255 (bitmap) to S10-S500 (with I=10 J=500) and then from S10-S500 to PMW 3-127 (with $30=1000) but it is the only way to use the gray values directly and at the same time to be able to use a reduced and translated scale of the laser power according to configured $30. In any case, this too is a minor detail compared to the rest. |
Beta Was this translation helpful? Give feedback.
-
I'm glad I got this enthusiastic answer from you, but at this point I think it's necessary to step back and ask our-self a question: why a raster protocol? What advantages does it have? Is it really necessary or are other ways are possible? I see as advantage:
The only really valid reason is the first, admitted and proven that the current protocol is limiting the overall performance. |
Beta Was this translation helpful? Give feedback.
-
So, back of the envelope calculation. Assume a spot size of 0.1mm . Using a line per spot in G91 mode, each line looks like
or, when going backwards,
So, roughly 10 characters per spot, a bit less on average. 10 characters at 115200 baud is about 1 ms, so 1000 x 0.1mm /sec = 100 mm/sec = 6000 mm/min. That is where the bandwidth limitation starts to kick in. The speed could be increased with a higher baud rate. I expect that there will be other limitations in the planner code. |
Beta Was this translation helpful? Give feedback.
-
Regarding error resend - the real solution is to implement TCP. It is extremely well understood and efficient implementations are available. Why shoehorn error handling into an already-bad protocol? If you are going to fix the protocol, really fix it. TCP can work over a serial line via SLIP or PPP. If you have TCP, any number of problems just disappear. For example, realtime characters are just messages with the urgent flag set. |
Beta Was this translation helpful? Give feedback.
-
I use binary data to enable/disable laser on constant speed. |
Beta Was this translation helpful? Give feedback.
-
My personal notes:
Don't waste M66 WAIT ON INPUT for outputting things, choose annother one.
Do you are aware that this is already implemented on several Grbl branches,
mostly ARM based ones,
when enabling it inside config.h, extract:
#define ENABLE_WAIT_ON_INPUT
/*
---------------------------------------------------------------------------------------
* Enable M66 wait on input mode
* Pvalue is the pin index ranging from 0 to 254
* example: M66 P0 L3 Q5.6
* wait up to 5.6 seconds for digital input 0 to turn ON (HIGH)
*
* This is a subset of the linuxcnc implementation of M66, with the
implementation of digital input only
* and only with the wait mode of HIGH and LOW.
*/
further
M Codes are not allowed to have Axis Words. This collide with modal motion
and modal macros.
Maybe add Gcode, or better, move config/setup to the binary section too.
As note, some CNC use # for local variables, @ for global variables and $
for system variables, me too.
I'm using framing for sending binary lines, that don't need ACK from grbl
side, only NAK in case of error
in order to speedup the transmission, and for this it get separated before
going in the normal gcode parser.
Seeing you'r example, i suggest to use intel hex code including : marker
for the binary laser data
From firmware support, GRBL have no timing support, there is possible to do
per step timing,
timing in subitems of steps after 15uS of step, but if you need do 40khz,
the timing is only from 0.25uS to 10uS
usable for higher power lasers.
Sure, it's possible to add timing support in multiplies of 16uS only if
considering legacy board, including
that shipped with china laser engravers.
For diode lasers, for fast response time, it's important to not power off
the laser,
just power it down into the led region and ramp it up. Respond is then in
the nS range, as 0.25uS pulses
are visible on paper.
Annother option for imaging is per microstep imaging and not per time.
Further from doc, direction of imaging is to consider, as certain cnc can
only reliable image the target
from the same side, as the backlash is not constant.
Am Sa., 7. Mai 2022 um 23:10 Uhr schrieb Terje Io ***@***.***
…:
I think instead that the M66 command is modal and is part of the M3, M4,
M5 group
Why would that be? M66 is a "user defined" command and as such part of
modal group 10 per LinuxCNC specs. In grblHAL it will be executed in group
9a - later than group 7 which handles M3/M4/M5 - so IMO in the correct
order (if on the same line).
[image: image]
<https://user-images.githubusercontent.com/20260062/167271264-a357281c-c83c-4711-ac1f-a227324b7f14.png>
This would be insanely slow, is that the intention?
For fast *pixel perfect* engraving switching the laser on for a short
time for each pixel while cruising is, again, IMO the best option. Which
leads me back to some questions earlier about design limits. E.g. a DC
excited CO2 laser has a typical response time of 1 ms, a RF excited laser
in the region of 0.2-0.3 ms (IIRC). This limits the engraving speed vs
engraving resolution. I have no experience with diode lasers other than the
one I built for my PCB exposer so I do not know what to expect from those.
Only that the constant current source I bought with the laser diode was
useless for the high speed engraving I required for that (1200DPI @
230mm/s).
There are other limiting factors as well, such as beam spot size...
When I clear my backlog (I have been busy with another project for a
while) I can try to write an engraving plugin for grblHAL - are there any
grblHAL users out there with a diode laser that can help with testing?
—
Reply to this email directly, view it on GitHub
<#1818 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACIQ5FQOP33QFPORROQ5WSLVI3L2XANCNFSM5UK56CUQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I feel strongly that the raster data line should have:
Error lines should be acknowledged differently from non-error ones, so in case we want to do some kind of retransmission scheme later, at least it will be possible to extend the protocol. If there is no good way to detect error lines, future improvements are very difficult. One way of handling error lines is to repeat the previous line (in reverse order if the scan is boustrophedon). That leaves a visual artifact, but every lost and uncorrected data scenario leaves some kind of artifact. A repeated line is usually less visible than an image shift resulting from missing bytes that cannot be precisely located within the line. |
Beta Was this translation helpful? Give feedback.
-
Lots of things to discuss, but at least that's a starting point. I try to answer everyone.
I had noticed that this new binary mode seems to take on a similar role to M3 / M4: M3 constant power laser, M4 variable power laser, M66 laser controlled by binary data. Also it seems very unlikely that these modes could be used together, and finally I liked the idea of being able to turn off binary mode with the M5. But the most important reason is my ignorance. I did not know the existence of group 10 and this is why I placed it in the modal group 7 instead of 10. Better to use the "user defined" modal group? it's ok to me! |
Beta Was this translation helpful? Give feedback.
-
I admit my ignorance again. I tried searching the internet for what M-codes were used and seems that M66 was unused. If it's used, better to switch to another one.
Since this is not a user customization but is an attempt to write public documentation of a new standard, I was thinking of using a free M code among the "non-user" ones. Obviously, however, without going to conflict with already defined functionalities. Any suggestions? In any case, I see no problem if using a M-code > 100. |
Beta Was this translation helpful? Give feedback.
-
for system variables, me too.
Used by grblHAL as well. $ migth be used if not in the first position of a
line? LinuxCNC uses $ for specifying which spindle to address for some
commands,
Yes, several vendors use that. It's improve reading of code and allows
having position data starting at $1 instead of needing to lookup the
codebook what variable is that #2001 as example.
Extract from one random cnc mill manual:
#00 NULL
#1~#33 Local Variables For each level
@000 NULL
@***@***.*** Global Variables(Common) Common variables for all program
levels Not preserved
@***@***.*** Global Variables(Common) Common variables for all program
levels Preserved
$001~$199 : Read only -- $196 is the last used
$200~$399 : Read only and preserved -- $333 is last, including 16bit
from PLC
$400~$599 : Read/Write -- unused, for system integrators or for
expanding the call levels
$600~$799 : Read/Write and preserved -- $631 is the last used including
16 bits to the PLC
NULL is NAN, every double value that is NAN cancel automatically the
preceding Word used, necessary for macros, really important.
just power it down into the led region and ramp it up. Respond is then in
the nS range, as 0.25uS pulses are visible on paper.
You use a high spindle PWM frequency to achieve that?
No, it's on/off. I use HW voltage/current converter and settable
minimum/maximum current.
I'm using 145mA and 310mA, where the granted laser threshold is 150mA , on
10bit adc, minimum laser on is 31 up to 1023 ,
I'm using 6bit -> 8bit -> 10bit -> 16bit expansion mapping, 10bit on avr,
16bit on arm.
6 ->8 and 8->10 bit divided range / 3 , lower third is used as is, upper
third is subtracted from maximum, and middle third is multiplied by 4.
10 to 16 bit is expanded to 12bit by the same algorith as 6->8bit and then
multiplied by 4, to get 14 bit, then again the alg 6->8bit to get 16bit.
Expansion code is this:
uint16_t expand2bit(uint16_t val, uint16_t limit) {
uint32_t tmp = val; uint16_t t,l,lim=limit>>2;
tmp=limit*21845; t=tmp>>=16; l=t>>2;
if(val>(lim-l)) val = limit-(lim-val); else // upper third
if(val>=l) val = ((val-l)<<2)+t; // middle third
if(limit>250 && limit<1000) /* 8-10bit */ {
tmp=val; val=tmp+=32; if(tmp>=0x10000) val=0xffff;
}
return val;
}
Do you have/need backlash compensation for high speed engraving
No, i expose always from the same side only as i don't make artistic images
but tecnically that get processed and with backlash
it could violate some requirement. Otherwise yes, it's necessary.
PS i could send my code for handling, but there is some hint.
The @n@ format is for program control streaming, no OK get replied, only
errrors including the last correct received n line.
The :n: format is for SD card streaming, it send back OK code, same as any
other gcode on grbl.
As the format is compressed, LZSS and RLE , the program must stream first
the code to the controller in order to verify the buffering.
and at the same time writing down the : format for offline usage, as the PC
not really know what is the buffer state of the controller.
I mean for things, that need data during movement and the buffer to cache
data is too small for holding all data.
I'm using ENC , ACK NACK ascii for enquiring normal and binary line buffer
capacity for smooth control of transmitting data.
I feel it's too specific implementation, but if you want just start with
that, see how good it's work, do it.
—
… Reply to this email directly, view it on GitHub
<#1818 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACIQ5FWEDQYTZDN5MUL6LATVI5CKLANCNFSM5UK56CUQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I am perfectly aware that this would be slow. Currently I am convinced that this leads to a qualitatively better result but I have not yet managed to have a proof of this.
However, this cannot be called pixel engraving, it would be dashes: more like lines than points. I've seen some software that generate gcode for pixel-engraving using G4 dwell command, unfortunately I don't have these software and lasergrbl doesn't support this output. I would at least like to try. Then I can say more.
Laser diode are commonly used in high-frequency communication system and pulsed operation is very common too. Obviously, the possibility of making accurate uSec timings on the diode pulse also depends on how the firmware is designed. Anyway, I have included these modalities because it seems to me that they are achievable using the exact same protocol. If they are not feasible due to technological limitations, or if they do not provide better results than the line mode, for me they can be forgotten. |
Beta Was this translation helpful? Give feedback.
-
I understand that the axis words could cause conflicts, but why S command too? M3 S1000 is a command that I send when I want to turn on the laser at full power, and it is correctly interpreted.
I don't like the idea to move setup to binary section. |
Beta Was this translation helpful? Give feedback.
-
Communication problems, CRC, byte count. I first thought they were needed, I still think so, but I don't think they need to be implemented and defined in the documentation of a sub-part of the communication while the other parts of the communication doesn't handle it. Even a re-transmission system that deals only with binary data, and which treats errors on binary packages differently from how it treats those on gcode packages, does not convince me. I read in reprap that some firmware support CRC and checksum. Perhaps this path should be deepen.
Agree, base64 is a must have but I choose hex because it was easier to implement even in limited hw like atmega328 (I wish it could be implemented for these devices as well.)
Agree.
Or using the last know value (usually the pixels close to each other have similar colors). |
Beta Was this translation helpful? Give feedback.
-
Your need something as a code in order to be sure that the machine is the
one you intend to use and take in mind, there are scenarios where you use
steps instead of timing for laser control and sometimes its needed to
position the laser using calibrated positions.
Another point is, when you stepper speed is less then 3rpm there is no
timing penalty for stepper. Just expose, make step, expose ... Make g0 move
...
With m code the setup is too complex,
Inside binary you can have several parameters and functions.
Further doing binary setup you could mix s and timing data even only
partially, instead external m code blocks the motion.
arkypita ***@***.***> schrieb am So., 8. Mai 2022, 20:09:
… feel strongly that the raster data line should have:
Framing error detection in the form of a byte count. Lost bytes - a very
common problem - will gargle and shift the rest of the line, rendering the
"replace unconvertible hex values with 0" rule useless.
A CRC
Communication problems, CRC, byte count.
I first thought they were needed, I still think so, but I don't think they
need to be implemented and defined in the documentation of a sub-part of
the communication while the other parts of the communication doesn't handle
it. Even a re-transmission system that deals only with binary data, and
which treats errors on binary packages differently from how it treats those
on gcode packages, does not convince me.
I read in reprap that some firmware support CRC and checksum
<https://reprap.org/wiki/G-code#.2A:_Checksum>. Perhaps this path should
be deepen.
A format character, allowing future extension to e.g. base-64 encoding
Agree, base64 is a must have but I choose hex because it was easier to
implement even in limited hw like atmega328 (I wish it could be implemented
for these devices as well.)
Error lines should be acknowledged differently from non-error ones, so in
case we want to do some kind of retransmission scheme later, at least it
will be possible to extend the protocol. If there is no good way to detect
error lines, future improvements are very difficult.
Agree.
One way of handling error lines is to repeat the previous line (in reverse
order if the scan is boustrophedon). That leaves a visual artifact, but
every lost and uncorrected data scenario leaves some kind of artifact. A
repeated line is usually less visible than an image shift resulting from
missing bytes that cannot be precisely located within the line.
Or using the last know value (usually the pixels close to each other have
similar colors).
—
Reply to this email directly, view it on GitHub
<#1818 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACIQ5FVM6FRTU6NS4DGCI6LVI77O7ANCNFSM5UK56CUQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks to all, I need times to re-read all your comments and hints. @cri-s I read your messages with interest but I am struggling to understand if what you are exposing is a pure binary protocol or something that I could also use in a g-code style format. |
Beta Was this translation helpful? Give feedback.
-
Sorry if i didn't speak for a few days, i'm very busy with work. What M-code to use
My proposal is to switch to M54 M54 seems to be unused in most common firmware implementation: linuxcnc, reprap, marlin and also googling M54 does not give significant results. What parameter letters can be used
We need four parameters:
I and J are fine or not? can we use other letters like P, Q, E? Binary data format Here I still have some doubts: let me expose them to you.
First of all: Is it really necessary to define the possibility of having multiple encodings? When generating the g-code you should know which encoding the machine supports, this is inconvenient. The same saved gcode file might be fine for one machine but not for another. IMO using only one encoding it simplify! However I am open to this Idea, but still having doubt: should repeat it at any single raster data line? It's a waste of bytes! I think that the stream is consistent. Why not use use another parameter of M54 (or use different M-code) just to set "binary data format". Or define it implicitly (not explicited in any way) or auto-guess it by the firmware analyzing character set. Second: I approve of adding a CRC for data corruption verification and re-transmission request, but do we really need explicit packet length too? If we apply data discarding and re-transmission when the CRC does not match, what advantages having packet length does it really bring? |
Beta Was this translation helpful? Give feedback.
-
I apologize if I have not pursued this topic anymore but I am really very busy with the work in this period! :-( |
Beta Was this translation helpful? Give feedback.
-
First, bonafides, I'm the author of MeerK40t and do a lot of reverse engineering of dedicated laser control cards. A couple notes and an overview of the topic from outside the gcode world. The probably ways such a thing could go and my proposal. First prior art. There was a small weird project 7 years ago that apparently hacked in Raster-data in G7 with Base64 data into Marlin cards ( https://github.com/TurnkeyTyranny/buildlog-lasercutter-marlin ). G7 is typically Lathe Diameter Mode. I don't think that prior art did any work for you. Some, but not all, dedicated laser cards rather than CNC firmware hacked to allow laser-cutting (gcode) have a raster modes. M2 NanoThe M2 Nano, for example, lets you establish G values during rapid mode. This sets the number of stepper motor ticks (in the top or bottom direction) at the turn around point of the raster. Rasters come in a variety of flavors but they usually stop at some point and go the other direction. The M2 Nano detects this as the point where The encoding for M2 Nano has the stepper motors already set (they are set by a single ascii code value), and all it does is convey ticks to the stepper motors to move distances. A lot of K40s and other lasers have stepper motors of discrete tick sizes. So you're looking at conveying absolute distances in ticks rather than overt distances (big weird gcode fractional amounts). So the egv code looks like RuidaRuida runs a purely binary control code language. All commands begin with a high-bit and they can be of whatever length. Numbers that are larger than 7 bits are encoded to just use the 7 low bits. So 32 digit numbers are stored in 5 different 7 bit numbers (they don't/can't set a high bit in payload). This is also all swizzled with a really basic algorithm but varies slightly based on type of machine. But, because the high bit you can always identify and divide the command and the payload. This gives you 0x7E different potential commands with payloads of any size. This is done through serial and through UDP which tries also includes a checksum to try to tell whether anything changed (but, packets go missing, and things get bad, and it's UDP so packets go missing). Rastering is done purely with the same commands as vector, however it can do MoshiMoshiboards run a pure binary control code language with 16 different potential commands. Each command has a known amount of payload. There would be 255 different commands but they engage in a weird swizzling protocol which gives 16 different varieties of the same 16 commands and sprinkles the equivalent control codes throughout the little programs it runs. They run their own raster protocol which is basically "raster mode" which is entered into differently than vector-mode. The speed codes given are in cm/s rather than mm/s (which is how it works in vector mode). And the commands short relative commands in this mode. So LMC EZCad2LMC controllers which control EZCad2 Galvo lasers have preset command sizes. A command block is 0xC00 bytes long and consists of 256 commands that are 12 (0xC) bytes in size. These are 6 different int16le values, and the first 2 byte word typically has 0x80xx values specify the list commands (these are inside the 0xC00 blocks) and there's smaller realtime commands which are just single 12 byte commands and these usually are 0x00xx codes. However, the EZCad3 DML controller has commands that are like 0x8100 (lMarkPixelLinePara1). So each command of which there are a great many (way more than you actually need), fits nicely or is made to fit in the remaining 12 bytes (most don't use more than 4 bytes). Also, due to being Galvo the positions are in absolute values between 0x0000 and 0xFFFF for x and y. And usually 2 int16le values give a position. Rasters are done simply using these commands there's a So, sorry for the long winded overview of many different cards. But, generally sometimes these cards have dedicated raster modes but it's mostly so they know they'll be running at a faster speeds, or to account for the higher speeds with different accelerations. Usually what these cards have over grbl cards, aren't specialty raster modes but rather the ability to have a pre-defined understanding of the command codes are and will do. Thus do not require any expensive parsing, or planning, they also use the understanding of the stepper motors to give values in pure integer amounts (Ruida gives distances and locations in micrometers). This usually ends up being a lot less data than comparable g-code but it doesn't hold that you could jam in some binary into the existing gcode system and avoid the bottlenecks. We also need to understand that there are different types of rasters and these all tend to need some support. Regular on-off rastering is one type but regular PWM rastering is also important. You declared a desire to implement one or the other type and really both are sort of important. Also, there are times when it's useful for lasers to raster things diagonally (some controllers don't love this and are not built well for this) but it is certainly something a number of software packages permit. This gives three ways forward:
I think GCode Dash Array ProposalThat said, my two cents for a protocol is to add in a
The first value is the distance in currently set units (mm/in), the remaining values are how far between on and off we travel. So in this we're traveling 20 units and we set our dash at 20 units, 2 on, 3 off, 7 on, 9 off, 1 on. If we set our distance value to The logic behind this is that since we specify a length we're actually conveying a DPI to the controller. You could, in theory, specify traveling any distance and exactly mark the pixels there, you're defining the pixel size rather than relying on on the controller to know step size or how big our pixels are. The D-mode setting would not automatically unset. So sending gcode: We get the rather useful feature of dash-array lines, if we set these to macro levels where you could see them, we also get the rather useful feature of PPI power modulation, in addition to and in parallel with the PWM power modulation. And we can shorthand the raster information. If we're going to be drawing a scanline, so we can just tell it the pattern of pixels in this scanline (or segment of a scanline, given the buffer). And we draw the line as normal, but rather than a normal cut-line we get a patterned line. In this case a scanline as set forth in the image. So rather than a completely hacky side loading of pixel data. We convey a useful feature. You want to draw a dot-and-dash morse-code line around a circle... we have you covered. But, also, we could convey an image raster much more efficiently. In the M66 proposal rather than the encoded sequence command We also do not require a defined position, so you can raster not only vertically, horizontally, diagonally but you could raster an series of arcs if you wanted to. This generally meets the requirement set forth in development of a new raster protocol while also being useful enough that it might be worth implementing anyway. There's some additional things like you could turn the laser on and off at non-specific locations so you actually might be able to raster images smaller than the laser's actual physical step size. And the implementation details is not based on location, but just timing. You're traveling at a specific speed and going to specific distance and the laser is turned on and off over the course of movement but, you don't need to care about your position, this is actually just toggles at specific times. You're just hacking a pattern into the laser's on-off timings. So you're just touching that one system you should have traveled some number of units given your speed, go ahead and trip the laser There's a few other advantages like pixel shortening (it turns out pixels look bigger than they were given where the laser turned on and off because the oblated region is round and not square. Turning the laser on for 1 pixel often means drawing something that looks much more like 1.75-2 pixels wide, thereby darkening the image if there's many small cuts. We could accurately account for that since could turn the laser on and off across fractional pixels. The syntax is notably similar to SVG The raster protocol is a side effect of an otherwise killer feature. That seems like it might make getting people to implement it much easier. |
Beta Was this translation helpful? Give feedback.
-
I've went 2 different routes with mine. So far I'm not sure which ones work best. I tried various ways of converting the raster data to gcode using grbl, but they all suffered buffer under runs and stuttering when running beyond 2000mm/m for a distance greater than 500mm, and a step rate of 80/mm. I haven't tried it on a teensy yet tho. Regular jpeg rendering to generate intensity values for the laser and the image being a fixed size and a known dpi I didn't have to bother piecing motion segments together to find the return point of the motion. Then finding the laser intensity was pretty basic, by finding the gray value and factoring in current velocity when that pixel is being created. I've had pretty good results so far but still experimenting. The switch between regular gcode and raster mode is selected using an Mcode, and the mcode is only valid if the machine type is a laser. Second method is looking ahead to a point the motion changes 180*, while storing the S value for each pixel during that travel. Requires quite a bit of memory if the image being loaded is over 1000mm wide. The advantage to it is there's no need for a different process type, but I still use an M code to set raster mode before loading the file. |
Beta Was this translation helpful? Give feedback.
-
Hi all, thanks for the new contributions, I'll gladly read. |
Beta Was this translation helpful? Give feedback.
-
The gcode and grbl are great, but the use made of them for raster image engraving is a strain on its capabilities (as well as being highly inefficient) as because grbl is a kind of vector protocol.
For this reason I would like to try to write the specifications of a protocol for sending raster data, something that involves sending some modal commands at the beginning (to program the X / Y step between one point and another, the intensity desired for black, the dwell time on each point etc) followed by a series of data that define only the gray values and a line change command.
I intend to do it in two possible ways:
All obviously taking into account the length of the buffer, the management of immediate commands (therefore using escape codes) etc.
My intention is to send this specification to the various manufacturers and firmware developer and see if anyone would like to invest in this idea.
Anyone who wants to collaborate can write below this thread!
Beta Was this translation helpful? Give feedback.
All reactions