Pocket

[Embedded Software Modeling]

Models in Argo Embetics has various feature for optimaizing embedded software development.

This tutorial simply describes how to use External Data, Platform Model and Task to develop embedded software.

The main centent in this tutorial are as below.

  • Make embedded software project.
  • Make interval driven Process.
  • Import Platform Model.

Make embedded software project

Making embedded software project is same as normal project.
But it uses almost all of Models of Argo Embetics.

Follow the steps below.

  1. Set Up New Project
  2. Import Platform Model
  3. Configure I/O Port
    1. Enable Port Data
    2. Configure Port Direction
  4. Make Model
    1. Make Context Diagram
    2. Add External Data
    3. Make Logic
    4. Link External I/O Data
  5. Generate Source Code
    1. Generate Source Code
    2. Build
    3. Load

Now, make a Project for the control board “MPIC-KIT” (a PIC learning kit by “MARUTSU Co,. Ltd”).
The MPU on this board is “PIC16F819”.

1. Set up a new Project

First, create a new Project.
If you do not know how to create, refer to “Tutorial #1”.

2. Import Platform Model

Two kinds of Model file are included in the exported Model files.

  • Entire Platform Model
    Interface Model + Register Model
    Including the configuration of the target port and device.
  • Register Model
    Register Model Only the information of the MPU, import it before making the necessary configuration.

In this tutorial, only import the Register file and configure it below.

Use “PIC16F819_18_en.zip” as Platform Model file.
If you do not have it, download from the following site.
http://www.argo-s.com/ae_en/

Extract zip file before import.

(Note) Commonly, the imported Model Elements are added to the current Platform Model, but if the entire Platform Model file is imported, the Platform Model of the current Project will be overwrited.

First, open the import dialog from the menu “File” – “Import Model” – “From Folder”.

Select the sample project file “PIC16F819.xml”.

After importing the Project, the information of PIC16F819 can be opened like the following image.

Only the Platform Register Model are imported and the interface will be generated automatically.
Once the Project has been imported, save it from the “File” menu or the following button.

3. Configure I/O Port

The configuration of I/O port can be edited from the edit form of Port Data or “Valid Platform Model” tab form on “Platform Link”.
It is necessary to make the port available which to be used.
(Note)Make sure it is available before using it, not only for Port Data, but also for all the Platform Model Element except the Main.
Open the Platform Link form from the “View” menu.

After importing the Project, the tab will be as the following image.

i. Enable Port Data
Check the box to enable the Platform Mode Element.

ii. Port Direction (input/output) Configuration
The current direction of the port are displayed on the right side of name of the Port Data. To change the direction, select “Exchange I/O” on the right-click menu of the corresponding Port.

Click “Update” to save the changes.

The direction configuration of the I/O port must adapt to the specification of the target board. Button and LED are already on the sample board, configure two port for a simple Model to make the LED controled by the button.

According to the board datasheet, button “SW1” is connected to PortA4 and “LED4” is connected to PortB7 .
Noted that when the button is pressed, the the Port becomes low (0) and the LED is turned on.

First, enable PortA4 and PortB7 and configure the direction for each of them.

Click “Update” to save the configuration.

4. Make Model

By now, everything is ready for making Model. Follow the steps below to make the Model.

i. Make Context Diagram

Making Model is start from Context Diagram.
Add the control target H/W Element to make hardware configuration.
Right-click the “H/W Model/Requirement Model – Context Diagram” to open the edit form of Context Diagram.

Now, the new Context Diagram edit form is opened with nothing on it.

Click the button “Input H/W Element”, “Output H/W Element” or “Feature Requirement” to add the corresponding Element as you wish.

ii. Add External Data

Drag the mouse between H/W Element and Feature Requirement Element on the form to add a input/output Data.

The External Data the Model that linked with Platform Model.
As the Port has been known, link it here.

[Link External Data and Port Data]
Click the menu from the right-click menu of the item on the form or double-click it to open the edit form of the External Input Data.

