Component: Modbus Slave (SCADA) (Comms: System)

From Flowcode Help
Jump to navigationJump to search


Author Matrix TSL
Version 1.0 (Release)
Category Comms: System


Image Modbus Slave (SCADA) component

Modbus component for creating Modbus compatible slave hardware via RS232 or RS485.

Examples

No additional examples


Downloadable macro reference

ReadHoldingRegister

Reads the value of a single holding register.

Parameters

UINT Address
Coil Address


Return value

UINT


ReadCoilStates

Reads the state of a single digital coil.

Can pack a max of 8-bits together in a single operation

Parameters

UINT StartAddress
Coil Address Range 0 to (NumCoils - 1)
BYTE AddressCount
Range 1-8


Return value

BYTE


ReadAnalogueInput

Reads the value of a single analogue input.

Parameters

UINT Address
Coil Address


Return value

UINT


ReadInputStates

Reads the state of a single digital input.

Can pack a max of 8-bits together in a single operation

Parameters

UINT StartAddress
Coil Address Range 0 to (NumCoils - 1)
BYTE AddressCount
Range 1-8


Return value

BYTE


SetSlaveAddress

Allows the slave address to be overridden from the default slave address specified

in the component property. The number of bytes used for the address is fixed by the

Slave ID Bytes property to save on RAM usage.

Parameters

UINT SlaveAddress


Return value

This call does not return a value


SetCoilState

Sets the state of a single digital coil.

Parameters

UINT Address
Coil Address
BYTE State
0=off, 1=on


Return value

This call does not return a value


ChangeFrameType

Default frame type is the type set in the component properties.

Parameters

BYTE Type
0 = Modbus RTU / 1 = Modbus ASCII


Return value

This call does not return a value


SetInputState

Sets the state of a single digital input.

Parameters

UINT Address
Coil Address
BYTE State
0=off, 1=on


Return value

This call does not return a value


SetHoldingRegister

Sets the state of a single holding register.

Parameters

UINT Address
Coil Address
UINT Value
Analogue Value range 0 - 65535


Return value

This call does not return a value


CheckForIncoming

Checks for an incoming message and if the data address is within range then also automatically replies with the correct reply.

Returns 0 if no comms received, 1 for a succesful transaction, 255 for an error.

Parameters

This macro has no parameters


Return value

BYTE


GetLastIncoming

Gets a value from the last incoming command.

Index 0 = 0 Read / 1 Write

Index 1 = 0 Coils / 1 DigInput / 2 AnInput / 3 Register

Index 2 = Address

Index 3 = Number

Parameters

This macro has no parameters


Return value

UINT


SetAnalogueInput

Sets the state of a single analogue input.

Parameters

UINT Address
Coil Address
UINT Value
Analogue Value range 0 - 65535


Return value

This call does not return a value


Initialise

Starts up the UART to allow communications and initialises the states of the various

Modbus Coils, Inputs and Registers to 0.

Parameters

This macro has no parameters


Return value

This call does not return a value


Simulation macro reference

This component does not contain any simulation macros


Property reference

Frame Type

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

Switches between RTU and ASCII forms of Modbus

Receive Buffer Size

This property is of type Unsigned integer and can be referenced with the variable name ReceiveBufferSize.

Maximum number of bytes the receive buffer can hold

Receive Timeout

This property is of type Unsigned integer and can be referenced with the variable name Timeout.

Length in milliseconds to wait for additional bytes to be received when checking for incoming messages.

Slave ID Bytes

This property is of type Unsigned integer and can be referenced with the variable name AddressBytes.

Number of bytes used when passing a slave ID, usually 1 but sometimes 2

Slave Address

This property is of type Unsigned integer and can be referenced with the variable name SlaveAddress.

No additional information


Reply Delay

This property is of type Unsigned integer and can be referenced with the variable name ReplyDelay.

Delay in micro seconds to wait before transmitting a reply

Maintain Stats

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

Controls if the last command from the master is logged allowing for easier value updates.

No - Do not log commands

Yes - Commands are logged and available via the GetLastIncoming macro

Label

This property is of type Line of text and can be referenced with the variable name label.

A text label to appear on the Modbus panel object.

Console Data

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

Selects if the console data is automatically generated or not

Console Columns

This property is of type Unsigned integer and can be referenced with the variable name scada_uart1::ConsoleColumns.

Number of characters that can be displayed on a single line of the console.

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.

Baud Rate

This property is of type Unsigned integer and can be referenced with the variable name scada_uart1::baud.

COM port data rate in bits per second

Starting Address

This property is of type Unsigned integer and can be referenced with the variable name StartAdrCoil.

Start address of the Modbus coils. Referenced from 0.

For example

Slave 1 might have 100 coils addressed 0-99 Start Address = 0

Slave 2 might have 100 coils addressed 100-199 Start Address = 100

Number of Addresses

This property is of type Unsigned integer and can be referenced with the variable name NumAdrCoil.

Specifies how many Coils are available on the slave.

Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte.

Starting Address

This property is of type Unsigned integer and can be referenced with the variable name StartAdrDI.

Start address of the Modbus digital inputs. Referenced from 0.

For example

Slave 1 might have 100 inputs addressed 0-99 Start Address = 0

Slave 2 might have 100 inputs addressed 100-199 Start Address = 100

Number of Addresses

This property is of type Unsigned integer and can be referenced with the variable name NumAdrDI.

Specifies how many Digital Inputs are available on the slave.

Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte.

Starting Address

This property is of type Unsigned integer and can be referenced with the variable name StartAdrAI.

Start address of the Modbus analogue inputs. Referenced from 0.

For example

Slave 1 might have 100 inputs addressed 0-99 Start Address = 0

Slave 2 might have 100 inputs addressed 100-199 Start Address = 100

Number of Addresses

This property is of type Unsigned integer and can be referenced with the variable name NumAdrAI.

Specifies how many 16-bit analogue inputs are available on the slave.

Each address consumes two RAM Bytes.

Starting Address

This property is of type Unsigned integer and can be referenced with the variable name StartAdrReg.

Start address of the Modbus registers. Referenced from 0.

For example

Slave 1 might have 100 registers addressed 0-99 Start Address = 0

Slave 2 might have 100 registers addressed 100-199 Start Address = 100

Number of Addresses

This property is of type Unsigned integer and can be referenced with the variable name NumAdrReg.

Specifies how many 16-bit holding registers are available on the slave.

Each address consumes two RAM Bytes.