Arduino MEGA2560 vs Arduino DUE
 
DUE
 
The DUE is the second Arduino type that i've updated for loading the AFSM. As documented some of the differences between the 2560 and the DUE, is the fact that the DUE is a 3.3Vdc board insted of 5Vdc and the DUE is much faster and has much more memory.
 
Summary Microcontroller ATmega2560
 
  • Operating Voltage 5V
  • Digital I/O Pins 54 (of which 14 provide PWM output)
  • Analog Input Pins 16
  • Current for 3.3V Pin 50 mA
  • Flash Memory 256 KB of which 8 KB used by bootloader
  • SRAM 8 KB
  • EEPROM 4 KB
  • Clock Speed 16 MHz

Summary Microcontroller Atmel SAM3X8E ARM Cortex-M3 CPU (risc processor)

  • 54 digital input/output pins (of which 12 can be used as PWM outputs)
  • 12 analog input
  • 84 MHz clock
  • USB OTG capable connection
  • 2 DAC (digital to analog)
  • 2 TWI
  • 3.3V and compliant with the 1.0 Arduino pinout.
  • 96 KBytes of SRAM.
  • 512 KBytes of Flash memory for code.
  • A DMA controller that can relieve the CPU from doing memory intensive tasks.
 
When making a serious control -i think- the differences of 3,3Vdc and 5Vdc will surface clearly.
But what are the software changes for making this board work with the AFSM?
At the first build of the board i got:
  • Failure resetting the board from HMI
  • Failure on FreeMemory function
  • The calculation for the size of the FSM state constructor is wrong

 

Adjustment made for the DUE (blue is new, green is old)

Added new libraries:

#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>

 

void ResetBoard()
{
  delay(2000);
  RSTC->RSTC_CR = RSTC_CR_KEY(0xA5) | RSTC_CR_PERRST | RSTC_CR_PROCRST;
  NVIC_SystemReset();
} // End of ResetBoard

 

void RAM()
{
  char top;
  int FreeMem;
  HMISendString("@VAL," + ValidationId);
  FreeMem = &top - reinterpret_cast<char*>(sbrk(0));
  HMISendString("@RAM," + String(FreeMem));
} // End of RAM

 

void InitFSMStates ()
{
  int StateNo = 0;
  FSMStateType* FSMStateLaatste;
  Serial.println ( F("Setup FSM States"));
  NoFSMStates = sizeof(PossibleFSMStates) / 12;
  //Serial.println(sizeof(PossibleFSMStates));
 
while (StateNo < NoFSMStates)
  .......

There is a great difference between the speed of similair controls. First test gave a serious reduction of the cycle time; for the DUE 0,18 mS and the similair MEGA2560 control has a cycle time of 0,87 mS. Notice also the difference in free memory.

 

AFSM 2560   AFSM ARM