# Step 1 - Use 4DIAC-IDE locally (Blinking tutorial)

This page is part of a guide that gives a walkthrough over the major 4DIAC features.

0. Overview
1. Use 4DIAC locally (YOU ARE HERE!)
2. Create a distributed application
3. Deploy remotely
4. Create your own Function Blocks
5. Other basic features
6. Advanced Features [optional]

In this guide, it will be shown a simple Blinking application. It's the "Hello World" of automation programs, so it will be enough to understand the key aspects and workflow of 4DIAC. The application will run locally, so no connection to any PLC or external hardware is needed. The architecture is shown below.

## Create a new IEC 61499 System

1. Select the System Perspective using the button create a new IEC 61499 System, by selecting either
   - Context menu of the System Explorer → New → New System,
   - File → New → New System.
   - File → New → Other... → 4DIAC and select New System.
2. Follow the instructions in the creation wizard. In the following wizard, the project name has to be specified.

The system appears in the System Explorer on the left. There you can see two things now:

- System Configuration: The definition of the devices present in your System.
- Type Library: You find here all the available Function Blocks for this System.

You will see here also later the applications you develop.

New systems per default contain a copy the types in the Type Library. If different types are need, for example from another project or another IEC 61499 engineering tool, these type files can be easily added by copying them into the project directory at the desired place. Furthermore the Type Navigator allows to drag and drop types between projects as well as within a project to a different folder.

## Configuration of the Automation Hardware

First, let's define the devices that are present in out system. The automation hardware can be modelled with the System Configuration Editor. It can be opened by double clicking on the System Configuration tree node in the System Explorer on the left. By using Drag and Drop, Device, Resource and Segment types can be added from the palette. On an IEC 61499 Device several IEC 61499 Resources can be configured. Resources can be directly added to Devices.

Drag and Drop a FORTE_PC Device and a Ethernet Segment from the Palette. Connect them clicking on one of them and dragging to the other. One EMB_RES resource is already present in the device. The MGR_ID localhost:61499 specifies the IP:PORT where the device will run. In this case it'll run locally and will listen at the port 61499.

Device and Resource parameters can either be specified directly at each Device/Resource or via the Properties View. The Properties View shows the parameters of a IEC 61499 Device/Resource (if it is selected either in the System Configuration Editor or in the System Manager View). The most important parameters are the IP address and the port of the device management interface as they are required for the communication between the engineering tool and the Devices (e.g. Download of IEC 61499 Applications).

Check that the Profile in the Properties tab is set to HOLOBLOC.

### Configuration of the Device's Configuration Profile

In order to support different device vendors' download mechanism you need to specify the device profile to be used for your device. currently 4DIAC-IDE supports the following two device profiles:

- HOLOBLOC Device conforming to the "IEC 61499 Compliance Profile for Feasibility Demonstrations". Currently the devices supporting this profile are all FORTE devices and FBDK devices older than 2009.
- FBDK2 for FBDK devices version 2 or later.

## Create a new IEC 61499 Application

1. Create a new IEC 61499 Application, by selecting either
   - Select a System, and on the context menu: New → New Application
   - File → New → New Application
   - File → New → Other... → 4DIAC and select New Application.
2. Follow the instruction in the creation wizard. In the following page of the wizard, the name of the Application and the corresponding parent System have to be specified. The number of applications that can be created is not limited.

## Create a network of FBs for the Blink application

A double-click on an Application in the System Explorer tab on the left opens the Application Editor for this specific application in the editor area.

1. Drag and Drop the following Function Blocks (FBs) to the Editor. Use the Palette on the right or the Type Libary in the System Explorer (the three are in the event folder):
   - E_CYCLE
   - E_SWTICH
   - E_SR

   The name in the middle of the FB is the type of it. If you CTRL + click on it, you can access the definition of the type of the FB. There you can see the interface and how it works. Check E_SWITCH and E_SR and go to the ECC tab to see how it behaves.

   The name on top of the FB is the instace name. Two FBs cannot have the same instance name. You can double click on it to change it for a better organized application.

2. Create the connections between the FBs

   Event (red, on top part of FBs) and Data (blue, on lower part of FBs) connections can be generated by connecting the Event-/Data in- and outputs. Position the mouse pointer over an Event-/Data in- or output, click and drag to the other end of the connection to create one. Remember, Event and Data connections cannot be mixed. Events connections allow fan-in and fan-out. Data connections allow fan-out but not fan-in.

   Here are some tips about editing the application:

   - If you hover the mouse over a FB or Data or Event connection end, you'll get information about it.
   - If you try to connect Data connections that have incompatible types, you will a red error in the status bar at the lowest part of 4DIAC.
   - Selected function blocks in the Application Editor can be parameterized using the Properties View typically located below.
