External control

Part of the GOcontroll toolbox is an opensource implementation of the XCP protocol. This means that each build comes with a generated .a2l file. This file contains signal and parameter descriptors matching the model created in Simulink. With a dashboard tool like HANtune the .a2l file can be loaded and a realtime dashboard can be created. In this example we will show how to control an enclosure LED with an external dashboard.


Since Simulink needs to be aware of an external parameter, we first need to create a parameter in MATLAB to control the LED.

  • Right click in the project browser
  • Select New
  • Select Script
  • Provide a name. In this case Parameters.m
  • Double click the new file to open.

We add parameter led, It is an Exported Global and has an initial value of 0 with a datatype of uint8.

MATLAB syntax:

led = Simulink.Parameter;
led.StorageClass = 'ExportedGlobal';
led.Value = uint8(0);

Click on Run to execute Parameters.m and add led to the MATLAB workspace.

Now switch to your Simulink Model to use parameter led to control an enclosure LED.

  • Add a constant block (start typing “constant” on the canvas)
  • Open the contant block by double click and set Contant Value to led and click OK
  • Connect it to Status LED 4

Build and upload your binary.

  • Download HANtune from Openmbd.
  • Install HANtune
  • Open HANtune
  • Click on File
  • Create a New Project
  • Right click on ASAP2 file
  • Add ASAP2 file
  • Navigate to your Simulink project folder and locate .a2l (In our case GOcontroll.a2l)
  • When the file is opened in HANtune double click (or right click and Load File) to load the file into the environment.
  • On the left, select the vertical tab ASAP2 elements
  • Locate parameter led in the left column.
  • Drag and drop led to the canvas and select SliderEditor in the pop-up window.

Your HANtune project should look like something below.

When you press F5, HANtune opens a connect window. Select Ethernet (in case of wired ethernet or Wi-Fi). You can verify the IP address under Settings. The IP address is adopted from the .a2l file which got the IP from the Simulink Model settings.

When Connect and Request is clicked, the connection is established and you are able to control blue LED 4 on the enclosure between 0 and 100% (decimal 255)

When a connection fails, verify if the go-simulink service is running. Also check if the IP address in HANtune aligns with the IP address from the controller.

Go to Top