UM-0085-B09
DT80 Range User Manual
Page 355
RG
For example, if the control string is
1SERIAL("%d")
:
Input data
Result
"
abc
"
Scan Error (return
NotYetSet
;
abc
left in receive buffer)
"
123
"
Receive Timeout (return
NotYetSet
, nothing left in receive buffer)
"
123
"
return 123 ("
" left in receive buffer)
"
123abc
"
return 123 (
abc
left in receive buffer)
Control String – Example
The control string in the Serial Channel command
1SERIAL("\e{WN\013}%d[1CV],%f[2CV]{C\013}\w[2000]")
specifies the following output and input actions for supervising electronic weighing scales connected to the serial sensor
port of a DT80:
Input/Output action
Description
\e
An input action.
\e
erases any extraneous characters that may have been sent by the scales at some earlier time.
{WN\013}
An output action.
Sends the "Weigh Now" command (
WN
) to the scales. The
WN
command is terminated by a
carriage return (
\013
). (See your serial device’s manual for details of its command set.)
%d[1CV],%f[2CV]
Three input actions.
These scales return two comma-separated values: a batch number as an integer, and the weight
as a floating-point value, followed by a carriage return.
%d[1CV]
will interpret the first returned value as an integer batch number, and assign
this to 1CV.
Skip the comma in the returned data string (
,
).
%f[2CV]
will interpret the second returned value as a floating-point weight in kilograms,
and assign this to 2CV.
{C\013}
An output action.
These scales also have a Clear command (
C
), which instructs the scales to clear ready for the next
weighing operation.. This output action sends the Clear command to the scales. The Clear
command is terminated by a carriage return (
\013
).
\w[2000]
An input action.
These scales do not respond to commands for 2s after a Clear operation. The
\w[2000]
action
ensures that at least this time elapses following a Clear.
Important:
The
DeTransfer
program, which is often used to supervise the DT80, has a number of special commands that begin with a \
(backslash) character. These are interpreted by
DeTransfer
and not sent to the DT80. In order to send a \ character from
DeTransfer
,
you need to enter a double backslash (\\). For example, the above example would be entered into
DeTransfer
as follows:
1SERIAL("\\e{WN\\013}%d[1CV],%f[2CV]{C\\013}\\w[2000]")
This rule applies to
DeTransfer
only; it does not apply to the Command window in
dEX
.
Schedules
Executing Serial Channel Commands in Schedules
Like any other channel type, Serial Channel commands can be placed into scan schedules. For example
BEGIN
PS=RS485,9600
RA1M 1SERIAL("\e{01READ^M}%6f")
RB2-E 1SERIAL("\e{02READ^M}%12s[1$]",W) 1$
LOGON
END
This example will, once a minute, request then read a floating point value from device #1 on the multi-drop RS485 link
connected to the serial channel. Also, every time digital input
2D
goes low, the serial channel will request then read a
string value from device #2.
Notice:
in the first schedule the scanned floating point value is the return value of the
SERIAL
channel, which will then be logged and
returned. In the second schedule, the scanned string is assigned to string variable 1$. The
SERIAL
channel will then return a status
code – which in this example we are not concerned about so the
W
channel option is used to make the channel a working channel (not
logged or returned).
Serial commands can also be used in the "immediate" schedule, i.e. executed immediately after they are entered. For
example, sending
2SERIAL("{hello^M^J}")
will immediately transmit the indicated string on the host port (assuming it has been configured for serial channel
operation).