Grbl on Arduino Mega

Discussion about the arduino based g-code interpreter, grbl

Grbl on Arduino Mega

Postby MLange » Thu Apr 19, 2012 2:47 am

I noticed on the Grbl website that the Arduino Mega "Doesn't Work" with Grbl. I'd imagine that has only to do with pins and maybe some registers?

I'm looking at making a Mega shield not entirely unlike the RAMPS setup, I'm just wondering if it's possible to modify the code to get it working on an Atmega1280 or 2560 vs, say, adding an atmega328 to the shield as a co-processor (of sorts) to deal solely with GRBL.
Shapeoko #280 (Inventables Batch #1)
MLange
 
Posts: 69
Joined: Tue Apr 10, 2012 8:23 am
Location: Ottawa, ON, Canada

Re: Grbl on Arduino Mega

Postby edwardrford » Thu Apr 19, 2012 3:23 am

I know the 3D printer people use parts of grbl in the Sprinter/Marlin firmware and those run on the Mega, so you're probably right, only light modifications, although Alden would be much better at addressing that.

Frankly, I'm not interested in porting it to Mega. What I am interested in doing is exactly what I think you're talking about with the 'co-processor'. Basically adding functionality based off another arduino.

I've got an NES controller, SD card streamer, LCD display, on my short list of items I'd like to add to my rig. I don't have the C chops to incorporate them into the standard grbl codebase. But, I know I can add them with a second arduino. yeah, maybe it's a shortcut, but that's OK with me.

If you're interested in collaborating, let me know and maybe we can get a short roadmap laid out. I already have the SD card streamer working, and I have a good idea how the NES controller can be used as a pendant: http://youtu.be/6jYcv4afsP8

-Edward
Shapeoko #0 - a couple of upgrades.
edwardrford
 
Posts: 754
Joined: Mon Apr 09, 2012 5:40 pm
Location: Dixon, IL

Re: Grbl on Arduino Mega

Postby MLange » Thu Apr 19, 2012 4:05 am

As far as a pendant, I was thinking of using a Wii Nunchuck (Analog stick, two buttons, and accelerometer), as off-brand ones can be purchased for $5, though the analog stick probably wouldn't be the best compared to the NES controller.

As for the shield I'm thinking of, it could be doable with a 16-bit SPI port expander as opposed to the extra pins afforded by the MEGA. I was thinking of a front-end with an LCD/VFD display, a rotary encoder w/switch, an SD card slot and a button or two. I already have the schematic whipped up for another project I am working on; the entire thing would run off of a 2x10 header for SPI, power and interrupts.

For prototyping, you could always grab an LCD/buttons shield, Adafruit has one that uses I2C, though to be fair, I've had issues in the past on Arduinos with Serial and I2C not playing nicely together without having delay()s everywhere in the code, as apparently the hardware Serial and I2C use some of the same registers. I'm not sure if the SPI library does the same.

As far as other stuff, I did a kind of 'idea dump' over on my Wiki userpage.
Shapeoko #280 (Inventables Batch #1)
MLange
 
Posts: 69
Joined: Tue Apr 10, 2012 8:23 am
Location: Ottawa, ON, Canada

Re: Grbl on Arduino Mega

Postby DrRob » Thu Apr 19, 2012 12:10 pm

The Grbl folks have given me very quick and thorough answers when I've raised questions here: https://github.com/grbl/grbl/issues?utf8=%E2%9C%93
Perhaps they could help you with the Arduino Mega question?

Rob.
DrRob
 
Posts: 60
Joined: Mon Apr 09, 2012 5:49 pm
Location: Cambridge, UK

Re: Grbl on Arduino Mega

Postby MLange » Thu Apr 19, 2012 4:46 pm

Thanks, DrRob, I'll lob the question at them and see what happens.

I think there might also be an issue with the fact that the GRBL code, enhanced as it is, likely takes up most of the CPU time, and any kind of interrupts or other CPU-hogging would freeze it in its tracks. The Arduino MEGA and UNO both run at 16Mhz, the only real advantage is to the MEGA are the added features like 3 TX/RX pairs and a bunch more digital and analog I/O, along with more SRAM.
Shapeoko #280 (Inventables Batch #1)
MLange
 
Posts: 69
Joined: Tue Apr 10, 2012 8:23 am
Location: Ottawa, ON, Canada

Re: Grbl on Arduino Mega

Postby roberlin » Fri Apr 20, 2012 2:25 pm

So, I assume these second arduino addons would work simply feeding the GRBL arduino its gcode via serial pins directly? (bypassing the usb)
I like this idea.

It seems like you could do the same thing with tinyg in place of grbl. Does anybody know for sure whether the stock tinyg firmware supports something like this?
(have not ordered my electronics yet and trying to decide between tinyg and grblshield).
roberlin
 
Posts: 59
Joined: Tue Apr 10, 2012 12:12 pm
Location: Baton Rouge, Louisiana

Re: Grbl on Arduino Mega

Postby edwardrford » Fri Apr 20, 2012 2:48 pm

That's exactly how I was using the second arduino when I setup the SDcard streamer. Used 1 arduino to read the SD card, then connected (tx->rx, rx->tx) the two arduino's together with a couple of jumper wires. I also connected their grounds, don't know if that' necessary though.

Worked like a charm. The only 'hack' was to add a type of hardware flow control. otherwise the SDcard arduino would overflow the grbl Arduino's buffer immediately.

-Edward
Shapeoko #0 - a couple of upgrades.
edwardrford
 
Posts: 754
Joined: Mon Apr 09, 2012 5:40 pm
Location: Dixon, IL

Re: Grbl on Arduino Mega

Postby MLange » Sat Apr 21, 2012 12:36 am

Apparently it's just an issue of changing pin assignments and registers around to make it work on the Arduino Mega. I'm curious, of course, if there will be enough clock cycles left over to handle all of the extra fun stuff like LCD displays, SD cards, etc...

From the looks of it, SD Card support is on the grbl list of "possible additions", though it seems to be more on their 'far future' list of additions; however, it seems that they want to progress to v1.0 before branching out to different hardware (ie, Arduino Mega, etc).

Would you be averse to a shield that is a bit longer than the Arduino to be able to house 4 drivers, an ATMega, etc?
Shapeoko #280 (Inventables Batch #1)
MLange
 
Posts: 69
Joined: Tue Apr 10, 2012 8:23 am
Location: Ottawa, ON, Canada


Return to GRBL

Who is online

Users browsing this forum: No registered users and 2 guests