Arduino Due: Difference between revisions

From Axel Public Wiki
Jump to navigation Jump to search
No edit summary
 
(19 intermediate revisions by the same user not shown)
Line 3: Line 3:
__TOC__
__TOC__


== Download and flash firmware (binary version)==
= Arduino Due firmware types =
Please visit the "Download" page on our website:
http://www.axelsoftware.it/download
then expand the '''Run-times''' section, here you can choose between two variants of the Arduino PLC runtime:
* '''Binary version:''' pre-compiled firmware binary, ready to download and use, but can not be customized in any way
* '''SDK version''': version for developers, can be customized by adding functions and variables written in C language


* Download the firmware with our PLC runtime from our site at (section Run-times):
== Binary version ==


http://www.axelsw.it/index.php?option=com_content&view=article&id=143&Itemid=1806
* choose '''Runtime for Arduino Due (Binary version)''' and download it
 
* unpack the contents of the archive, named ArduinoDue_PLC_binary_x.y.z.zip
* unpack the contents of the archive
* connect your Arduino Due with the '''Programming port''' and verify the COM port number assigned by Windows
* connect your Arduino Due with the '''Programming port''' and verify the COM port number assigned by Windows
* execute '''download.bat'''; it will ask your COM port and will proceed with the firmware download
* execute '''download.bat'''; it will ask your COM port and will proceed with the firmware download
* reboot your Arduino Due, connecting it to the '''Native port'''
* reboot your Arduino Due, connecting it to the '''Native port''' and verify the COM port number assigned by Windows
* please go to "Installation and first use of LogicLab" chapter in this page, to install LogicLab and register a valid license


== Customizable firmware version ==
== SDK version ==
=== Downloads ===
=== Downloads ===
First of all you need ArduinoDue compiler on your computer:
First of all you need Arduino Due compiler on your computer:
*Go to Arduino website, at the following link, and download the latest version of Arduino IDE  
Go to Arduino website, at the following link, and download the latest version of Arduino IDE (1.8.4 at the moment of this writing). "Windows installer" is recommended.


  https://www.arduino.cc
  https://www.arduino.cc/en/Main/Software


* Install Arduino IDE and launch it
* Install Arduino IDE and launch it
* Go to Tools → Board: “Current board name” Click on Boards Manager
* Go to Tools → Board: “''current board name''” → Boards Manager...
* Chose Type “Arduino” from the drop down menù
* Type “arduino due” in the ''"Filter your seach..."''
* Select Arduino SAM Boards (32-bits ARM Cortex-M3)
* Select below "Arduino SAM Boards (32-bits ARM Cortex-M3)"
* Version 1.6.11
* Select compiler version 1.6.11. You can also choose a more recent version if available, in this case you will have to manually adjust the Makefile!
* Install
* Install




Now download the customizable firmware version from Axel website:
Now download the SDK version from Axel website:
* Go to the following link
* choose '''Runtime for Arduino Due (SDK version)''' and download it
* unpack the contents of the archive, named ArduinoDue_PLC_SDK_x.y.z.zip. You will now have a "AlPlc_ArduinoDue_Custom" folder.
[[???? LINK NOT AVAILABLE ????]]
* choose '''Runtime for Arduino Due (SDK library)''' and download it
* unpack the contents of the archive, named ArduinoDue_PLC_SDKLibrary_x.y.z.zip, '''inside the "AlPlc_ArduinoDue_Custom" folder''' cited above. You will now have a "AlPlc_ArduinoDue_Custom\lib" folder.


* Download the ''custom archive (???)'' and unzip it; you will find a folder named “lib”
The "SDK library" contains the base LogicLab PLC Runtime (static library and headers), so everytime there’s an update you can just download the latest version of the "Runtime for Arduino Due (SDK library)" and replace the content of “lib” folder.
* From the same link above download the ''library archive (???)'' and unzip it in the “lib” folder


