Flowcode SCADA Simulation Getting Started
Updated: Mar 17
SCADA Simulation is a very powerful feature from Flowcode it allows communication with a IC(Device) over SPI,I2C and UART. It allows the program developer to use the real acquired data from the device such as an ADC in the bigger simulation of the system/plant that he is developing code /firmware for. It also allows for easy development of Serial Communication Drivers an example is the SPI driver development for an ADC MCP3201 with SPI Interface the benefit is the driver is developed and tested in one go. SCADA support many other features which we will not look at here. The goal of this short introduction is to get you started with Serial Communication with SCADA devices.
There are a few SCADA devices available from MATRIX TSL.
Arduino UNO and PIC ECIO28P are two examples of such SCADA devices (Boards) .
Configuring the SCADA device.
Download the SCADA Slave device Firmware for your SCADA device from the MATRIX Homepage .
Unzip the package to a destination folder on your Computer/Notebook.
Program your SCADA device with the .hex file found in the unzipped package.
Create a Flowcode Project - Add SCADA.
Create a new flow code project and save it to your desired location.
Place a While 1 loop on the Flow Chart.
Next Place the following Components on the 2D Panel.
Place a Flowcode Injector(SPI, i2C or UART) in our case this is the SPI injector on the Panel.
Place a SCADA Device Component on the 2D Panel in our case the ADRUINO SCADA.
The 2D Panel should look as below.
The device you are looking to communicate with (Component)
SCADA Device Injector
Set the SCADA Component Properties.
Click on the SCADA device Component in the Panel
Select the Component properties tab in Flowcode if not selected(View >> Component Properties).
Set the Comport (VCP) to be used by Flowcode, if you would like to log the data in the console etc.
Set the Injector Properties.
SCADA Slave use the device you are using in our Case it is the SCADA_ARD_Uno
Set the other properties as indicated yb your device in our case it is the CS pin number and the SPI Prescaler Value.
Connecting your SPI- I2C or UART device component to SCADA Injector
Select your SPI(i2C/UART) Device in the panel and set the Injector Property to the Handle of the Injector you placed on the Panel.
Placing Macro's in the Flow chart to communicate with the SPI(I2C-Uart) device in our case a MCP3201 AD SPI 12 bit Converter.
Above the While 1 main loop call the Hardware macro initialize (if you are developing drivers you will call your hardware macro initialize,This macro initializes the SPI module in a real application it initializes the target micro-controller SPI module, in our case it initializes the SCADA Slave SPI Module.
In the main loop we call the macro's to communicate with the SPI (I2C-UART) device, as required by your development or Simulation in our case we call macro(driver) to sample the Channel differential Voltage and the Channel Raw 12-bit conversion result.The values is saved in the two variables CH_Volts and CH_Raw.(you name your variables as you would like ) During Simulation these values are used to pass on to the next part of code that depends on these values obtained from the ADC.Example you can use these values and display them on the panel in Numeric indication or use them as a parameter to calculate the pressure in a system (Voltage/Pressure translation of a sensor ADC conversion)
Running the Simulation
Use the debug tab buttons to control your simulation process
Press the "GO" button to start the simulation, the following happening
The main loop in the Flow Chart is executed continuously and you will see the arrows on the SCADA and Injector Components on the panel light up
If you place a break point after the macro calls the code execution will stop /halt at the break point and you can inspect the resultant values in the watch window for example.This is very useful for debugging your code and analysis purposes.
How to run and control/ monitor your simulation results is absolutely in your hands this article only give getting started hints. As you can see all the real or actual real world values are available from your device in your simulation.This you test and debug the communication, driver code and your application code all in one go.
Decoding of the SPI - I2C and UART Communication
Flowcode has the ability to decode the Communication(protocol) as it as a Data Recorder as part of its tools .Available it from the Menu Rail
To use the Data Recorder set the Simulation Properties Scope Traces in the Device Component to "Yes" if you would like to log the results in the Console set the property to "Yes"
Run the simulation with a break point set after a macro call so that the simulation stop/halt after the execution of a SPI(I2C/UART) call to the device you are communicating too.
Now inspect the Traces in the Data Recorder (by selecting the Decode Steam button on the left of the Traces) You will see the actual decode data similar as in any Logic Analyser
Using SCADA Simulation with Flowcode is a very powerful feature that help developers to quickly and with minimum effort create drivers for SPI-I2C and UART Communications.
No additional tools requires such as Oscilloscope and Logic Analyser all are included in Flowcode.
It brings real world values into bigger system simulations which makes simulation more reliable.
It shortens development time by factors 2 and 3.
If drivers or code is developed with SCADA simulation they are tested and will work out of the box when applied in an application.