8 input and output of data, Sending messages – Yaskawa SMC–4000 User Manual

Page 342

Advertising
background image

332

SMC–4000 User Manual

8 Input and Output of Data

Sending Messages

Messages may be sent to the bus using the

MG (Message)

command. This command sends specified text

and numerical or string data from variables or arrays to the screen.

Text strings are specified in quotes and variable or array data is designated by the name of the variable or
array. For formatting string variables, the {Sn} specifier is required where n is the number of characters, 1
through 6. Example:

MG STR {S3}

The above statement returns 3 characters of the string variable named STR.

Numeric data may be formatted using the {Fn.m} expression following the completed MG statement.
{$n.m} formats data in HEX instead of decimal. Example:

MG "The Final Value is", RESULT {F5.2}

The above statement sends the message:

The Final Value is xxxxx.xx

The actual numerical value for the variable, RESULT, is substituted with the format of 5 digits to the left
of the decimal and 2 to the right.

In addition to variables, functions and commands, responses can be used in the message command. For
example:

MG "Analog input is", @AN[1]

MG "The Position of X is", _TPX

The message command normally sends a carriage return and line feed following the statement. The
carriage return and the line feed may be suppressed by sending {N} at the end of the statement. This is
useful when a text string needs to surround a numeric value.

Example:

When #A is executed, the above example will appear on the screen as: The speed is 50000 counts/sec

The MG command can also be used to configure terminals. Here, any character can be sent by using {^n}
where n is any integer between 1 and 255.

Example:

MG {^07} {^255} sends the ASCII characters represented by 7 and 255 to the bus.

#A

Label

JG 50000;BGX;ASX

Jog, Begin, After Speed

MG "The Speed is", _TVX {F5.1} {N}

Message

MG "counts/sec"

Message

EN

End Program

Advertising