The ''library archive (???)'' contains the LogicLab Runtime, so everytime there’s an update you can just download the latest version of the ''library archive (???)'' and replace the content of “lib” folder.


You can now edit the provided sources with any text editor or IDE you want, and then compile them with a simple '''make''' command in the command prompt (and use '''make clean''' to clean the previous build).


A Codelite project as already been created in order to edit and compile these files, if you want to use it you need to download Codelite software at the following link
Alternatively, you can use '''Codelite''' (a free C++ IDE), for which a project is already provided; you can download it from:


  https://codelite.org/
https://downloads.codelite.org/


Once installed, run Codelite and select “Workspace → Open workspace → AlPlc_ArduinoDue_Custom.workspace”
Once installed, run Codelite and select “Workspace → Open workspace → AlPlc_ArduinoDue_Custom.workspace”.




Line 54: Line 59:


* '''To add a new datablock'''
* '''To add a new datablock'''
A datablock is a special memory area of the PLC runtime used to "publish" a C variable to the PLC environment, using a fixed "logical address".
You can create the variable you want to publish wherever you want but we suggest you to put it in the '''Datablocks.cpp''' file, where all the datablocks are stored. You will find an array named const PLCIEC_DBREC plcDataBlocks[] in the '''UserDefinition.cpp''' file, to make your variable visible to LogicLab you have to add an element to that array; follow the instructions you will find there.
You can create the variable you want to publish wherever you want but we suggest you to put it in the '''Datablocks.cpp''' file, where all the datablocks are stored. You will find an array named const PLCIEC_DBREC plcDataBlocks[] in the '''UserDefinition.cpp''' file, to make your variable visible to LogicLab you have to add an element to that array; follow the instructions you will find there.
Then, you will need to edit your TGT file for LogicLab accordingly.


* '''To add a new embedded function'''
* '''To add a new embedded function'''
An embedded function is a C function that is "published" to the PLC environment.
You can create the function you want to publish wherever you want but we suggest you to put it in '''IEC_Embedded.cpp''' file, where all the IEC functions are stored. You will find an array named const PLCIEC_FCNREC plcEmbeddedFunctions[] in the '''UserDefinition.cpp''' file, to make your function visible to LogicLab you have to add an element to that array; follow the instructions you will find there.
You can create the function you want to publish wherever you want but we suggest you to put it in '''IEC_Embedded.cpp''' file, where all the IEC functions are stored. You will find an array named const PLCIEC_FCNREC plcEmbeddedFunctions[] in the '''UserDefinition.cpp''' file, to make your function visible to LogicLab you have to add an element to that array; follow the instructions you will find there.
Then, you will need to edit your TGT file for LogicLab accordingly.


* '''To modify firmware behavior'''
* '''To modify firmware behavior'''
Line 71: Line 84:


=== Flash firmware ===
=== Flash firmware ===
As said in the previous chapter, the custom version provide a Codelite project ( AlPlc_ArduinoDue_Custom.workspace), you can use this project to build your code; else you can open your command prompt, drive to the custom folder (where the makefile is) and invoke '''make clean''' command and then '''make''' command.
To '''download the firmware''' on your Arduino Due board you must use command prompt:
To '''download the firmware''' on your Arduino Due board you must use command prompt:
* Open command prompt and drive to the custom folder (where the makefile is).
* Open command prompt and go to your AlPlc_ArduinoDue_Custom folder
* Connect your Arduino Due with the programming port and verify the COM port number assigned by Windows (should be COM 13, if not modify it)
* Connect your Arduino Due with the programming port and verify the COM port number assigned by Windows
* Edit the Makefile and put the correct COM port number
* Execute '''make download''' command, once finished reboot your Arduino Due
* Execute '''make download''' command, once finished reboot your Arduino Due
* Connect the board to the native port and verify the COM port number assigned by Windows (it should be COM 11, if not modify it).
* Connect the board to the Native port and verify the COM port number assigned by Windows.


