Pocket

Getting Started with Arduino

For about Arduino, refer to http://www.arduino.cc/.

You can develop with Arduino on Argo Embetics.
There are various ways of developing. This document describes some preparation for using Arduino and some developing ways.
This document is for the user who knows usage of Argo Embetics. If you do not know how to use it, carry out the tutorial before.

  • Preparation for using Arduino
  • Developing ways
  • Generating Code

Preparation for using Arduino

  1. Set up ArduinoTarget board and developing environment is necessary for using Arduino.
    “Arduino Duemilanove (Atmega328p)” is used as target board in this document.
    “Arduino 1.0.1” is used for developing environment.
    If you do not have it, download from http://www.arduino.cc/.
    Set up Arduino and carry out some sample by Arduino web site.Here, Arduino setting up is finished.
  2. Argo Embetics setting
    1. Run Argo Embetics and create new project.Current Argo Embetics version is 3.0.1.
      Use this version or later.
    2. Open Project configuration form and change “Platform” for “Arduino”.
      Project configuration form is displayed by right-click at the Model Management form or by “View” menu.
      After changing, the following dialogue will be displayed. Click “Yes”.
      If Platform is changed to “Arduino”, “Output path” will be same as Source file name. Do not change this value.
      Though the least preparation is finished at this point, it is better for developing to import Arduino Platform Model.
    3. Import Arduino Platform ModelDownload Arduino Platform Model from Argo Embetics web site. At “Sample Model” page, get the Platform Model named “Arduino”.Extract zip file.
      Select Argo Embetics “File” menu “Import Model” – “From Folder” and specify xml file.The following dialogue will be displayed. Click “Yes”.

After importing, the Platform Model will be displayed at Model Management form.

You can use Arduino standard liblaries through Platform Model.

  1. The preparation for using Arduino is complete.
    Save the Model at this point.The above operation is necessary if you create new project.
    If you use copy project, the above operation is not necessary.

Developing ways

Make Process element

At least one Process element is necessary to make software that runs at Aruino.
Make Process element by the following steps.

  1. Add Feature requirement on Context Diagram.
  2. Add Logic to Feature requirement.
    After added, Logic form will be displayed.

After the steps, DFD, Process and Logic will be created.
For details of the operation, refer to “Argo Embetics Tutorial #2”.

Expression of processing

For Arduino, initializing function:setup(), main loop function:loop() is necessary.
These function are generated automatically. Describe processing in setup() and loop() as follows.

  • Processing in loop() functionDescribe at Logic element.
  • Processing in setup() functionDescribe at “Start Process”.

“Start Process” is on Project configuration form.

For example, describe the processing as follows.

  • Start ProcesspinMode(13, OUTPUT);
  • LogicdigitalWrite(13, HIGH);

After update and generating, the following file will be output.
Code generating is executed by “Generate” menu.


Check output folder by Project configuration form.
Open “tmp.ino” and you can check the generated code.

Created processing will be output as the followings.

  • Start ProcesspinMode(13, OUTPUT);
  • LogicdigitalWrite(13, HIGH);

SystemInit() and L_0() is called from setup() and loop() as the following flow.

  • setup() – SystemInit()
  • loop() – T_Resident() – L_0()

How to use Arduino standard liblaries

There are a few ways of using Arduino standard liblaries.

  1. Use liblaries directlyFor using liblaries directly, describe code on code editor like normal coding.
    If you describe all the processing by this way, Platform Model is not necessary.
  2. Use Platform ModelYou can check available Platform Model elements at Model Manager form.

    There are two ways of using Platform Model.
    One is using Module function and another is using Port.

    • MainUse as function
      Available functions of Main element are common control function as “Enable Interrupt” or “Disable Interrupt”.
    • Port DataUse as variable
      Set I/O to the Port element that is to be used.
      I/O setting must be done on Port form.Initializing processing will be output according to I/O setting.

      (Note: if you use the port that two elements shares same pin for digital and analog, validate only one port and use it.)

    • Timer, External InterruptTimer and External Interrupt is used for driving Task. Normaly, they are not used directly.
      For details, refer to help.
      • Advanced I/OTone function and etc…
        Refer to “Advanced I/O”
      • BitsBytesBits and Bytes operation function.
        Refer to “Bits and Bytes”
      • MathMathematics function
        Refer to “Math / Trigonometry / Random Numbers”
      • PortPort access function
        Refer to “Digital I/O / Analog I/O”
      • SerialPort access function
        Serial communication function
        Refer to “Communication”
      • TimeTime function
        Refer to “Time”
      • WireWire library function
        Refer to “Communication”
        ModuleUse as function
        The libraries that is provided in the Platform Model is as below.
        For details, refer to Arduino web site, Reference page – Function.

    For Platform Model, only valid elements are available.
    You can check valid Platform Model elements at Platform Link form.
    Platform Link form is displayed by “View” menu.

    After importing Platform Model, all the elements are invalid.
    Check the element to be used and click Update and checked elements will be validated.

    You can also validate element at its form.

    If you validate Platform Model elements while displaying Logic form, it is necessary to re-display Logic form.
    Logic form is displayed at Model Manager form.

    How to use Platform Model elements at Logic form
    Select function or Port element at “Insert” menu of right-click menu of code editor.

  3. Use External DataFor using External Data, it is necessary to add External Data on Context Diagram and specify Port element to symbol of External Data.Add External Data
    Display External Data form and specify Port element to symbol.

    Only valid elements are displayed.
    (Note) Specify “function” not “variable” to symbol in the case of Arduino model.

    If External Data is newly added, it is necessary to add External Data on DFD form.

    After the above preparation, it is possible to use port of Aruduino as External Data.

    For details of using External Data, refer to “Argo Embetics Tutorial #3”.

Data type

In Argo Embetics, the following data types are used.
For comparing with data types of Arduino, refer to the following list.

  • BO unsigned char
  • UC unsigned char
  • U2 unsigned int
  • U4 unsigned long
  • SC signed char
  • S2 signed int
  • S4 signed long
  • FLT float
  • DBL double
  • CH char
  • void void
  • enum enum

How to use other libraries

If you use libraries that is not defined at Arduino Platform Model, describe the code at code editor directly.
Include file is specified at Project configuration form.

You can insert other libraries functions by insert menu if you make External Module elements.
For details of using External Module, refer to help.

Generating Code

Contents of Generating Code

For Arduino, initializing function:setup(), main loop function:loop() is necessary.
These function are generated automatically.
Two files that are “.ino” and “.h” are generated.
For setup(), initializing of Platform Model or initializing of Data elements are generated.
For loop(), resident Task calling code is generated. The procesing of Logic is called by Task function.

Build / Load

If Arduino is set up, Arduino developing environment will be opened by double-click of “.ino”. If not, open “.ino” on Arduino environment.
For Build / Load opration, use Arduino developing environment.

This Getting Started has described the preparation for using Arduino.
For making actual Model, refer to other tutorial, user’s guide or help.

 

The re-configurable Module and Logic are also provied there. Make use of them with Argo Embetics for various development.

Please send an e-mail to argo-embetics@argo-s.com to connect with us when you have any question about Argo Embetics or our company.

Latest information about Argo Embetics is on:

http://www.argo-s.com/ae_en/