Showing results for 
Search instead for 
Did you mean: 

Send G-Code to Arduino Mega (Marlin 1.1.0-RC7)

Hello to all Programmers,

Currently I am writing on my Bachelor Thesis and I need to send g-code (generated in LabView) from Labview to an Arduino Mega (of a 3D-Printer), where Marlin 1.1.0-RC7 is running.

Usually the g-code is sent from RepetierHost via Serial Connection to the Arduino (which works perfectly), now I want to do it from LabView directly.

I have installed the VISA Library for Labview and when I send through the serial Connection a g-code (M42 P57 S255 meaning: turn on pin 57) I only get information as for the printer set up, but it is not answering my command, meaning the pin is not going on, even though through RepetierHost it is (-->pic Visa Test).

Then a lecturer advised me to add a carriage return, an empty string or a \n (next line) after my command. There came the same printer-Infos, but when I put the carriage return in front of the command, there was showing:

echo: Unknown command: ""



above the same usual lines that were showing in the tests before (-->pic/vi Visa Test 2):


echo: External Reset

Marlin 1.1.0-RC7

echo: Last Uploaded…


and no pin is lit.

Are there maybe other elements I have to put before or after my command?


I would be extremely thankful, if you could give me some advice.

Best regards,


Download All
0 Kudos
Message 1 of 15

Hi Lea,


I had a view to your code attached. It seems to be a VISA write/read operation.


As I understand your request, the VI is running correctly, executing it on the Windows Host.

Is this correct? On the windows Host the serial interface is used to communicat with your device.


And afterwards you try to copy the VI directly to your device (not longer using the windows host). And then executing it there. Is this correctly?


I think the serial interface could be not the correct way to execute the command, because then the host is not longer connected. Is there another coding reference, which you can use instead directly on the device?


One additional point, running a vi directly on another target always need a labview runtime installed on the target.

You could try installing the labview runtime engine on the device.


0 Kudos
Message 2 of 15

You nede to have your Carriage Return after your command. 

And I think you need to have all your letters as capital, M, P and S.

0 Kudos
Message 3 of 15

Look into LIFA and LINX.  Both are toolkits that show basic communication to an Arduino using a predefined firmware.  I know LIFA had a section of code allowing you to add your own commands, but my point is you can use it as a template and add commands to execute whatever function you want it to.

0 Kudos
Message 4 of 15

Hi all,


I'm building an Inspection Machine along with motion. I got some help with vision inspections the day before. 
Now, I'm curious to know whether this method "sends G-Code to Arduino Mega" can be apply to my project:


Any suggestion would be greatly appreciated.





0 Kudos
Message 5 of 15

I know this post is old but have you been able to get LabVIEW to properly send G-Code to an Arduino Board running Marlin? I'm currently working on something very similar and it would be extremely helpful if you could share what you did to get it working.

0 Kudos
Message 6 of 15

I have to ask what the difference is between sending "G-code" and sending any other data serially to an Arduino?


Are you not simply sending bytes of data over a serial connection?

=== Engineer Ambiguously ===
0 Kudos
Message 7 of 15

I've tried directly sending a line of G-code over serially to the Arduino board and it hasn't worked. I'm not really sure what the issue is, which is why I'm asking.

0 Kudos
Message 8 of 15

Well I am far from a G-Code expert buy what little I have seen just looked like lines of text ending in a semicolon..


So you simply want to send lines of text to the Arduino or do you want to send the G-code to the Arduino and then have the Arduino do something with it like control the motors of a 3d printer?

=== Engineer Ambiguously ===
0 Kudos
Message 9 of 15

I'm trying to send lines of g-code to the Arduino and get it to move motors. Since Marlin is installed on the Arduino, it should be able to move the motors on its own after getting the g-code.

0 Kudos
Message 10 of 15