Now LogicLab can connect to your Arduino Due board, but you won’t be able to download a program until you register a valid license.
Now LogicLab can connect to your Arduino Due board, but you won’t be able to execute a PLC program until you register a valid license.
To learn more about LogicLab and license read chapter “Installation and first use of LogicLab”
To learn more about LogicLab and license read chapter “Installation and first use of LogicLab”


== Installation and first use of LogicLab ==
= Installation and first use of LogicLab =
=== Downloads of LogicLab Automation Suite ===
== Downloads of LogicLab Automation Suite ==
Go to our website '''www.axelsw.it''',
Go to our website '''www.axelsw.it''',
In the '''Downloads''' section expand the list '''Software -> LogicLab Automation Suite'''
In the '''Downloads''' section expand the list '''Software -> LogicLab Automation Suite'''
Download the file '''LogicLab Automation Suite'''
Download the file '''LogicLab Automation Suite'''


=== Install the setup ===
== Install the setup ==


=== Launch LogicLab ===
== Launch LogicLab ==
* Press '''New Project''', select target '''Arduino Due 1.0''', give the project a name and press the '''OK''' button.
* Press '''New Project''', select target '''Arduino Due 1.0''', give the project a name and press the '''OK''' button.
* From the menu '''On-line''' select '''Setup communication'''.
* From the menu '''On-line''' select '''Setup communication'''.
* Select the protocol '''GDB''', then press the '''Properties''' button.
* Select the protocol '''GDB''', then press the '''Properties''' button.
* Change the COM port number (verify the COM port number assigned by Windows)
* Change the COM port number (verify the COM port number assigned by Windows to your Arduino Due board)
* Choose '''Connect''' from the menu '''Online'''
* Choose '''Connect''' from the menu '''Online'''


Line 102: Line 114:
However if the license key has not been written yet, will be able to connect but not to download and run any PLC code
However if the license key has not been written yet, will be able to connect but not to download and run any PLC code


=== Get the free license ===
== Get the free license ==
* Press the '''Read HW Key''' button : this will display your hardware key in the text box
* Press the '''Read HW Key''' button : this will display your hardware key in the text box
* Send a mail to '''support@axelsw.it''' with the hardware key; Axel will send you the license key back
* Send a mail to '''support@axelsw.it''' with the hardware key; Axel will send you the license key back. Our policy provides a first license for free, if you need numerous license, we may request a payment.
* Enter the license key you received in the '''Write License''' text box and press the button
* Enter the license key you received in the '''Write License''' text box and press the button
* Reboot your Arduino Due and connect with LogicLab again
* Reboot your Arduino Due and connect with LogicLab again


== More informations ==
 
For more information you can consult LogicLab online manual,
 
or follow our tutorials available in the news section of the website or on  
= More information =
YouTube by following the link below:
=== About LogicLab ===
For more information you can consult LogicLab online manual, or follow our tutorials available in the news section of the website or on YouTube by following the link below:
  https://www.youtube.com/user/Axelsrl
  https://www.youtube.com/user/Axelsrl
=== Support ===
We ask you to contact our support team only to get the license; due to the fact that this is a free software distribution '''we won't provide assistance through our support system'''.
=== Supported Features ===
* Generation of immediately executable code upon compiling
* Hot swap download: allowing you to download the new application without halting the current execution
* Floating point support: for optimized floating point operations
* Extended string support: for optimized string operations
* Extended math support: for optimized math operations
* Relocatable code: for optimized memory usage
* Source code download and upload: allowing you to download the project source code on the target and to retrieve it in a second moment
* Can use SoftScope trace tool
* On-line debug: advanced debug instrument which allow you to see current symbols value directly inside the editor
* Triggers and graphic triggers debugging instruments
* Breakpoints and step debug
* Synchronous I/O forcing
* Dynamic check of stack integrity
* Dynamic check of array validity
* Dynamic check of pointers validity
* Object-oriented programming mode


