Component: SCADA (Arduino Uno) (SCADA Slaves)

From Flowcode Help
Jump to navigationJump to search


Author Matrix TSL
Version 1.0 (Release)
Category SCADA Slaves


Image SCADA (Arduino Uno) component

Connects to an Arduino Uno running the SCADA Arduino Uno Firmware allowing the board to become a slave to the flowcode simulation runtime. Supports: Digital IO / ADC / I2C / SPI / PWM See Flowcode Help Wiki for firmware.

Detailed description

The SCADA (Arduino Uno) component allows an Arduino Uno board to be controlled from within the Flowcode simulation runtime.

To allow Flowcode to communicate and control the Arduino Uno hardware the board must first be pre-programmed with dedicated firmware.

The firmware hex file and Flowcode source project can be downloaded from here.

ZIP Icon.png Arduino Uno SCADA Firmware

More information about the workings of the firmware project can be found on the FiniteStateMachine page.


The COM port to the Arduino hardware is selected via the SCADA_Ard_Uno componennt COM port property.

When building the component into a SCADA project remember to expose the COM port property to allow the end user to select the correct port for the hardware.


The console window can display data in two modes which is set via a component property.

  • fixed statistics showing IO / ADC inputs / PWM
  • scrolling log showing all commands and returns


Examples

Direct Slave Access

Here is a simple demo to switch on and off digital pin 5.

FC6 Icon.png Simple Arduino Uno Demo


Rapid Development - Virtualised SPI

A feature of the SCADA Slave interface is to use the component for rapid development.

The SCADA Slave hardware can be used to take communications from the Flowcode simulation and transfer them to a real world device allowing for easy code generation and test without having to download to a target microcontroller device.

The CS pin and SPI Prescaler are set via the properties of the Injector component.

The SPI Master component is linked to the Injector component via the Injector property.

The Injector component is linked to the SCADA Slave component via the SCADA Slave property.


FC6 Icon.png Arduino Uno SCADA Slave SPI Demo


Rapid Development - Virtualised I2C

A feature of the SCADA Slave interface is to use the component for rapid development.

The SCADA Slave hardware can be used to take communications from the Flowcode simulation and transfer them to a real world device allowing for easy code generation and test without having to download to a target microcontroller device.

The I2C Master component is linked to the Injector component via the Injector property.

The Injector component is linked to the SCADA Slave component via the SCADA Slave property.


FC6 Icon.png Arduino Uno SCADA Slave I2C Demo


Rapid Development - Virtualised UART

A feature of the SCADA Slave interface is to use the component for rapid development.

The SCADA Slave hardware can be used to take communications from the Flowcode simulation and transfer them to a real world device allowing for easy code generation and test without having to download to a target microcontroller device.

The Baud rate and optional RS485 Properties are set via the properties of the Injector component.

The UART component is linked to the Injector component via the Injector property.

The Injector component is linked to the SCADA Slave component via the SCADA Slave property.


FC6 Icon.png Arduino Uno SCADA Slave UART Demo

Downloadable macro reference

This component does not contain any downloadable macros

Simulation macro reference

I2CInitialise

Initialsie the I2C module ready for communications

Parameters

This macro has no parameters


Return value

This call does not return a value


IOGetInputPin

Sets the selected digital pin to an input and reads the input state.

Parameters

BYTE Pin
Range: 0-13


Return value

BOOL : Returns true if the operation is a success, else false


ADCSample8

Reads the voltage present on an Alanog pin as an 8-bit value range 0-255

Parameters

BYTE ADCChannel
Range: 0-5


Return value

BYTE


I2CRestart

Put the I2C Module into Restart mode

Parameters

This macro has no parameters


Return value

This call does not return a value


PWMDisable

Disable a PWM output

Parameters

BYTE Channel
Range: 0-5


Return value

This call does not return a value


I2CReceive

Receive a byte using the I2C bus

Parameters

BOOL Last
Last byte to receive: Range 0-1


Return value

BYTE


I2CStart

Put the I2C Module into Start mode

Parameters

This macro has no parameters


Return value

This call does not return a value


SPITransfer

Transfer a byte using the SPI bus

Parameters

BYTE DataOut


Return value

BYTE


I2CStop

Put the I2C Module into Stop mode

Parameters

This macro has no parameters


Return value

This call does not return a value


SPIPrescaler

Modify the speed of the SPI bus

Parameters

BYTE Prescaler
Range: 0-2


Return value

This call does not return a value


PWMSetDuty

Sets the duty for the PWM output

Parameters

BYTE Channel
Range: 0-5
BYTE Duty


Return value

This call does not return a value


ADCSample10

Reads the voltage present on an Alanog pin as an 10-bit value range 0-1023

Parameters

BYTE ADCChannel
Range: 0-5


Return value

UINT


IOSetOutputPin

Sets the selected digital pin to an output and assigns the output state.

Parameters

BYTE Pin
Range: 0-13
BOOL State
Range: 0-1


Return value

This call does not return a value


SPIInitialise

Initialsie the SPI module ready for communications

Parameters

This macro has no parameters


Return value

This call does not return a value


I2CSend

Transmit a byte using the I2C bus

Parameters

BYTE DataOut


Return value

BOOL : Returns true if the operation is a success, else false


PWMSetPrescaler

Sets the prescaler for the PWM output

Parameters

BYTE Channel
Range: 0-5
BYTE Prescaler


Return value

This call does not return a value


PWMEnable

Enable a PWM output

Parameters

BYTE Channel
Range: 0-5


Return value

This call does not return a value


Initialise

Initialise the comms to the Arduino board ready for commands to be sent.

Parameters

This macro has no parameters


Return value

This call does not return a value



Property reference

Data Source

This property is of type Fixed list of ints and can be referenced with the variable name scada_uart1::DataSource.

Simulation data source used to allow the component to connect to various remote devices

Nothing - Simulation data is ignored

COM port - Routes the communication data to and from a physical or virtual COM port

Injector - Routes the communication data via a data injector component on the Panel.

COM Port

This property is of type Fixed list of ints and can be referenced with the variable name scada_uart1::com_port.

Lists all the current available COM port hardware on your PC.

Refresh Ports

This property is of type True or false and can be referenced with the variable name scada_uart1::RefreshPorts.

No additional information


Console Log

This property is of type True or false and can be referenced with the variable name ConsoleLog.

Create an automatic console log of the commands sent to the Arduino

Log Mode

This property is of type Fixed list of ints and can be referenced with the variable name LogMode.

Controls how the console data is formatted.

Fixed statistics gives an easy to read overview of the IO, Analog and PWM functionality

Command Log gives a more in depth analysis of the outgoing commands and incoming returns