In a previous post I had had issues sending serial commands via Python to my Makergear M2 printer.
Those issues have since been resolved, after I gave my serial port the proper amount of time to initialize before sending my first command.
I have now moved onto writing simple code in Python that reads in a text file line by line (GCode), and sends each line serially to the M2 to be executed.
For relatively short text files, this process worked flawlessly. However, for a more lengthy GCode file, the printer can only execute a handful of commands before stopping.
What I imagine is happening is that as soon as my code says the serial port is good to go, it spits out GCode commands as fast as the baud rate allows, overwhelming the serial port, sending in all ~ 500 lines of code at once.
Is there some sort of buffer size limit that the M2 is able to take in? I would imagine that as GCode commands are executed, those lines are removed to make room for incoming data.
I have also attempted to put a slight wait in between each successive send command, but I'm still running a risk of overwhelming the M2. In these cases the printer continues to execute commands, but will frequently skip over commands, affecting print quality. Increasing this wait time ends up sending commands too infrequently that my print has slight pauses between each command, affecting my overall print quality with excess extrusion.
Any suggestions on how I should handle sending commands to the M2 such that movement remains continuous without overwhelming the port, and skipping over commands. My one thought was to send commands in chunks, with longer waits between them, but I have yet to try that out.
Ask the MakerGear community for assistance...
2 posts • Page 1 of 1
sorna wrote:sending in all ~ 500 lines of code at once
The MEGA2560 microcontroller has 8 kB of RAM, with a serial buffer on the order of a few hundred bytes, tops. You must pace your serial output by monitoring the responses from the microcontroller, but it's complicated: Marlin doesn't send a response for every command.
Take a look at the Printrun source code (in Python!) for ideas on how to make it work: