AsciiWrite (FB)

FUNCTION_BLOCK AsciiWrite EXTENDS AC500_StateMachine.AbbLCon3

Function block to send messages on a serial connection in ASCII code

The input Message must be defined as STRING. The input Length must be the actual character length of the Message and not the size of the variable.

Hint

For AsciiWrite, only CHARACTER can be used as telegram ending selection. All other ending selections has to be done in the user program.

Hint

The max size of Message is 255 by default and can be increased with the CharLength parameter.

After successful sending of the message, the COM port is closed automatically provided that the AsciiRead is not in use. If AsciiRead is used in parallel, the COM port remains open to continue reading.

InOut:

Scope

Name

Type

Initial

Comment

Inherited from

Input

Enable

BOOL

FALSE

A rising edge (Enable = TRUE) starts a single operation, the output Busy goes to TRUE. All other inputs are read and considered continuously. A falling edge (Enable = FALSE) aborts the operation, if BUSY=TRUE (Note: During Aborting the Busy is still TRUE). Afterwards all outputs will be reset. For executing another operation the Enable input needs to be retriggered by another rising edge!

AbbLCon3

Output

Done

BOOL

FALSE

Operation is completed without error (while outputs Busy and Error are FALSE). This output is TRUE for at least one cycle or until Enable is set to FALSE.

AbbLCon3

Busy

BOOL

FALSE

Operation is running (while outputs Done and Error are FALSE)

AbbLCon3

Error

BOOL

FALSE

Operation is stopped with error (while outputs Busy and Done are FALSE). This output is TRUE for at least one cycle or until Enable is set to FALSE. The output ErrorID gives more details about the error.

AbbLCon3

Input

Com

STRING

‘COM_1’

Node name of the serial interface

TelegramEnding

TELEGRAM_ENDING

Telegram ending parameter

Message

STRING(Param.CharLength)

Message with a maximum number of the parameter “CharLength”

Length

UDINT

Actual length of the entered message to be send

Output

ErrorId

ERROR_ID

ERROR_ID.NO_ERROR

ErrorId <> NO_ERROR if output Error = TRUE

AddErrNo

DWORD

0

Additional error number to indicates errors coming from underlying libraries. Please check AC500_Com.COM.ERROR enumeration for references