Go Down

Topic: Streaming data to / from Arduino (Read 2295 times) previous topic - next topic



Ive been playing around with my Arduino Uno for a while now and have decided that I want to use it as the controller for a super simple 3 Axis CNC I have been working on.

I think I have the hardware (drivers, steppers, limit switches) pretty well locked down and figured out, what I need help with is writing the code either in programming or python to stream G-Code to the Arduino via the serial monitor.

I thought the work-flow would go something like this:

1. User loads G-Code file into Programming / Python script.
2. Script issues command to "zero-out" machine by turning stepper motors until "home" switches are depressed.
3. Upon feedback from arduino that machine has been zeroed (simple if/then command?), the script would then feed the arduino the first line of g-code, which would be translated into steps by a sketch on-board the arduino.
4. After feedback from the arduino that the first line of g-code had been completed (basically after the digital pins are done sending signals), the script would feed the arduino the next line of g-code. This process would continue until the G-Code file had been read start to finish.

I think I can take care of all the logic of converting the g-code to step and direction commands, so what i really need help with is sending those commands via the serial monitor to the arduino. any direction would be greatly apreciated!


You need to establish a protocol between PC and arduino using serial port.

Say you can send data as the following:

You send this from PC to arduino and wait for arduino to send back a job complete

Then you send Arduino another move command and wait for OK#.

On arduino, it has two stages:
1) Wait for a complete command from PC
2) Interpret the command, execute it and reply to PC
Certainly when Arduino starts up, it may send a message that it is up and running with OK# so the PC program starts and waits until it receives OK# before asking the Arduino to do anything.

You know something like above will get you started at least with communicating part. Later you can improve your protocol to do more stuff though. Your CNC has to move slowly one step at a time on one axis to start with. Later you can develop a go command that PC sends so all previously sent commands executes together and you get multiple-axis motion.

BTW, I'm just making these all up :smiley-mr-green:. I never programmed a motor. Only spent some years using systems with stepper motors and anyone with experience please correct me.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter


Thanks for the help, it sounds like it will be easy to make the arduino and pc communicate complete commands with ok#, I am still trying to figure out how to automatically send g-code data (or interpreted g-code) from a processing app to the arduino via serial. I know this is pretty basic, but i havent had any experience, thanks for the help!


Post some basic code you manage to write on interface with software forum. That's where processing folks hang out. I've done processing but that was a while ago.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Go Up