Arduino Due: Difference between revisions

From Axel Public Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 17: Line 17:
* 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'''
* please go to "Installation and first use of LogicLab" chapter in this page
* please go to "Installation and first use of LogicLab" chapter in this page, to install LogicLab and register a valid license


== SDK version ==
== SDK version ==
Line 79: Line 79:


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 the folder where you unpacked the ArduinoDue_PLC_SDK_x.y.z.zip, here you will find a Makefile
* Connect your Arduino Due with the programming port and verify the COM port number assigned by Windows (should be COM 11, 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.
* 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”


Line 101: Line 102:
* 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'''



Revision as of 17:46, 22 September 2017

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.axelsw.it/index.php?option=com_content&view=article&id=143&Itemid=1806

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
  • 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)"
  • Latest compiler version should be automatically selected (1.6.11 at the moment of this writing)
  • 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, in any folder you want. Please note you now have an empty "lib" folder inside
  • 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 "lib" folder cited above

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.

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

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.

  • To add a new embedded function

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.

  • 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

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:

  • Open command prompt and go to the folder where you unpacked the ArduinoDue_PLC_SDK_x.y.z.zip, here you will find a Makefile
  • 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 informations

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

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.