Galil DMC-2X00 用户手册

下载
页码 267
DMC-2X00 
Chapter 7 Application Programming  
y 109  
Sending Messages 
Messages may be sent to the bus using the message command, MG.  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 example: 
MG "The Final Value is", result 
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 A is", _TPA 
Specifying the Port for Messages: 
By default, messages will be sent through the port specified by the USB/Ethernet Dip Switch - the state 
of this switch upon power up will determine if messages will be sent to USB port (DMC-2000), or 
Ethernet (DMC-2100/2200) the Main Serial Port.   However, the port can be specified with the 
specifier, {P1} for the main serial port {P2} for auxiliary serial port, {U} for the USB port , or {E} for 
the Ethernet port. 
MG {P2} "Hello World"   
Sends message to Auxiliary Port 
Formatting Messages 
String variables can be formatted using the specifier, {Sn} where n is the number of characters, 1 thru 
6.  For example: 
 
MG STR {S3} 
This 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. The actual numerical value will be formatted with n 
characters to the left of the decimal and m characters to the right of the decimal.  Leading zeros will be 
used to display specified format. 
For example: 
 
MG "The Final Value is", result {F5.2} 
If the value of the variable result is equal to 4.1, this statement returns the following:  
The Final Value is 00004.10 
If the value of the variable result is equal to 999999.999, the above message statement returns the 
following:  
The Final Value is 99999.99 
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: 
#A 
JG 50000;BGA;ASA 
MG "The Speed is", _TVA {F5.1} {N} 
MG "counts/sec"