Welcome! Log In Create A New Profile

Advanced

How to save gcode to sd card using serial port

Posted by daniel35111 
How to save gcode to sd card using serial port
October 26, 2023 05:24PM
Hello

I am looking for a way to save gcode on an SD card in a laser cutter using a python application on a Raspberry Pi connected to the cutting board via a USB cable. I made a port in python but the Gcode commands do not allow me to save. I'm currently using something like this

M21 Use this command to mount the last-selected SD card or thumb drive.
M28 This command starts a file write.
G0 ...
G1...

M29 Stop writing to a file

This code only allows me to create an empty file on the card. I also tried to use the M110 code, but it caused numerous errors (Line number not changing, errors on the terminal).

Does anyone know what the correct code should look like?

Data:
Software version: Marlin 2.1.2.1(pins_CREALITY_V4.h - changed to work as a laser cutter)
Motherboard: Creality V4.2.2
Re: How to save gcode to sd card using serial port
October 26, 2023 06:06PM
I did basically the same thing and got the expected results.

Here's the contents of the file I created:
G0 X1 Y23 Z36 F2500
M114
G0 X1 Y23 Z36 F2500

Here's the log of what I did. This was done via Octoprint.
Send: M21
Recv: echoconfused smileyD card ok
Recv: ok
[...]
Send: M20
Recv: Begin file list
Recv: TEST.GCO 32
Recv: FIRMWAR.G 107268
Recv: FIRM.GCO 110168
Recv: End file list
Recv: ok
[...]
Send: M28 TEST2.GCO
Detected manual streaming. Disabling temperature polling. Finish writing with M29. Do NOT attempt to print while manually streaming!
Recv: echo:Now fresh file: TEST2.GCO
Recv: Writing to file: TEST2.GCO
Recv: ok
Send: N2 G0 X1 Y23 Z36 F2500*4
Recv: ok
Send: N3 M114*36
Recv: ok
Send: N4 G0 X1 Y23 Z36 F2500*2
Recv: ok
Send: N5 M29*29
Manual streaming done. Re-enabling temperature polling. All is well.
Recv: Done saving file.
Recv: ok
[...]
Send: M20
Recv: Begin file list
Recv: TEST.GCO 32
Recv: TEST2.GCO 48
Recv: FIRMWAR.G 107268
Recv: FIRM.GCO 110168
Recv: End file list
Recv: ok
[...]
VDX
Re: How to save gcode to sd card using serial port
October 26, 2023 07:04PM
... I did something similar per WLAN with the Toshiba Flash Air SD card - you have to tweak it with a different config-file on the card, as its only meant for sending files, not receiving them cool smiley


Viktor
--------
Aufruf zum Projekt "Müll-freie Meere" - [reprap.org] -- Deutsche Facebook-Gruppe - [www.facebook.com]

Call for the project "garbage-free seas" - [reprap.org]
Re: How to save gcode to sd card using serial port
October 26, 2023 09:41PM
when uploading gcode to your sdcard you need to use the more complicated way of sending data that includes line numbers and checksums.

This is so it can detect errors and request resends if data is corrupted or lost

these are the lines like the following as posted in the above examples.


N2 G0 X1 Y23 Z36 F2500*4


See [reprap.org] for details

Edited 2 time(s). Last edit at 10/26/2023 09:51PM by Dust.
Re: How to save gcode to sd card using serial port
October 27, 2023 07:09AM
Ok, but if i use N number sending line to save , like there " N2 G0 X1 Y23 Z36 F2500*4" I have a recive Error:Line Number is not Last Line Number+1, Last Line: 0

when i set M110 N0 i can send only N0 , only this number does not send error. Anyone know why ?
Re: How to save gcode to sd card using serial port
October 27, 2023 09:40AM
What host are you using? Most have an option to turn the line number system on/off.

If I remember correctly, N0 resets the line counter to zero no matter what it's currently at. Basically, N0 is guaranteed to work.
Sorry, only registered users may post in this forum.

Click here to login