4

I have read a few times1 that the Arduino Mega can struggle to perform the tasks required for 3D printer control, as the AVR chip is working at its limits, and this is why some manufacturers have moved away from the ATmega2560, to make custom (and integrated) controller boards using ARM processors.

Having just seen the latest answer to this question, Multithreading with the Arduino, on the Arduino SE site, I wondered if anyone had used a Shield Buddy in conjunction with the standard RAMPS 1.4 board?

Shield Buddy

It is pin for pin compatible with the Arduino Mega (and Arduino IDE compatible - once the appropriate add-ons have been installed), but it has a much faster three core processor. Obviously only one core would be used, leaving the other two idling, but even so the performance is apparently much better.

See Bringing Multicore To The Arduino World With ShieldBuddy TC275.

If anyone has experience of using this board, I would like to know whether it was successful or not? I don't see why it should not, although the Marlin firmware would need recompiling, for the Aurix TC275 processor. Would any improvement be seen? Is it worth paying the high price tag of £89?


1 One of the places was 3D Printering: Electronics boards:

While they work for what they’re intended to do, there are a few limitations. Arcs and circles are a little weird to program, and using these boards for something other than a cartesian 3D printer – a CNC machine, or a laser cutter, for example – is a bit out of the ordinary.

Greenonline
  • 5,831
  • 7
  • 30
  • 60
  • 1
    It's not just a matter of recompiling Marlin. You'd need to rewrite large parts of it. It may be compatible with the Arduino IDE, but that doesn't mean you can just run firmware intended for the AtMega2560 on it. All the timings (e.g. those of the pulses sent to the stepper motors) would be off, if you managed to get it to compile at all. – Tom van der Zanden Jan 16 '17 at 21:14
  • @TomvanderZanden - oh ok thanks. I haven't looked at Marlin's source code, as yet, so I wasn't aware of that. – Greenonline Jan 16 '17 at 21:32
  • 2
    I am currently trying to port the Marlin RC6 to the ShieldBuddy. I have managed to get most of it to compile and I have converted a lot of the AVR assembler to C (the TC275 is so fast that assembler code is not needed!) What I am having difficulty with is the interrupts. I can see that there is an interrupt for the serial receive and there is a timer0 interrupt for the stepper driver. Are there any others? Also, what frequency does the timer0 interrupt run at? I am doing the work in Eclipse but using the Arduino/ShieldBuddy HAL. I would welcome any help anyone can give!!! – Mike Beach Jan 25 '17 at 18:54
  • 1
    @MikeBeach This is not really the place to ask such questions. – Tom van der Zanden Jan 25 '17 at 20:23
  • @MikeBeach - Nice work, I would definitely like to hear how the work pans out. Once you get it working, your should post an answer to my question... :-) However, in the meanwhile, your question, _may_ be better suited for StackExchange Arduino, there are some clever chaps there, who may know the answer (although they maybe more ATmega oriented)... Or failing that maybe StackOverflow? – Greenonline Jan 26 '17 at 00:40

1 Answers1

2

It's not quite as simple as you would suggest.

You can't just recompile Marlin for another device. You'd need to rewrite large parts of it. It may be compatible with the Arduino IDE, but that doesn't mean you can just run firmware intended for the AtMega2560 on it. All the timings (e.g. those of the pulses sent to the stepper motors) would be off, if you managed to get it to compile at all.

As some examples, here are some pieces of code from Marlin that would be broken, as they're written directly in AVR assembly:

#define DELAY_1_NOP  __asm__("nop\n\t")
#define DELAY_2_NOP  __asm__("nop\n\t" "nop\n\t")

[...]

// ensure 100ns delay - a bit extra is fine
asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz
asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz

[...]

#define MultiU24X32toH16(intRes, longIn1, longIn2) \
asm volatile ( \
             "clr r26 \n\t" \
             "mul %A1, %B2 \n\t" \
             "mov r27, r1 \n\t" \
             "mul %B1, %C2 \n\t" \
             "movw %A0, r0 \n\t" \
             "mul %C1, %C2 \n\t" \
             "add %B0, r0 \n\t" \
             "mul %C1, %B2 \n\t" \
             "add %A0, r0 \n\t" \
             "adc %B0, r1 \n\t" \
Tom van der Zanden
  • 14,588
  • 2
  • 33
  • 60