[[Category:Supported boards]]
[[Category:Supported boards]]

Latest revision as of 18:29, 18 November 2020

Following these instructions, you can turn your Arduino Due into a complete IEC-61131 PLC.

Arduino Due firmware types

Please visit the "Download" page on our website:

http://www.axelsoftware.it/download

then expand the Run-times section, here you can choose between two variants of the Arduino PLC runtime:

  • Binary version: pre-compiled firmware binary, ready to download and use, but can not be customized in any way
  • SDK version: version for developers, can be customized by adding functions and variables written in C language

Binary version

  • choose Runtime for Arduino Due (Binary version) and download it
  • unpack the contents of the archive, named ArduinoDue_PLC_binary_x.y.z.zip
  • connect your Arduino Due with the Programming port and verify the COM port number assigned by Windows
  • execute download.bat; it will ask your COM port and will proceed with the firmware download
  • reboot your Arduino Due, connecting it to the Native port and verify the COM port number assigned by Windows
  • please go to "Installation and first use of LogicLab" chapter in this page, to install LogicLab and register a valid license

SDK version

Downloads

First of all you need Arduino Due compiler on your computer: Go to Arduino website, at the following link, and download the latest version of Arduino IDE (1.8.4 at the moment of this writing). "Windows installer" is recommended.

https://www.arduino.cc/en/Main/Software
  • Install Arduino IDE and launch it
  • Go to Tools → Board: “current board name” → Boards Manager...
  • Type “arduino due” in the "Filter your seach..."
  • Select below "Arduino SAM Boards (32-bits ARM Cortex-M3)"
  • Select compiler version 1.6.11. You can also choose a more recent version if available, in this case you will have to manually adjust the Makefile!
  • Install


Now download the SDK version from Axel website:

  • choose Runtime for Arduino Due (SDK version) and download it
  • unpack the contents of the archive, named ArduinoDue_PLC_SDK_x.y.z.zip. You will now have a "AlPlc_ArduinoDue_Custom" folder.
  • choose Runtime for Arduino Due (SDK library) and download it
  • unpack the contents of the archive, named ArduinoDue_PLC_SDKLibrary_x.y.z.zip, inside the "AlPlc_ArduinoDue_Custom" folder cited above. You will now have a "AlPlc_ArduinoDue_Custom\lib" folder.

The "SDK library" contains the base LogicLab PLC Runtime (static library and headers), so everytime there’s an update you can just download the latest version of the "Runtime for Arduino Due (SDK library)" and replace the content of “lib” folder.


You can now edit the provided sources with any text editor or IDE you want, and then compile them with a simple make command in the command prompt (and use make clean to clean the previous build).

Alternatively, you can use Codelite (a free C++ IDE), for which a project is already provided; you can download it from:

https://downloads.codelite.org/

Once installed, run Codelite and select “Workspace → Open workspace → AlPlc_ArduinoDue_Custom.workspace”.


Customize the firmware

By customizing the firmware you can add new datablocks and embedded functions for LogicLab and modify the firmware behavior.

This firmware version already includes TinkerKit files. TinkerKit I/O has been used as datablocks and embedded functions examples.

  • To add a new datablock

A datablock is a special memory area of the PLC runtime used to "publish" a C variable to the PLC environment, using a fixed "logical address".

You can create the variable you want to publish wherever you want but we suggest you to put it in the Datablocks.cpp file, where all the datablocks are stored. You will find an array named const PLCIEC_DBREC plcDataBlocks[] in the UserDefinition.cpp file, to make your variable visible to LogicLab you have to add an element to that array; follow the instructions you will find there.

Then, you will need to edit your TGT file for LogicLab accordingly.

  • To add a new embedded function

An embedded function is a C function that is "published" to the PLC environment.