3. Set a literal as an input data connection. The DT input data connection of E_CYCLE must be set to a value in order for it to work. You can do it by either:
   - Double click on the data connection in the Application Editor
   - Selec the FB or the Data connection itself, and change the value in the Properties tab below.

   Set the value to T#1s, meaning 1 second.

Now the application is done. You should try to understand how the application works. Something missing is the starting event. This would be done later when the hardware is configured. For now, imagine an event arrives to E_CYCLE.START. Every 1 second, and event output will be triggered in E_CYCLE.EO. The E_SWITCH will trigger an event output EO0 when G is zero, and EO1 when G is one. The value Q of E_SR will be 1 when an event at S arrive and 0 when an event at R arrive. Try to follow the flow of events and understand why this application makes Q toogle, considering it starts at 0.

## Mapping of Function Block Networks to Devices/Resources

Mapping FBs means specifing in which Hardware will each FBs run. All mapped FBs are changing their fill color to the Device's color during the mapping process.

Go to the Application created before, select the FBs you want to map (in this case all of them), right click → Map to ... → FORTE_PC → EMB_RES

To unmap a Function Block instance from a Resource, use the context menu entry Unmap of a Function Block in the corresponding Application.

## Configure the Resource

You can ope the Resource Configuration by double clicking the Resource in the System Configuration, or in the tree in the System Explorer on the left.

There you can find a START function block in white. This is the default starter fuction block of the EMB_RES. This will trigger a COLD event when starting. The STOP is triggered when the PLC is set to a STOP state, and the WARM when the PLC changes from a STOP state back to a RUN state. Connect both COLD and WARM to E_CYCLE.START.

You also see the FBs that were previosly mapped. You can add more FBs directly here and they will be already mapped to the resource, or you can unmap the FBs.

## Deploying application to FORTE

In this step, the Blink application will be deployed to FORTE running locally.

1. Go to Windows → Preferences → 4DIAC → FORTE Preferences, and in FORTE Location look for FORTE inside your 4DIAC folder in runtime/FORTE/1.8RC3/[YOUR_OS]/forte[.exe] and then click OK.
2. Change to the Deployment Persperctive using the button.
3. Set the port to 61499 (the same define before, remember localhost:61499 in the System Configuration?)
4. Launch Local FORTE
5. You should see the the location of your FORTE and the STOP button enable in the Console.
6. Select the elements to deploy. In case you have many devices with many resources, you can select the devices to deploy and even which resources to deploy.
7. Click the Download button
8. Check that the deployment console shows some output, and that no red warning appears on the right nor left of it. If you get somthing red, something went wrong.

Note: With the runtime launcher you can only start run-time environments in your local development computer. It is not possible to start run-time environments on remote computers or control devices. In order to perform this task device specific means to start the run-time environment have to be performed.

The Deployment Console is automatically cleared before each download. Furthermore, with the icon in the upper right corner of the Deployment Console the deployment messages can be cleared.

By selecting a Device or Resource the corresponding IEC 61499 element can be cleaned. This means that the Device or Resource configuration are cleaned and reset to the default configuration without any Function Block Network.

Delete All Resources leaves the Device empty, and Kill Device stops FORTE. You can deploy again after cleaning the Device

Delete Resource deletes just the selected resource:

## Monitoring the Application

To observe the outputs of your Application you can use 4diac's monitoring functionality. You can enable it in the toolbar under the toolbar icon: or doing the following:

1. Change to Debug Perspective using the button.
2. In the System Explorer, right click on the System → Monitor System

A green sign shows that the monitoring is enabled for the system. To watch variables, you can:

- Right Click on a FB → Watch All or
- Right Click on a Variable → Watch

The Data and Events are monitored. The Data shows the current value and the Events show the times it was triggered. You can watch on the directly on the Element or in the Watches view.

You can force values to data inputs and trigger events by right clickin on it and selecting the corresponding command.

# Where to go from here?

Now that you know how to do a centralized solution, let's try and distribute things:

Step 2 - Distribute 4DIAC applications

If you want to go the back to see an overall overview of 4DIAC, here's a link

Step 0 - 4DIAC-IDE - General View

If you want to go back to the Start Here page, we leave you here a fast access

Start Here page

Go to top