Go Down

Topic: Can I save GCode instuctions in a UNO running GBRL and run them stand alone?  (Read 506 times) previous topic - next topic

BobP2

Hi I'm building a CNC machine to wind lots of identical springs.  I know how to do the mechanics and wire the bits together and can work out how to write the GCode  in a laptop. I've read how to download GBRL into a UNO and should be able to sort that out, and also run the CNC  from the  GCode  in my laptop.

 But when I've got my GCode and CNC machine debugged  I'd like to burn that  Gcode into the UNO so that it can be powered up and run without the laptop connected.  I can connect switches to the abort, hold, stop, reset etc  pins on my breakout board to control the machine.

Is this possible and easy to do?  My GCode program should be pretty small  -  under 100 instruction lines.

This is my first CNC machine  and first  Arduino project and I'm not a programmer so please spoon feed me.

Many Thanks (in anticipation)

BobP2



 

Robin2

I reckon you will need an SD Card attached to the Uno to store the GCode - unless the GCode is very short.

How many lines of GCode does your project need?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

BobP2

I estimate 25 line of G code - but allow for 50 lines. I'm just driving 2 motors.

BobP2

Robin2

A wild guess is 25 characters per line amounting to 1250 characters.

I think you could store all that in PROGMEM (as part of the program) but there is not enough EEPROM memory.

You can't change PROGMEM while the program is running.

My own preference would be for an SD Card - much more versatile.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Paul_KD7HB

Your proposal is a bit more complicated. The CNC controller returns messages to the PC for both errors and when to send the next G-Code line or lines.

Paul

Robin2

Your proposal is a bit more complicated. The CNC controller returns messages to the PC for both errors and when to send the next G-Code line or lines.
I have never used GRBL. I had assumed it could read from an SD Card.

But you raise an important point which I overlooked - the use of GRBL. I had been assuming (thoughtlessly) that the OP was going to use a program he was writing himself when using GCode stored on his Arduino.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

MorganS

Many 3D printers can read a gcode file from an SD card. Maybe you can borrow the SD module from the Marlin firmware?

Maybe there is a more efficient storage format that will fit in EEPROM?
"The problem is in the code you didn't post."

BobP2

Thanks for all the info. My idea sounds non trivial for you experts  --------- so for novice me to do this seems a non-starter.

Would it be possible to run code in  a second UNO (perhaps with an SD card containing the GCode) that pretended to my CNC GBRL UNO that it was my laptop  PC supplying the GCode?

Perhaps there is some ready made UNO code that does this?  or could be tweaked to do so?

Thanks Again

BobP2

Robin2

Would it be possible to run code in  a second UNO (perhaps with an SD card containing the GCode) that pretended to my CNC GBRL UNO that it was my laptop  PC supplying the GCode?
Possible yes. Easy, NO.

Why not just use your PC (or a Raspberry Pi) to supply the GCode?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

MorganS

Why gcode at all? I would expect that there is not a lot of variation between different springs. Maybe just the number of turns? Then you just need to select the number and the Uno already knows how to do everything else that a finished spring requires.
"The problem is in the code you didn't post."

BobP2

Its a complex spring so a simple mechanical geared spring former is not an option.
If possible I want to keep my expensive delicate laptop out of my dirty oily greasy workshop.

I'll look at raspberry pi but as I know nothing about these either, so if a second UNO could be (easily)configured to  just stream out the GCode  that is my preferred option.

Thank for all the help and suggestions. If anyone does know of an easy way to configure a UNO to do this please let me know.

Robin2

Its a complex spring so a simple mechanical geared spring former is not an option.
If possible I want to keep my expensive delicate laptop out of my dirty oily greasy workshop.
Buy a cheap used laptop ?

The oil and grease etc will be just as harmful for an Arduino - if you want a reliable system you must create a safe space for it. So why not make that space big enough to house the laptop as well?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

groundFungus

I have thought about this.  Using an Uno to read a line of Gcode and sending it to Grbl using the simple handshake is not difficult.  See the Interfacing with Grbl Wiki page.  I think that you also need a way to home the machine, jog to the starting point, set the WCS, start the job and respond to errors.  All of that means adding a display and user controls.  By the time that you are done, you have written a large part of the functionality of a program like Universal Gcode Sender.  If you can run UGS on a Pi (I don't know Pi at all) then it seems that it would be a much easier route.   Or the cheap laptop.

MorganS

Its a complex spring so a simple mechanical geared spring former is not an option.
If possible I want to keep my expensive delicate laptop out of my dirty oily greasy workshop.

I'll look at raspberry pi but as I know nothing about these either, so if a second UNO could be (easily)configured to  just stream out the GCode  that is my preferred option.

Thank for all the help and suggestions. If anyone does know of an easy way to configure a UNO to do this please let me know.
How complex? And how much of that complexity changes between different springs? I'm imagining a coil spring may have a complex end on it but you only select between 2 or 3 variations and maybe left- or right-handed versions.

I get the idea that it's not a coil spring but with the information given so far, I'm only guessing.
"The problem is in the code you didn't post."

BobP2

Thanks everyone for your thought inspiring ideas.

Workshop contamination isn't a problem for the GrBL Arduino (or a second Arduino/Raspberry pi G code sender) as I can  put them  in the remote sealed box with the stepper motor drivers and PSU. The switches to stop/start the program can be mounted on the coil winding machine and wired back to the box.

The spring winding operation should be very simple:

1 Manually load pre cut wire onto the machine (wire located by the pre formed spring end loop)
2 Press start button.
3 GrBL winds a couple of closed turns (pitch = wire thickness)
4 GrBL winds 20 open turns at  my programmed pitch distance
5 GrBL winds a couple of closed turns (pitch = wire thickness)(the pre-cut wire falls out of the travelling wire guide as the second closed turn completes)
6 GrBL fast returns both stepper motors to (almost)the start position
GrBL slowly returns both stepper motors to just beyond their start position (but mechanical start position switches remove the enable signal to the stepper drivers at the instant the zero position is reached to ensure everything is properly positioned for winding the next spring).
7 Manually remove the wound spring 
8 GoTo 1 above .


Obviously a PC  will need to be connected during machine/program debugging.

Error messages won't come back from the GrBL arduino as there won't be any (program already debugged)

As the application is slow and simple I think the simple streaming protocol method is OK (many thanks for the link  explaining how the GrBL program works).

If my coil wing machine works well I might look at converting my milling machine to perform simple repetitive CNC operations as well.

Thanks again

BobP2

Go Up