Instructions
UM-0085-B09  DT80 Range User Manual  Page 359 
RG 
  Reading Fixed Width ASCII 
In this case a simple serial sensor continuously transmits a stream of records which consist of an A character followed by 
four 4-digit fixed point (2 decimal place) temperature values (2209 represents 22.09, for example). 
This job samples the stream every 30 seconds and logs the values it reads. 
  BEGIN"SPOT" 
   PS=RS232,1200,7,E,1 
   RA30S 
   1SERIAL("\eA%4d[1CV]%4d[2CV]%4d[3CV]%4d[4CV]",W) 
   1..4CV(.01,"~degC",FF2) 
   LOGON 
  END 
Notice: the receive buffer is cleared at the start of the control string. The 1SERIAL channel will therefore wait until the next update 
from the sensor. An alternative strategy would be clear the buffer at the end, in which case the 
1SERIAL channel would immediately 
get what it needs from the buffer. However the data it reads will be the first
 record in the buffer and would therefore be up to 30s old. 
  Reading Binary Data 
In this example an even more simple sensor outputs 6 bytes of data in response to a digital signal going low. These are 
to be interpreted as two binary values. The first is a 16-bit integer sequence number, in big endian format (most 
significant byte first). The second value is a 32-bit voltage measurement, scaled such that 0x00000000 represents -
17.0V and 0xFFFFFFFF represents +17.0V. For historical reasons, this value happens to be returned in little-endian 
(least significant byte first) format. 
This job triggers a reading (by pulsing the 1D output low) every 5 seconds and reads and logs the received values. 
  BEGIN"RAMBUTAN" 
   PS=RS232,115200 
   S1=-17,17,0,4294967296"V" 
   RA5S 
   1DSO(100,R)=0 
   1CV(W)=-1 
   1SERIAL("%2b[1CV]%b[5CV]%b[6CV]%b[7CV]%b[8CV]",W) 
   1CV("Seq") 
   2CV(S1)=8CV*16777216+7CV*65536+6CV*256+5CV 
   LOGON 
  END 
Note the following points about this job: 
•  In this case the sequence number can be read as a single binary number, using %2b, but the measured value 
must be read byte by byte and reassembled into a single value. 
•  A span (S1) is used to scale the reading into the correct range. 
•  1CV is set to an error value (-1) before each attempt to read the serial channel. If the attempt fails (e.g. no data 
is forthcoming from the device) then 1CV will be unchanged, so the value -1 will be logged for the sequence 
number. This makes it easy to identify the reading as invalid. 
Note: CVs can only precisely store integers with absolute value less than 16,777,216 (24 bits) – above that they will be rounded. In the 
above example this is not a problem because the value is scaled and rounded anyway. 
If, however, you need to recover all 32 bits exactly (for example if they represented 32 separate logic states) then you 
should read them using two 16 bit conversions and log each half separately, e.g.: 
  BEGIN"WHISTLE" 
   RA1+E 
   1..2CV(W)=-1 
   1SERIAL("%2b[1CV]%2b[2CV]",W) 
   1CV("MS 16 bits") 2CV("LS 16 bits") 
   LOGON 
  END 
(This example assumes the data word is in big endian format). 










