<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Why is everyone using arduinos to interpret gcode?</title>
        <description>Hi Everyone,

I had a look at electronics yesterday, thinking about what I would need to build a new reprap (possibly a mendel 90 or similar). I noticed that almost all are based on the arduino, they usually convert gcode into movement using the 16/20MHz arduino and are also limited on pins. I had an idea for a different approach which would be lower cost and higher performance.

As far as I see it, there are two operations involved in controlling a CNC machine. The first is converting gcode into actual positions at particular times. The second is to toggle various pins at the right times to make the stepper motors move to the required position at the right time (I&#039;ve ignored the heater control here as it isn&#039;t going to be limited by the processor speed). I don&#039;t understand why the gcode conversion is done in the arduino and not on the host pc as its pretty unsuited to the task. Its also not necessary to do the gcode conversion just in time as it looks pretty deterministic.

When processing gcode, the task is to make sure that the different motors run at the correct relative speeds to follow the right path. gcode is roughly made up of a series of positions and max speeds (ignoring the heaters again) which just needs to be converted into a waveform to be applied to a series of parallel pins. When the resoultion gets too high - i.e. when I export an STL file with 0.1mm resolution without thinking - the printer judders as it can&#039;t keep up. I&#039;m guessing this is related to the processing power of the arduino, and also the requirement to do that processing just in time as there&#039;s limited space in the buffer, accentuated by needing to convert text to numbers because we&#039;re using a text protocol. As an alternative, I wanted to build the conversion part of the firmware to run on a pc, and then pipe the actual motor commands to the electronics using a raw binary format. This way, I&#039;d get the benefit of massive amounts of memory and processing power when interpreting gcode and also be able to do all the work in advance, so no juddering as we&#039;d have a very constant stream of commands. Has this been done before? It would be the equivalent of a software modem which is a good example of a low cost device.

Thinking about electronics and firmware, I would just need a basic firmware that handles updating motor positions at regular intervals (timed interrupt) from some sort of fifo buffer and a background task that handles keeping the buffer full. Some of the higher pin count pics (£2-3) look like they could control 8 steppers and 6 heaters/fans pretty easily. Stepper drivers are relatively cheap if you buy the chips rather than pololus (£2-3x8=£16-24) so we might be able to hit ~£50 for a complete board, with hopefully much better performance than the arduino based boards, and space for many more steppers and extruders.

If anyone&#039;s tried this I&#039;d be interested to hear how you got on.

Regards
Pete</description>
        <link>https://reprap.org/forum/read.php?13,145515,145515#msg-145515</link>
        <lastBuildDate>Sat, 10 Oct 2026 12:41:27 -0400</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,448232#msg-448232</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,448232#msg-448232</link>
            <description><![CDATA[ @pete-theobald<br />
So what was the end result of your test boards? I read through this topic in hopes of a resolution.]]></description>
            <dc:creator>treflip</dc:creator>
            <category>Controllers</category>
            <pubDate>Sat, 27 Dec 2014 20:25:50 -0500</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,155716#msg-155716</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,155716#msg-155716</link>
            <description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong></strong><br />Also, adding complex collision detection algorithms or lets say a toolpath creation and simulation is problematic because of the process speed a arduino has.</div></blockquote>
<br />
Controllers by definition don't do tool path generation. Neither Arduino based ones nor EMC(2).]]></description>
            <dc:creator>Traumflug</dc:creator>
            <category>Controllers</category>
            <pubDate>Fri, 21 Sep 2012 06:21:55 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,155609#msg-155609</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,155609#msg-155609</link>
            <description><![CDATA[ Thanks for responding, but on the matter of the subject, I guess the keyword I was missing was "realtime", because all CNC CAM are actuating the motor drives in realtime, with some multiple threads or processes running at the same time. Now for the 3d printers, the realtime part is done in the Arduino/electronic with PWMs and such, with queued-in commands (gcode lines) and having a "realtime" response to the PC host is relative to the usb communication link. Also, adding complex collision detection algorithms or lets say a toolpath creation and simulation is problematic because of the process speed a arduino has. So maybe one way to go is to add an expansion connector, akin to the parallel port and have a more direct interface with the electronics/hardware. But then again, the parallel port is somewhat on the brink of extinction, am I right? So I'd say, let's make something that works on the pci-e, but then you'd need a really faster uC to do the job... All this is telling me is CNCs need to be a little more like 3d printers (usb connection part), and 3d printers need to be a little more like CNCs (CAM "realtime" part). I'm still a newb so tell me if I'm wrong, thank you.<br />
<br />
Now, for the precedent post, I'm really grateful for the info and I will look into the GCodes more deeply because, from what I understand gEDA/pcb can produce "non advanced g-code". Maybe casting them in the Pronterface would give me a better flow to execute double sided boards milled PCBs but today I will be reading more on pyCAM, which seems suited to what I do. And from what I read around here, I guess its not so bad to throw the gcodes directly using the pronterface but I believe pyCAM will really help with the organisation, even if it's not driving the printer/cnc directly, I can still simulate after in emc2 and run the gcodes with Printrun. [<a href="http://sourceforge.net/apps/mediawiki/pycam/index.php?title=Features" target="_blank"  rel="nofollow">sourceforge.net</a>]<br />
<br />
Thanks everyone,<br />
MikE]]></description>
            <dc:creator>Mevon</dc:creator>
            <category>Controllers</category>
            <pubDate>Thu, 20 Sep 2012 16:46:11 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,155513#msg-155513</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,155513#msg-155513</link>
            <description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong></strong><br />Now, where I fall short is the CAM are all made for CNC and not usb electronics, so using the printer/printer electronics to do some CNC work is kinda hard with Pronterface/Printrun and Slic3r...</div></blockquote>
<br />
Huh? G-code is G-code and a G-code compiler doesn't care the slightest how the electronics makes machine movement from that. I run G-code made on Catia with Teacup just fine. The same G-code simulates in EMC2 perfectly as well.<br />
<br />
<blockquote class="bbcode"><div><small>Quote<br /></small><strong></strong><br />like mirror X or Y axis for double sided pcb milling</div></blockquote>
<br />
All G-code compilers making G-code for PCB milling I'm aware of do that already.]]></description>
            <dc:creator>Traumflug</dc:creator>
            <category>Controllers</category>
            <pubDate>Thu, 20 Sep 2012 05:47:37 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,155407#msg-155407</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,155407#msg-155407</link>
            <description><![CDATA[ I thought GCodes were for CNCs and then adapted to Repraps...<br />
<br />
Anyways, I don't know this seems obvious to me but, linuxCNC/emc2 uses drivers for steppers on the parallel port, while arduino based electronics also uses stepper drivers. Now, any CNC use a CAM that takes the .STL and produce gcodes or whatever signals on the parallel bus to control the drivers, but the reprap does no computing (else the PID for the heaters and maybe a little accel/decel for the movements). The point is, for a reprap, all is done in the slicing of the stl on the host pc, so the gcodes are not generated by the arduino, but simply interpreted and the printer is doing what its told to.. So for linuxCNC to "print", its just a matter of sending the gocodes on the usb serial connection, queue in 8 lines of gcode in advance and keep 'em flowing (sounds easier said then done... :S).<br />
<br />
So what Im doing here will sound like heretic to y'all, I'm actually using Gen7 electronics to drive my tabletop Mantis to mill (eventually :P) PCBs. Now, where I fall short is the CAM are all made for CNC and not usb electronics, so using the printer/printer electronics to do some CNC work is kinda hard with Pronterface/Printrun and Slic3r... Though the gcodes come from the CAD I use for creating the pcb, getting the work done would be nicer with a CAM for cnc, so maybe a plug-in for linuxCNC/emc2 to use the Printrun's console API. Now I'm at the point where I will add gcodes in the firmware to do whats needed (like mirror X or Y axis for double sided pcb milling) but if anyone knows a good tutorial on printing a double sided pcb on a diy tabletop mil or anything on using reprap electronics to do some milling work would be nice.<br />
<br />
Thanks in advance,<br />
MikE]]></description>
            <dc:creator>Mevon</dc:creator>
            <category>Controllers</category>
            <pubDate>Wed, 19 Sep 2012 16:41:11 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,155137#msg-155137</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,155137#msg-155137</link>
            <description><![CDATA[ I think you have to try. Without actually trying it's difficult to do a good judgement, as often hidden details, like the 32-bit division in the acceleration algorithm, turn out to be major obstacles.]]></description>
            <dc:creator>Traumflug</dc:creator>
            <category>Controllers</category>
            <pubDate>Tue, 18 Sep 2012 06:10:33 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,154784#msg-154784</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,154784#msg-154784</link>
            <description><![CDATA[ Hi, I am new here and have started working on a RepRap-related project for OSE [<a href="http://opensourceecology.org/wiki/CNC_Torch_Table" target="_blank"  rel="nofollow">opensourceecology.org</a>]. The first iteration has been done with grbl on Arduino<br />
<br />
I have been thinking about converting G-Code to an intermediate PVT (position-velocity-time) waypoint format, then using Arduino to generate the step/direction (using cubic spline interpolation) from that. This is similar to some CANOpen DS402 motion control that Maxon, etc. do in their servo drive modules. PVT mode is designed for splicing together continuous smooth moves out of segments, unlike the trapezoidal point-to-point trajectory generators in L6740 etc.  For attaining the same deviation from ideal path it takes a lot fewer PVT (spline) segments than linear segments so bandwidth to Arduino, buffer size, etc should be a non-issue.<br />
<br />
Another thing I am contemplating is using ROS protocol to stream data to the Arduino (I have used [<a href="http://www.ros.org/wiki/rosserial_arduino" target="_blank"  rel="nofollow">www.ros.org</a>] successfully in a past project), ROS also provides a time sync service which could keep multiple Arduino slaves in sync if some grander multi-axis scheme materializes. (A 5-axis CNC torch table that pivots the torch head to do angle cuts would be cool...) I have tried rosserial in Raspberry Pi but I think the serial_node.py script needs optimization: [<a href="http://wiki.jigsawrenaissance.org/ROS_on_RaspberryPi#5-Sep-2012" target="_blank"  rel="nofollow">wiki.jigsawrenaissance.org</a>]<br />
<br />
Agreed that when we use big buffers to handle communication stack latency (e.g. in USB, serial, ethernet) that there has to be another route for homing and perhaps status feedback but that fits pretty cleanly into ROS comms architecture just by adding another topic or service.<br />
<br />
All this is handwaving right now, any comments?<br />
<br />
Chuck]]></description>
            <dc:creator>ChuckH</dc:creator>
            <category>Controllers</category>
            <pubDate>Sun, 16 Sep 2012 17:53:26 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,148279#msg-148279</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,148279#msg-148279</link>
            <description><![CDATA[ nophead Wrote:<br />
-------------------------------------------------------<br />
&gt; 8 bit PICs run four times slower for a given clock<br />
&gt; speed. I.e. they need four clocks for each<br />
&gt; instruction. And the instructions are a lot more<br />
&gt; primitive than AVR so C runs considerably slower<br />
&gt; on a PIC18.<br />
<br />
Yep, PICs run one instruction per 4 cycles so 20MHz is only 5MIPs. I think they're also a risc processor which means they don't have the benefit of specialist instructions. that said, they have DMA modules, lots of timers and PWM modules so you can keep a fair bit of stuff running in separate modules. I'm planning to use DMA to receive messages, PWM modules to run heated beds, extruders and fans and the rest can happen in code as it doesnt need to run so fast.<br />
<br />
Pete]]></description>
            <dc:creator>pete-theobald</dc:creator>
            <category>Controllers</category>
            <pubDate>Wed, 15 Aug 2012 08:31:57 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,147468#msg-147468</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,147468#msg-147468</link>
            <description><![CDATA[ 8 bit PICs run four times slower for a given clock speed. I.e. they need four clocks for each instruction. And the instructions are a lot more primitive than AVR so C runs considerably slower on a PIC18.]]></description>
            <dc:creator>nophead</dc:creator>
            <category>Controllers</category>
            <pubDate>Fri, 10 Aug 2012 14:27:03 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,147457#msg-147457</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,147457#msg-147457</link>
            <description><![CDATA[ pete-theobald Wrote:<br />
-------------------------------------------------------<br />
&gt; sam0737 Wrote:<br />
&gt; --------------------------------------------------<br />
&gt; -----<br />
&gt; &gt; 1Mbps on UART is hard, I expect noise, clock<br />
&gt; &gt; glitches may ruins the packets.<br />
&gt; &gt;<br />
&gt; I'm a bit worried about that but most firmwares<br />
&gt; are running rs232 at 250Mbaud (except its a short<br />
&gt; hop from the ft232 to the avr, but I only need<br />
&gt; 500kbaud max and probably less most of the time<br />
You must have miscounted the zero. Marlin default is 250Kbps, or 0.25Mbps, or 250000 bit per second.<br />
<br />
<br />
&gt; &gt;...but does that mean now I<br />
&gt; &gt; have to buy a RPi in additional to the<br />
&gt; &gt; Arduino/AVR?<br />
&gt; &gt; <br />
&gt; I never planned to have an AVR in my setup, just<br />
&gt; an 80p pic on each controller board.<br />
PIC? It's just as fast as AVR - they are the same class of MCU.]]></description>
            <dc:creator>sam0737</dc:creator>
            <category>Controllers</category>
            <pubDate>Fri, 10 Aug 2012 14:00:36 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,147325#msg-147325</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,147325#msg-147325</link>
            <description><![CDATA[ <a href="http://objects.reprap.org/wiki/GCodes" target="_blank"  rel="nofollow">G-code</a> is the command protocol that most RepRaps use.]]></description>
            <dc:creator>rhmorrison</dc:creator>
            <category>Controllers</category>
            <pubDate>Fri, 10 Aug 2012 02:42:02 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,147277#msg-147277</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,147277#msg-147277</link>
            <description><![CDATA[ sam0737 Wrote:<br />
-------------------------------------------------------<br />
&gt; 1Mbps on UART is hard, I expect noise, clock<br />
&gt; glitches may ruins the packets.<br />
&gt;<br />
I'm a bit worried about that but most firmwares are running rs232 at 250Mbaud (except its a short hop from the ft232 to the avr, but I only need 500kbaud max and probably less most of the time<br />
 <br />
&gt;...but does that mean now I<br />
&gt; have to buy a RPi in additional to the<br />
&gt; Arduino/AVR?<br />
&gt; <br />
I never planned to have an AVR in my setup, just an 80p pic on each controller board. I sent a couple of boards off to production earlier this week. The cost of parts for a single board is about £9 and that includes pcb, a single stepper driver, a single power mosfet, 2 endstop headers and a fan header. 4 or 5 of those boardshooked up in parallel would run the average machine and cost £50-£60 (including the interface board at about the same cost). They all take commands from an interface board which is basically a board with an ATX connector, MCP2200 (usb to serial that can be reprogrammed) and an RS485 bus driver. The MCP2200 needs some revised firmware to handle sending commands at defined times, which takes the timing problem away from the host pc. If I combine that with a raspberrypi i've got a full set of electronics with a lot of processing power for less than £100 and I have a decent amount of power to run more complex algorithms (handling circles for instance).<br />
<br />
Anniraks idea is a bit less dumb than mine as it takes commands defining paths rather than individual steps which would mean it should get away with lower bandwidth. I think bandwidth isn't really the big problem, its the lack of buffers, especially if usb is only sending packets at 1mS timeslots. SD card won't have that problem as its basically reading the gcode in using SPI which the avr has direct control of. Keeping the buffers full will be a lot easier with a binary protocol as (especially on the MCP2200 with 256bytes of DMA RAM) it will be easier to pick in a few mS of commands.<br />
<br />
I'm not worried about using the host for something else. I have a mini-itx box I use for printing but a £25 raspberrypi should be more than enough and with £60 of electronics and a £15 ATX power supply you could have a full set of electronics for £100.<br />
<br />
Pete]]></description>
            <dc:creator>pete-theobald</dc:creator>
            <category>Controllers</category>
            <pubDate>Thu, 09 Aug 2012 18:06:05 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,147260#msg-147260</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,147260#msg-147260</link>
            <description><![CDATA[ What is the Gcode?]]></description>
            <dc:creator>hondalawnparts1</dc:creator>
            <category>Controllers</category>
            <pubDate>Thu, 09 Aug 2012 17:22:38 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,147241#msg-147241</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,147241#msg-147241</link>
            <description><![CDATA[ My solution shouldn't require any additional controllers; just the RPi since I'm using SPI-based, fully integrated stepper motor motion controllers.<br />
<br />
R2C2 looks pretty nice.  My only complaint about it is the lack of modular expansion of stepper drivers.  I'm constantly debating that tradeoff, but I think there's some significant benefits to be had by going with the RPi.]]></description>
            <dc:creator>Annirak</dc:creator>
            <category>Controllers</category>
            <pubDate>Thu, 09 Aug 2012 16:05:44 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,147215#msg-147215</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,147215#msg-147215</link>
            <description><![CDATA[ 1Mbps on UART is hard, I expect noise, clock glitches may ruins the packets.<br />
<br />
People want print on SD for 2 reasons, <br />
 1. they need not to keep the computer running the host, connecting to the USB. Especially when Diablo 3 (insert your favorite CPU intensive program) and printing host doesn't mix well.<br />
 2. Performs better on small arc/corner because of the processing latency.<br />
Why it prints better when prints from SD? I can't say for sure but believe the latencies are introduced in the host program. It has a high jitters (inconsistency latency) to read a wake up the host thread, read gcode line, send it down to the USB.<br />
<br />
So if you take away the gcode-&gt;step calculation functions from the MCU, the host must do it.  And if I want to print from SD because of reason 1 (free my computer from running the host because I want to play Diablo 3 while printing), there must be some other kind of hardware running the host. RPi would do the job...but does that mean now I have to buy a RPi in additional to the Arduino/AVR?<br />
<br />
Then why not just take the R2C2 way...dump the AVR, just do everything with ARM. Sounds more cost effective, less problem (high speed communication), less complex to me.]]></description>
            <dc:creator>sam0737</dc:creator>
            <category>Controllers</category>
            <pubDate>Thu, 09 Aug 2012 13:19:32 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146708#msg-146708</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146708#msg-146708</link>
            <description><![CDATA[ I think the point is not problems with bandwith between storage medium and host, more likely the problems would be because of latency between the host and arduino over USB. <br />
<br />
USB (at least &lt;=2) is not very well suited for low/guaranteed latency transfers. <br />
This is (partially) why many prefer firewire for pro/prosumer audio "cards".<br />
<br />
I don't have any direct insights about the communication in the reprap specific case, but unless it's operating in some low speed usb 1 mode, the bandwith should not be the issue.]]></description>
            <dc:creator>anwe79</dc:creator>
            <category>Controllers</category>
            <pubDate>Tue, 07 Aug 2012 08:56:10 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146582#msg-146582</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146582#msg-146582</link>
            <description><![CDATA[ DeuxVis Wrote:<br />
-------------------------------------------------------<br />
&gt; USB communication doesn't seem fast enough for a<br />
&gt; lot of little moves following each other - like in<br />
&gt; a tiny circles drawn using way too small lines.<br />
&gt; <br />
&gt; People had noticeable improvement in print quality<br />
&gt; using Sd card on the controller, instead of USB<br />
&gt; communication from the host - removes the short<br />
&gt; pauses.<br />
&gt; Note that Nophead solution - using ethernet - is<br />
&gt; probably good for that too.<br />
<br />
I may be incorrect here, but it would seem to me that you're mixing a few different operating modes.  The existing USB solution is USB-&gt;Serial conversion, while what I'm suggesting is using a CPU capable of being a USB host and using USB mass storage.  USB Mass storage is limited at 480Mbps, though individual USB drives' real world read performances seem to range from 15 to 40 MBps (120-320Mbps) for name-brand USB flash drives.  Considering the SPI data rate limit on an AVR is fosc/2, that means the absolute limit of performance would be 10Mbps with a 20MHz crystal.<br />
<br />
Based on the above, I can't see a USB mass storage source being worse than a SD card.]]></description>
            <dc:creator>Annirak</dc:creator>
            <category>Controllers</category>
            <pubDate>Mon, 06 Aug 2012 15:32:22 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146536#msg-146536</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146536#msg-146536</link>
            <description><![CDATA[ DeuxVis Wrote:<br />
-------------------------------------------------------<br />
<br />
&gt; USB communication doesn't seem fast enough for a<br />
&gt; lot of little moves following each other - like in<br />
&gt; a tiny circles drawn using way too small lines.<br />
&gt; <br />
&gt; People had noticeable improvement in print quality<br />
&gt; using Sd card on the controller, instead of USB<br />
&gt; communication from the host - removes the short<br />
&gt; pauses.<br />
&gt; Note that Nophead solution - using ethernet - is<br />
&gt; probably good for that too.<br />
<br />
If sdcard works but usb doesnt then its clearly bandwidth rather than time taken to interpret text based gcode. I'm planning to send binary packets made up of 4-5 bytes for each step. I think I can get decent speeds at 500kbps so USB should be plenty.<br />
<br />
p]]></description>
            <dc:creator>pete-theobald</dc:creator>
            <category>Controllers</category>
            <pubDate>Mon, 06 Aug 2012 08:31:07 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146534#msg-146534</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146534#msg-146534</link>
            <description><![CDATA[ Annirak Wrote:<br />
 <br />
&gt; The printer raspberry pi has a pair of USB ports. <br />
&gt; Why do you need print from SD?  You have print<br />
&gt; from USB.<br />
<br />
<br />
USB communication doesn't seem fast enough for a lot of little moves following each other - like in a tiny circles drawn using way too small lines.<br />
<br />
People had noticeable improvement in print quality using Sd card on the controller, instead of USB communication from the host - removes the short pauses.<br />
Note that Nophead solution - using ethernet - is probably good for that too.]]></description>
            <dc:creator>DeuxVis</dc:creator>
            <category>Controllers</category>
            <pubDate>Mon, 06 Aug 2012 08:27:34 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146415#msg-146415</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146415#msg-146415</link>
            <description><![CDATA[ sam0737 Wrote:<br />
-------------------------------------------------------<br />
&gt; And there is a big "but" if the position<br />
&gt; computation is moved to the host - you lose the<br />
&gt; print by SD function!  Or you need a host on the<br />
&gt; printer Raspberry Pi?<br />
<br />
The printer raspberry pi has a pair of USB ports.  Why do you need print from SD?  You have print from USB.]]></description>
            <dc:creator>Annirak</dc:creator>
            <category>Controllers</category>
            <pubDate>Sun, 05 Aug 2012 15:30:15 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146386#msg-146386</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146386#msg-146386</link>
            <description><![CDATA[ sam0737 Wrote:<br />
-------------------------------------------------------<br />
&gt; pete-theobald I think you have raised two<br />
&gt; questions-<br />
&gt; 1. Serial link between is too slow to transfer<br />
&gt; tons of GCode, especially during arc<br />
&gt; 2. Arduino CPU is not fast enough to compute the<br />
&gt; steps.<br />
&gt; I think we should move to a higher speed<br />
&gt; interface, be it normal USB (12Mbps instead of<br />
&gt; serial 0.25Mbps) or even Ethernet - that should be<br />
&gt; fast enough, and easy enough. Then also compute<br />
&gt; the steps on the host and buffered on the chip.  I<br />
&gt; just wish Arduino could made a board based on a<br />
&gt; AVR chip with built-in USB support.<br />
&gt; <br />
&gt; I would imagine that the MCU would still need its<br />
&gt; own step execution logic of some sort, because<br />
&gt; otherwise homing would be very difficult to do.<br />
<br />
I finished laying out my modular boards and I think it should just about work. What i've done is very reliant on a serial bus so if I can't get the baud rate up, I won't be able to get it to work. My calculations say that 250mm/s (along one axis) would need just over 1Mbps so this is going to be more than enough. Here's the calculations:<br />
<br />
Max velocity (mm/s)	250<br />
steps per revolution	3200 (200x16)<br />
mm per revolution	40 (16tooth t2.5)<br />
steps per mm	80<br />
max steps/s	20,000<br />
bits per byte	14 (uart with start, stop and 9th bit for addressing)<br />
address bytes	1 (address bit + number hardwired into board using solder jumpers)<br />
command bytes	1 (move to, change pid constants, control fan or whatever)<br />
value bytes	3 (data value, i.e. absolute position to move to. 3 bytes would give me a total range of over 200 metres on each axis)<br />
bits per packet	56<br />
bits per second	1120000<br />
Mbps	1.0681152344<br />
<br />
I want to always transfer absolute positions as it allows for some error correction. It allows me to send the same message multiple times just in case without risking multiple steps. Also, it means that if a packet is completely missed, it just causes a glitch in the microstepping and the next value that comes through will pick it up (This seems like a benefit of microstepping as normal stepping might jump back a step if it missed a could of packets)<br />
<br />
Here's an overview of what i've created and some maths that should help answer your points about communications speed.<br />
<br />
<u>Modular design</u><br />
I laid out a single module which controls a single stepper motor, a single resistive load (heated bed or extruder), 2 end stops and a fan (2, 3 or 4 pin). The idea is that a number of modules can be positioned on a bus which supplies power and communications. The design has pins on one edge laid out on a 2.54mm grid so it can use veroboard as a backplane.<br />
<br />
<u>Inter module comms</u><br />
Each module has an SN75176 bus driver so its effectively running an RS485 bus. I started off wanting to just wire the TX and RX pins directly to a bus but thought i'd struggle to get the bandwidth up high enough is I didn't use a proper line driver. Also, using the tristate on the pic pins to arbitrate the bus is asking for trouble!. I'm expecting the majority of the data to be going from the host computer to the module. The bus is attached using a 4 pin header. Wiring is<br />
1, 2 - differential comms<br />
3 - 5v for CPU<br />
4 - GND<br />
<br />
<u>Power</u><br />
I have a 6 pin header for supplying power. The wiring is as follows<br />
1,2 - 12v<br />
3,4 - 5v<br />
56 - GND<br />
<br />
<u>Stepper driver</u><br />
I copied the reference design for the A4982 stepper driver onto the board but i've created an exposed pad on the back for heatsinking instead of internal groundplanes. I added mounting holes for a slab of aluminium for a heatsink. The board is similar to a pololu in terms of driving the stepper, the price seems about the same but they're easy to wire in parallel and have a couple of extra modules as well.<br />
<br />
<u>Bed/extruder driver</u><br />
I wired in a p channel MOSFET with a massive 12v plane. I reckon it could handle 5A to drive a heated bed. Its attached to a PWM capable pin on the pic but I don't think you need even medium frequency to run a bed or extruder. Once a second is probably fine.<br />
<br />
<u>end stops</u><br />
2 end stops just to be sure.<br />
<br />
<u>Fan control</u><br />
I added a 4pin header and a jumper to allow a PWM signal to either control the power line (mosfet) or onto the 4th wire for pwm control. The 3rd wire is connected to the timer0 clk line so we can measure fan speed. Not really important but it means we have a controllable fan for every board.<br />
<br />
<u>Controller board</u><br />
The controller board is the cleaver part in all this. I decided I won't even attempt to handle the timing directly in the host pc, if usb really has 1ms resolution then i'm glad I haven't! I have a board which distributes power to the bus and also handles passing messages. The power is taken from an ATX connector and 2x disk drive connectors. That seems to be the lowest cost power supply for repraps. The comms are handled by a pic (18f14k50). This chips is used for the MCP2200 which are around £2 each and can connect as a full speed usb device. The chip needs to receive messages from the host pc and distribute them to the bus. The difference to a normal serial convertor is that it needs to handle the timing. I intend to send a stream of data equivalent to single steps, but I will also interleave specific wait periods. The wait commands are the clever bit in getting accurate time control. Its not really real time as it can only really playback a stream of data. If it wants to do any real time control it needs to give up the bus for modules to reply which means its only really useful for infrequent checks on temperatures. It might be possible to put pauses in the hosts control program to give some time to query all the modules for their status.<br />
<br />
I'm going to get a few boards made up (Thank annirak for the tip about iteadstudio!). If I can get them to work i'll look at putting together a kit of parts for anyone whos interested.<br />
<br />
Pete]]></description>
            <dc:creator>pete-theobald</dc:creator>
            <category>Controllers</category>
            <pubDate>Sun, 05 Aug 2012 13:13:09 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146320#msg-146320</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146320#msg-146320</link>
            <description><![CDATA[ And there is a big "but" if the position computation is moved to the host - you lose the print by SD function!  Or you need a host on the printer Raspberry Pi?]]></description>
            <dc:creator>sam0737</dc:creator>
            <category>Controllers</category>
            <pubDate>Sun, 05 Aug 2012 03:43:31 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146302#msg-146302</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146302#msg-146302</link>
            <description><![CDATA[ Linux offering a high resolution timer doesn't mean you could have a thread sleep at precisely as much as you want, for that you will need a real-time kernel, in particular even if you could control your thread, you need to make sure the data sent to the hardware as fast as possible, for that you need real time drivers for the particular hardware.<br />
<br />
That's exactly what EMC2 does when interfacing with drivers that compute acceleration profile and do the steps execution.<br />
Because of the latency problem, USB is out of the game (it's not designed to support low latency data stream consistency). Parallel port and PCI (or ISA) is a popular choice because they are directly mapped IO of the CPU. In fact, EMC2 support a tons of "steps execution device" that use parallel EPP for data transfers (not direct pinout bit-bang), or PCI. Most, if not all, are made of FPGA.<br />
<br />
Synchronization of the chip - not only you need to start all the execution precisely, you would need to change acceleration/deceleration profile in every steps execution to make sure they are in-sync. The communication channel would get real busy when drawing an arc.<br />
I just wish the chip to include a "trigger pin" - for all chip to execute all the buffered profile at the same time.  But still, profile computation and communication would still be a hard thing to solve.]]></description>
            <dc:creator>sam0737</dc:creator>
            <category>Controllers</category>
            <pubDate>Sat, 04 Aug 2012 22:48:04 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146301#msg-146301</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146301#msg-146301</link>
            <description><![CDATA[ Repetier host sends binary GCode, but it's still GCode but not computed position.<br />
<br />
EMC2 requires still relatively real-time operation for the position calculation, becasue EMC2 is not just designed for stepper but also servo motor, it is designed to compute the position every 1ms (or some other regular interval) and update the stepper driver.<br />
<br />
The stepper driver could be an old day parallel port, or a PCI card of some sort. USB is out of the game because the highest resolution (interrupt command) is just 1ms (or 0.125ms for high speed IIRC), and we don't even talk about the latency or jitter of any sort here, it's just the highest resolution offered in the spec.<br />
<br />
I understand that for steppers (not servo) we could precisely compute when to send out what steps signal.  <br />
IIRC, EMC2 does not support pre-computing all these and send them to a buffering device of steps execution. First, for the servo support, Secondly, logics (like end-stops, automatic Z-zeroing, or other tons of logic - because EMC2 even supports ladder) could be very tricky.<br />
<br />
pete-theobald I think you have raised two questions-<br />
1. Serial link between is too slow to transfer tons of GCode, especially during arc<br />
2. Arduino CPU is not fast enough to compute the steps.<br />
I think we should move to a higher speed interface, be it normal USB (12Mbps instead of serial 0.25Mbps) or even Ethernet - that should be fast enough, and easy enough. Then also compute the steps on the host and buffered on the chip.  I just wish Arduino could made a board based on a AVR chip with built-in USB support.<br />
<br />
I would imagine that the MCU would still need its own step execution logic of some sort, because otherwise homing would be very difficult to do.]]></description>
            <dc:creator>sam0737</dc:creator>
            <category>Controllers</category>
            <pubDate>Sat, 04 Aug 2012 22:26:39 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146156#msg-146156</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146156#msg-146156</link>
            <description><![CDATA[ Annirak Wrote:<br />
-------------------------------------------------------<br />
&gt; With two spare GPIO, you can have enable-in and<br />
&gt; enable-out, which allows you to set up each device<br />
&gt; without jumpers, based on its position in the<br />
&gt; chain.<br />
<br />
I moved a few pins around and freed up 8 pins (coupled with ICSP). You should be able to see the circuit diagram here [<a href="https://github.com/pete-theobald/reprap_modular_electronics/blob/master/reprap_modular_electronics/reprap_modular_electronics.pdf?raw=true" target="_blank"  rel="nofollow">github.com</a>]<br />
and the pcb here [<a href="https://github.com/pete-theobald/reprap_modular_electronics/blob/master/reprap_modular_electronics/reprap_modular_electronics_board.pdf?raw=true" target="_blank"  rel="nofollow">github.com</a>].<br />
The boards 50x50 and I don't see any reason to go smaller. I want to get a couple of mounting holes between the stepper driver and the big mosfet so I can fix a slab of aluminium to the back. I also need to think a bit more about the fan controller. It would only work with a 4 pin fan at the moment so I might need another mosfet to control the fan power so it can handle a two pin fan.<br />
p]]></description>
            <dc:creator>pete-theobald</dc:creator>
            <category>Controllers</category>
            <pubDate>Fri, 03 Aug 2012 18:57:45 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146079#msg-146079</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146079#msg-146079</link>
            <description><![CDATA[ With two spare GPIO, you can have enable-in and enable-out, which allows you to set up each device without jumpers, based on its position in the chain.]]></description>
            <dc:creator>Annirak</dc:creator>
            <category>Controllers</category>
            <pubDate>Fri, 03 Aug 2012 09:55:54 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,146060#msg-146060</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,146060#msg-146060</link>
            <description><![CDATA[ Its probably cheaper to get a pic with a higher pin count if i'm going to use dip switches but the board area goes up and I'm sure the switches cost £1 each as well. Soldered jumpers could be quite nice as its just as easy to read the value and its not as if they will be changed regularly.. I choose one based on cost to start with. The alternatives are to hard code the number into the firmware and recompile it each time or add a jumper to activate some form of address setting mode, i.e. the controller sends an address setting message and every board with the jumper connected gets that address.<br />
p]]></description>
            <dc:creator>pete-theobald</dc:creator>
            <category>Controllers</category>
            <pubDate>Fri, 03 Aug 2012 07:32:05 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,145858#msg-145858</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,145858#msg-145858</link>
            <description><![CDATA[ pete-theobald Wrote:<br />
-------------------------------------------------------<br />
&gt; * Some way to set the nodes address. I was<br />
&gt; planning to use a dip switch but i've run out of<br />
&gt; pins. I could program it directly into eeprom but<br />
&gt; that needs the user to have a pic programmer which<br />
&gt; is another £25<br />
<br />
If you have a spare ADC pin, you could make something like a R2R DAC with the DIP switches and measure the level to decide the address.]]></description>
            <dc:creator>Annirak</dc:creator>
            <category>Controllers</category>
            <pubDate>Wed, 01 Aug 2012 20:28:04 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,145850#msg-145850</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,145850#msg-145850</link>
            <description><![CDATA[ Annirak Wrote:<br />
-------------------------------------------------------<br />
&gt; If you can keep the PCB size to 50mmx50mm or<br />
&gt; smaller, iteadstudio will manufacture 10 of them<br />
&gt; for $9.90.<br />
<br />
Funny that you say that, I just managed to get the bulk of the components to fit onto 50x50. I've put it here [<a href="https://github.com/pete-theobald/reprap_modular_electronics" target="_blank"  rel="nofollow">github.com</a>] (eagle pcb).<br />
<br />
There are loads of components missing (mainly capacitors) and I haven't quite figured out how I'm going to attach the modules to a serial bus yet. Ideally I want them to stack on top of each other, or maybe fit into a series of sockets soldered to veroboard. The main problem i've seen with pololus and my own electronics (gen6 with drivers soldered directly to pcb) is heat causing the motors to skip. I'm trying to layout the board so I can screw a strip of aluminium to the back to act as a big heatsink. An inch of aluminium sticking out either side would help alot. The board currently has:<br />
* one pic<br />
* a4982 microstepping driver with a 4 way header<br />
* 2x 6 way headers with 5v, 12v, ground, switched ground and 2 analog connections. That should be enough for an extruder and a fan.<br />
* communications using the uart. I'm hoping I can get the addressing handled using 9 bit serial and also use that as a start of frame header. I can also use the same scheme as a synchronisation signal.<br />
<br />
What it still needs is<br />
* a master node which can handle receiving signals from a host pc and sending them to the relevant address and making sure everything is kept in good time.<br />
* Some way to set the nodes address. I was planning to use a dip switch but i've run out of pins. I could program it directly into eeprom but that needs the user to have a pic programmer which is another £25<br />
* Some better routing - hopefully involving some forward planning rather than just getting stuck in. I'll have another look later in the week but i'd love to hear peoples views on how I could route around a large exposed ground plane on the underside.<br />
* Possibly a transmit signal so the boards can talk back to the controller. It would need some form of tristating and arbitration so prob best avoided, but seems a shame to miss.<br />
* A better way to connect the boards together. I've just wired in molex kk connectors as they're easy to find, but they aren't made for easy daisy chaining<br />
* ICSP header routed in (not much use without it)<br />
<br />
Let me know what you think.<br />
<br />
Pete]]></description>
            <dc:creator>pete-theobald</dc:creator>
            <category>Controllers</category>
            <pubDate>Wed, 01 Aug 2012 18:42:11 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?13,145515,145807#msg-145807</guid>
            <title>Re: Why is everyone using arduinos to interpret gcode?</title>
            <link>https://reprap.org/forum/read.php?13,145515,145807#msg-145807</link>
            <description><![CDATA[ If you can keep the PCB size to 50mmx50mm or smaller, iteadstudio will manufacture 10 of them for $9.90.]]></description>
            <dc:creator>Annirak</dc:creator>
            <category>Controllers</category>
            <pubDate>Wed, 01 Aug 2012 15:22:31 -0400</pubDate>
        </item>
    </channel>
</rss>
