I am trying to use V4 gamma to send GCODE instructions to an Ender 3 Pro using the SerialPort node.
I can use the RS232 node in V4 beta to do this successfully but there appears to be a problem with the way ToBytes (gamma) encodes the data compared with AsRaw (beta) - when both using the UTF8 encoding.
Using V4 beta, the test GCODE of G28 is converted with the AsRaw node to the byte string [47 32 38 0A 0D 0A] which is sent through the RS232 node and executed by the printer.
In V4 gamma however, the input node only allows data formatted as Spread, which using the FromSequence node converts the G28 command to the Spread:
Iād be grateful for any advice on how to make ToBytes behave the same way as the AsRaw node, and then how to successfully pass that through the SerialPort node.
In the beta patch, there is a cons and a plus node, maybe they add the additional bytes? Otherwise, looks correctā¦ Also make sure that the com port isnāt opened by another software.
ahoi, it looks like you need to send the byte encoded as Hex
We did rebuild the Patch and figured out that you added some LF + CR LF in the Beta version - thats the 0A 0D 0A part.
In gamma the tobytes gives you the decimal representation of the supplied char as byte.
The easy solution is to convert your String into a CharArray and format each char as Hex Byte String. (I hope this makes sense :) )
Edit:
There is also a solution without low level nodes:
Convert the String in Chars in a ForEach, then use ToString (HEX)
the confusion here seems to be only regarding the different displays of raw/byte data between beta and gamma. while beta displays hex values only, gamma shows the actual byte values (+ hex values in tooltips). so really both are the same. the only difference seems to be, as tonfilm pointed out, the additional bytes that there are added in the beta patch.
Although Iām having one problem - do you know how I could buffer sending the commands based on the SerialPort OnData counter node - without avoiding a circular error? (V4 wonāt let me plug it diretly in)
Please see the image where the counter has reached 60 but only 20 lines have been successfully sent. Iād like to use that value of 20 to buffer the commands.
@bildwerk at the minute Iām using the printer as a drawing machine where the gcode can be edited as it is printing using Grasshopper.
This example is repeatedly drawing a circle where the radius is determined by the pressure of a wacom tablet. So the circle grows and shrinks as it is being drawn.
@bildwerk I have been using this set up for a while and it is working well!
But Iāve run into a speed limitation of how fast I can issue GCODE commands - resulting in stuttering print behaviour. Is this a limitation of the Counter node?
I donāt think this is due to the data rate of the Serial Port as I have tried multiple methods to create a fast counting list of numbers (etc. Trigger, Oscillator) but cannot seem to increase the speed of Counter without dropping values.
What is the best method to write a list of rapidly increasing integers? Iāve searched the forums but canāt find a solution
ouright, so it seems your problem is that the patch is mainloop-bound. the counter can only update once per frame.
one of the big new features with VL though is that this doesnāt have to be the case. you can send/receive things without being bound to the mainloop!
if i understand your patch correctly, see this outline how this should basically work using Reactive nodes: GCODE-Sender-Outline.vl (19.1 KB)
note, this is a non-functional, non-complete sketch to only give you the basic idea.
what happens between the Receiver and the Sender is not bound to the mainloop but instead triggered by the receive or init events: you press the init bang to start the whole thing. this sends an event and foreach event the counter is advanced and the according GCode line is passed down to the sender. this in turn triggers a message being sent back to the receiver which again passes an even down, further advancing the counter.
like this the patchs mainloop can be anything and still the communication to the printer will be as fast as possible.
Iāve tried to integrate it into my existing workflow but have a couple of questions/ problems:
Previously I was using IsMatch and Message Sent to buffer the commands so that the counter was only advanced when an āokā is received through the SerialPort. Is it possible to integrate this into the new method? Now it just sends all commands rapidly without knowing the state of the printer.
Often the data received from the SerialPort is a fragment of the full string eg. āoā or ākā”ā, and so the IsMatch method fails in these cases. I think this might be to do Parity and Stop Bits (I currently have set as None and One respectively but have tried all the different settings)
What is the best method to add a pause function with the init?
Iāve attached my working file and would appreciate any further help.
My bad. The most important info was missing. As you remarked in 2) when receiving data via the SerialPort, messages can be fragmented. Thatās why you have to use a Tokenizer to receive them! I recommend reading this article about message framing for a general understanding of the issue.
Note how i assumed that the message sent by the printer is āOK\r\nā. ie. the framing used would be a postfix of ā\r\nā, (carriage return, line feed). If my assumption is not correct, youāll have to adapt this, otherwise it will not work!
this works great thanks!
although I am still having a couple of issues:
the TopEdge node doesnāt appear to ābangā when pause is unpressed (even in the unedited file you sent) - this then means that I have to reset the Init which restarts the list of GCODE - rather than continuing from the last line sent (this is a problem I seem to have often where nodes like TogEdge and Changed donāt react to changing inputs)
Iād like the ability to send commands line by line at the beginning of the print (which I was able to with the old method), and have tried to implement this but canāt seem to get it to work properly. when I have managed to get it to work - by sending a single ābangā to un-pause the process - the ForEach loop sends multiple lines instead of just one, and resets from the first line each time
do you have any ideas on how I could fix these?
Iāve attached my edited file for reference if useful
I have implemented the OR but have not been successful in getting it to send only one command
I have also added a graphic interface using the skia renderer - of the current 3d printer state based on GCODE progress - but is it possible to use the counter value within the ForEach(Keep)? I am unable to add an additional output.
As the counters outside the ForEach loop always lag significantly behind - as per the attached screenshot. Iāve also attached the file for reference