First, select “RA4/AN4” from the pull-down list menu of “Symbol”.
If there is nothing in the pull-down list, back to the step “3. Configure I/O Port”.

Next, select the configuration value for the port.
To configure the button and LED with “ON = 0”, “OFF = 1”, select “Negative ON/OFF” in the “Value Group” pull-down menu.
Select “OFF” as the default value.
And change the name to “Button State” to make it easy to be understanded.

Click “Update” to save the changes.
Configure the External Output Data in the same way.

Click “Update” to save the changes.
Click “~” to close the edit form.
After changing the name of the External Data, the Context Diagram should be looked as the following image.

Click the “Update” button on the Context Diagram edit form.
Next, start to make the Logic.

iii. Create Logic

Right-click the item of the Feature Requirement, click “Create Logic – Procedure Description”.

Double-click the code panel to make the code editable.

The program logic is very simple as below.

“LED ON when button is pressed”

Using C programming language to achieve the logic.

if( Button State == ON ){
LED State = ON;
}

When it is input on the code editer of Argo Embetics, it can be done like the following steps.
First, input the string “if(“.

Then, the following “If” grammar will be completed automatically.

Leave the caret at the current place and select “Button State” at “insert” menu of the right-click menu.
After that, the following data will be inserted into the code, then select the configure value to complete the “If” grammar.

(Note)If the cursor is out of the place and the logic menu is closed, add a space after “=” to show it again.

After “ON (ON)” is selected, the “If” grammar is finished as below.

Input the logic code in the same way for “LED State”.
First, input line feed and tab to the start place.

Leave the cursor at the current place, double-click the “LED State” in the table of “Available data”.
After that, the following data will be inserted into the code, then select the configure value to complete the “If” grammar.

Click “ON (ON)” to insert the value.
(Note)The “;” is not inserted automatically, it must be input at the end.

The “else” grammar can also be made in the same way. Input “}else{“.
If the code has been made before, copy/paste can be used directly.

Now, “If” grammar is finished
Check the “Edit” off to end the coding.

If there is no problem, click the “Update” button to save it.

iv External I/O Data Link
The link of External I/O Data has been made, here give some explanation of the used link on the Platform Model Link form.
Open the form from the main menu “View – Platform Link”.
The link of External Data is achieved on the “External Data Link” tab.

“External Data” are shown on the left side and the selectable Platform Model Data are on the right side.
The External Data can be linked to the selection of “Symbol” on the right side.
Not only “Port Data” but also a function of Module Element can be configured to link with External Data. It can be select in the pull-down menu of “How to Access”, then the selectable functions of Module Element can be selected in the pull-down menu of “Symbol”.

With that, the Model Data is completed. After making the content of H/W Element and Feature Requirement, Context Diagram will be as below.
The edit form of each Element can be opened by the right-click menu of the item on the form.

5. Generate Source Code

After the Model Data has been completed, the source code can be generated by only one button click. Here is the introduction from source code generation to build/load.

i. Generate Source Code
Generate source code until generating error being not displayed.

ii. Build

If you build source code by command, input the following command line.

picc –CHIP=16f819 –RUNTIME=+stackcall source file path 

In this sample Project, “HI-TECH C” is used as the compiler and the build commond is also for “HI-TECH C” compiler.
For the information of “HI-TECH C”, refer to http://www.htsoft.com/ .
A hex file will be generated after the successful building.

iii. Load

Load the hex file to the target board (MPU)
If a command load is available, load command can be configured on “Load commond” tab in “Project Configuration” form in the same way as build command. After that, the hex file can be loaded by load menu of Argo Embetics.
If the load commond is not available or the Argo Embetics is Basic Edition, use some other tool to load the hex file.

Until now, a simple flow of embedded software developement has been introduced.
Next, modeling with interval timer will be introduced.


Make Interval Driven Process

The way to invoke Process by a certen frequency is described as below.
First, select “Invocation Timing – Change to Interval” from the right-click menu of on a Process item.

After that, the Interval Task will be created automatically and linked with the selected timing.
Next, select “Invocation Timing – Edit” to configure the interval of the invocation frequency.

The edit form of the generated Intercal Task will be opened.

Process is invoked from Task.
The interval timing of Process is managed from Task.

The default interval timing is 10 msec.
Select “Option” tab and the interval of the Task will be found there. The interval timing will also be 10 msec.

Because 10 msec interval driven is the expected timing, nothing needs to be changed at all.
If not, there are two way to change it.

  • Change the Interval of the Timer                                                                                                                                                                                                                It is useful to change the Interval of the Timer if the corresponding Timer is not used by any other Process and the interval time is in available range in the corresponding Timer.
    Click the “Edit” button on the “Option” tab of Task to open the edit form of the corresponding Timer, change the interval value on the “Select Parameter” tab.

    After that, change an interval of the Task in a similar way.

  • Change the Interval of the Task                                                                                                                                                                                                                It is better to set “Frequency dividing” of the Task if the interval of the corresponding Timer can not be changed.
    If the expected interval of the Task is 20msec, set the dividing value to two as below.

    If “Frequency dividing” value is set, the Task will be invoked at the specified frequency from the Timer.
    Just as the example above, the Task will be invoked in every 20 msec and the Process will also be run in every 20 msec.

If Task is to be dirven by an external interrupt, Task needs link to the External Interrupt.
There is the way to use Platform Model Link form to link Task to Platform Model Timer or External Interrupt.
First, open “Task Timing” tab of Platform Model Link form.

All the Task (except the Resident Task) will be shown on this form. Task are on the left side and the Timer or External Interrupt elements are on the right side.
Select the Element by the pull-down list of “Timing Element” to link it with the corresponding Task.

Commonly, the interval of Interval Task is used for the invocation interval of Process.
It is available to use for the condition of State Transition on STD.
In the following image, “dly(5)” is described at the State Transition condition.
This means the condition will be satisfied when the current State is entered five times.

By this delay function, if the Process of this Logic has 10msec Interval Task, looping 5 times of “State 1” means the implementation of 50 msec delay condition in Logic.
In this way, it is possible to describe the processing that is changed according to time by using STD and Intarval Task.

The “dly(times)” means the action will be delayed by the input times.
It can be added on the edit form of a STD. Open the edit form from the insert menu and select “Delay setting” to add the delay.


Import Platform Model

The way of how to import Platform Register Model has been intruduced in “Make Project” chapter above, here are two different ways to import.

A. Import Platform Model including the configuration of target board
“Platform Model including the configuration of target board” means the Model that is commonly called “Platform Model”.

The content of this import is as the following image.

Select “File” – “Model Import” from main menu and select the exported model file from the dialog to import it.

If Platform Model is imported, the development can be started from making Context Diagram. When Platform Model is imported into an existing Project, which means change of execution environment, it is necessary to re-link the Platform Model with External Data or Task. It is also necessary to check code if the logic uses Platform Model Module directly. If the link is not configured, error will come out when generating source code.

B. Import the Platform Model including H/W Element and External Data

The content of this Model is called as “H/W Platform Model”.
“H/W Platform Model” is not an exported Model but Project itself.
It means a Project without the contents of Feature Requirement.

“H/W Platform Model” can be imported from the main menu “File” – “New Porject”.

Select “Create project by other project” for “How to create”.
Specify project path to be created and base project file.

If H/W Platform Model is imported, the development can be started from making Feature. Each of External Data is linked with the existing Platform Model elements. Then it starts from making Feature Requirement. When draging mouse in Context Diagram, the registered External Data Element will be shown in menu.

This tutorial has simply described how to use External Data, Platform Model and Task for embedded software modeling.
For details, refer to other tutorial, user’s guide or help.


Available Platform Model are provied from the Argo Solutions web site.
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/