Function Blocks

Introduction to Function blocks and H/W interfaces.

Function blocks are reusable implementation of a specific function or component in an automation system similar to a class in OOP. .The following figure represents a function block

Function_Block.png

A function block in IEC61499 can be an active or a passive element. A passive element waits for a event to trigger its functionality while an active element is time dependent.The event and data flow in a function block is shown below

To learn more about Function Blocks, Application Model and System Model in IEC61499 please watch this video

Blinking an LED

We will now do a sample application to blink an LED connected to a GPIO in Raspberry Pi. The plan is to build an application in 4DIAC and then download it to Forte RTE running on RPi. To proceed further we need the following.

  1. PC running 4DIAC
  2. Raspberry Pi with Forte
  3. LED
  4. 220E Resistor (or equivalent)
  5. Breadboard
  6. Some wires/Jumpers
Please use Firefox/Chromium/Chrome before proceeding. WebM ,an open media container,is not natively supported in internet explorer/Safari.The browsers will need third party plugins to play the same.

Building Application

  • Launch 4DIAC and select your workspace
  • Create a new system and an application as shown below

  • For creating a blink application, we need to set and reset the output channel. For which we can use a SR flipflop FB from 4diac.We will also need E_CYCLE to provide a cycle of events at intervals. Select the function blocks as shown below

  • The E_SR Flip Flop requires two event inputs but E_CYCLE generates only one event output hence we will use E_SWITCH FB to switch between S&R inputs of SR flipflop.The selection and connections are shown below


  • Quick Tip: Move the mouse over to event or data I/O to more about each Function block inputs and outputs.

  • Now we will need to interface an output block. We will use QX FB which will serve as a Service Interface Block for the hardware

  • Note: While creating applications we are not usually aware of the target PLC/Hardware.The parameters are assigned after defining system configuration.The approach helps us run same application on different PLC's.
  • Define System Configuration.

  • The target machine(Embedded resource) is Raspberry Pi and is connected via ethernet (RJ45/WiFi).Make sure that a local IP address is assigned to Pi for downloading application.Global IP addresses will only work with port forwarding/DDNS.
  • Map the hardware to the Embedded Resource

  • Assign parameters to the Function Blocks.

    1. DT is assigned a value of 1000ms.E_CYCLE would hence generate events for every 1000ms/1s.
    2. Event input qualifier (QI) is made true.
    3. PARAMS in QX block take the Output Pin (GPIO) Number.In this case its the GPIO of Raspberry Pi.Forte uses SysFS which use BCM Pin Mapping. You can learn about the Pinout from this image or using the command in RPi.
    4. gpio readall 
  • Configure the embedded resource.

  • Ensure that RPi Device is defined as a HOLOBLOC.


  • Before proceeding any further

    Make sure that the work is saved !!

    Downloading Application to RPi

  • Connect LED to GPIO3 (Pin 5) of RPi as shown below
  • Pi_LED_Conn.png

  • Gain terminal access on Pi or use SSH to login remotely.
    More details on Secure Shell (SSH) can be found in my previous RPi tutorial
  • Start FORTE service as root.

  • Launch Deployment Console in 4DIAC and Download the application


  • The LED connected to RPi should now start Blinking.The blink rate should be 1000ms/1s, as defined in the application.
  • Pi_Blink.gif

    Note: Clean device in Deployment perspective to deploy a new application.

    Assignments for Practice.

    1. Change the blink rate.
    2. Change duty cycle of the blink
    3. Multiple LED configuration.