You can create the function you want to publish wherever you want but we suggest you to put it in IEC_Embedded.cpp file, where all the IEC functions are stored. You will find an array named const PLCIEC_FCNREC plcEmbeddedFunctions[] in the UserDefinition.cpp file, to make your function visible to LogicLab you have to add an element to that array; follow the instructions you will find there.

Then, you will need to edit your TGT file for LogicLab accordingly.

  • To modify firmware behavior

In the UserDefinition.cpp file you will find four functions named BeforePlcTaskFast(), AfterPlcTaskFast(), BeforePlcTaskBackground(), AfterPlcTaskBackground(). These functions are called before and after tasks execution; you can add your code here (see the example of ReadInputs() and WriteOutputs() which are called before and after the task fast).

In the main.cpp file you will find the “main” function, which you may use as entry point for your code. “Main” already calls two functions: AlPlcArduinoStartup() makes the basic initialization for Arduino device and it’s required by the Runtime library; you should leave this function call as the first thing done by “main” function. AlPlcMain() start the tasks execution. Do never delete those functions, or you’ll get unexpected behavior (most of all the LogicLab Runtime won’t run). You can add your code between those two functions, in order to do something before the tasks start running, and you can add your code after the AlPlcMain() in order to do something else other than the PLC programs made with LogicLab.


Flash firmware

To download the firmware on your Arduino Due board you must use command prompt:

  • Open command prompt and go to your AlPlc_ArduinoDue_Custom folder
  • Connect your Arduino Due with the programming port and verify the COM port number assigned by Windows
  • Edit the Makefile and put the correct COM port number
  • Execute make download command, once finished reboot your Arduino Due
  • Connect the board to the Native port and verify the COM port number assigned by Windows.

Now LogicLab can connect to your Arduino Due board, but you won’t be able to execute a PLC program until you register a valid license. To learn more about LogicLab and license read chapter “Installation and first use of LogicLab”

Installation and first use of LogicLab

Downloads of LogicLab Automation Suite

Go to our website www.axelsw.it, In the Downloads section expand the list Software -> LogicLab Automation Suite Download the file LogicLab Automation Suite

Install the setup

Launch LogicLab

  • Press New Project, select target Arduino Due 1.0, give the project a name and press the OK button.
  • From the menu On-line select Setup communication.
  • Select the protocol GDB, then press the Properties button.
  • Change the COM port number (verify the COM port number assigned by Windows to your Arduino Due board)
  • Choose Connect from the menu Online

If everything went correctly, you should see the green word Connected on the status bar in the lower right corner of LogicLab.

However if the license key has not been written yet, will be able to connect but not to download and run any PLC code

Get the free license

  • Press the Read HW Key button : this will display your hardware key in the text box
  • Send a mail to support@axelsw.it with the hardware key; Axel will send you the license key back. Our policy provides a first license for free, if you need numerous license, we may request a payment.
  • Enter the license key you received in the Write License text box and press the button
  • Reboot your Arduino Due and connect with LogicLab again


More information

About LogicLab

For more information you can consult LogicLab online manual, or follow our tutorials available in the news section of the website or on YouTube by following the link below:

https://www.youtube.com/user/Axelsrl

Support

We ask you to contact our support team only to get the license; due to the fact that this is a free software distribution we won't provide assistance through our support system.

Supported Features

  • Generation of immediately executable code upon compiling
  • Hot swap download: allowing you to download the new application without halting the current execution
  • Floating point support: for optimized floating point operations
  • Extended string support: for optimized string operations
  • Extended math support: for optimized math operations
  • Relocatable code: for optimized memory usage
  • Source code download and upload: allowing you to download the project source code on the target and to retrieve it in a second moment
  • Can use SoftScope trace tool
  • On-line debug: advanced debug instrument which allow you to see current symbols value directly inside the editor
  • Triggers and graphic triggers debugging instruments
  • Breakpoints and step debug
  • Synchronous I/O forcing
  • Dynamic check of stack integrity
  • Dynamic check of array validity
  • Dynamic check of pointers validity
  • Object-oriented programming mode