IOServer ASCII Driver FAQ
Home » IOServer ASCII Driver FAQ
Printer Friendly Version
 

IOServer ASCII Driver FAQ

Q: We have various equipment (IEDs (Intelligent Electronic Devices) such as such as relays, transient recorders, meters)  that supports operator commands via a terminal or terminal emulator. These are generally simple ASCII messages command and response.

We wish to extract data from the replies and present this information on an OPC server.

Please advise if you have an OPC server product that allows scripting, wizard, or other methods of manipulating simple ASCII strings in the above command-response manner without having to code up your own OPC server. We wish to extract the data such as frequency error and time deviation, time tag with the time returned in the message and present as "tags" in the OPC server etc as if received via a protocol. The commands are very simple - for instance an Arbiter 1093 GPS satellite clock.

Send to the GPS: "B7" (respond in broadcast mode 1/sec ASCII)
response: "mm/dd/yy hh:mm:ssL ss +f.ffff +t.ttt ppp.pp<cr><lf>" (every second)

where:
    ss = status, 1st character 0 = locked, 1 = unlocked, 2nd character = IEEE P1344 status
    +f.ffff = signed frequency error in Hz
    +t.ttt = signed time deviation in seconds
    ppp.pp = phase angle, 0 to 360 degrees
    L = local time, U = UTC

Other commands to the satellite clock are structured in a similar fashion.

We would also like to be able to send a 'command' plus a 'value' as an ASCII text string to the satellite clock.

The 'value' such as in the set time deviation command ASCII string
    s.fsRD
where s = 0 to +/- 2000 seconds
      fs = fractional seconds
      RD = the set deviation command

We would want the ability to enter the seconds 'value' into the tag prior to sending the command.

ATry the following definition with our ASCII driver.
Data
    Write B7\n
        Word Mode
    Write %6.2fRD\n
        Real SetDeviation
    Read (\d\d)/(\d\d)/(\d\d) (\d\d):(\d\d):(\d\d)([LU]) ([01])(\d) ([-+]\d+\.\d+) ([-+]\d+\.\d+) (\d+\.\d+)\n
        Digital Lock $8
        Byte Status $9
        String TimeStamp[20] $1 $2 $3 $4 $5 $6 $7
        Real FreqError $10
        Real Deviation $11
        Real PhaseAngle $12

Writing any value to Data.Mode will cause the string "B7<lf>" to be sent to the GPS. All incoming data will be matched against the pattern defined after "Read". The [length] in the String definition is the number of bytes including the terminating zero to be allocated for that string.

The deviation can be changed by writing to Data.SetDeviation. The "%6.2f" is a C - style string formatting syntax meaning print the data in floating point format with two decimal places.


Q: I need help with the .def file to correctly parse the data stream that is coming from an Avtron linear foot counter, unsolicited, every .5 seconds in the following format:
    Read \x10\x02\xff\x01\x3e123.456\x10\x03
Where:
    \x10\x02\ Start of message
    \xff Default destination
    \x01 Source ID
    \x3e Message type 3e
    123.456 ASCII format floating point, length 7
    \x10\x03 End of message

If message type is not 3e, then discard. I am only interested in capturing the ASCII floating point field.
A: Try
Data
    Read \x10\x02\xff\x01\x3e(%f)\x10\x03
        Real Value $1


Q: I have an IQ Plus scale interface, which emulates a Mettler-Toledo scale, It send the following string
[STX]*[SP][SP]000179000000[CR]
What is the way to extract the substring of the first 6 digits of 000179000000 (the second 6 digits is tare, which is not used), I want to extract: 000179

I have tried using 
Input
    Read \x02\x2A(.)\x20(\d+)\x0D
        String Motion $1
        Real Weight[6] $2

The motion variable is actually a binary, that depending if it is a 1 or a 0 tells us if the scale is in motion, if it is kilos or pounds, etc., e.g.,
[SP] = 00100000 or when in motion "(" =  00101000.
[STX]*[SP][SP]000179000000[CR]
[STX]*([SP]000173000000[CR]
A: Try
Input
    Read \x02\x2A(.)\x20(%06u)\d+\x0D
        Digital [6] "Motion=3,Metric=5" $1
        Real Weight $2

Input.Motion is the motion bit.


Q: I discovered that if the IQ Plus scale displays a negative number, the tare is not zeros, but spaces. Is there a short cut way to define exactly 6 characters, that can be either digits or spaces?
A: Try
Input
     Read \x02\x2A(.)\x20(%06d)[0-9\x20]+\x0D
         Digital [6] "Motion=3,Metric=5" $1
         Real Weight $2

This will allow Weight to be a signed number.
%06d for signed number, i.e number that may start with a +, -, space or digit


Q: Following is my working Weigh-Tronix .def
Input
    Read \x20G([-+]%06d)\x20([lk][bg])\x0D\x0A
    Real Weight $1
    String Mode[3] $2

The scale indicator is configured to display in pounds with no decimal points and in kilos with one decimal point. How do I accomplish this in the .def.
A: Try
Input
    Read \x20G([-+0-9.]+)\x20([lk][bg])\x0D\x0A
        Real Weight $1
        String Mode[3] $2


Q: Our Fairbanks Scale Digital Indicator Model H90-5200 has the following definition
Input
    Read \x20(\d+)\x20([lk][bg])\x20([GTN][RAT])\x0D\x0A
        Real Weight $1
        String Units[3] $2
        String Mode[3] $3

My question is regarding the String Mode, which can be:

    GR = Gross
    TA = Tare
    NT = Net

But it can be lowercase, denoting that the scale is in motion: ([gtn][rat]) Is there a way to account for this, that is, defining a String Motion[3] (or equivalent) so our OPC Client can monitor this tag and prevent database updates, until the scale has been stabilized with no motion. The idea is to try to have consistency with our OPC client, since other scales have a specific motion bit we can detect, separate from the Mode tag.
A: Try
Input
    Read \x20(\d+)\x20([lk][bg])\x20([gtnGTN][ratRAT])\x0D\x0A
    Real Weight $1
    String Units[3] $2
    String Mode[3] $3
    Digital [16] "Motion=5" $3

Input.Motion will be on if the scale is in motion. This make use of the fact that bit 5 is on for  lower case letters. The Digital array size must be greater than or equal to 16 so that the ASCII driver will not interpret the $3 as hexadecimal.


Q: We have two Veeder-Root Series 7910 Electronic Predetermining Counter with RS-422. The request message format includes a Checksum, for example:
    SOH 01
    Address 03 30 33
    Code 00 30 30
    Checksum 3C 33 43
    EXT 03

"The two character hex checksum represents the negative of the sum of all data including the start character up to the character preceeding the first checksum character, parity bits are excluded from the checksum calculation.

Here is the example for the response message:
    STX 02
    Code 00 30 30
    123456. 31 32 33 34 35 36 2E
    Checksum 3B 33 42
    EXT 03

For the request message the calculation is as follows:
    01 + 30 + 33 + 30 + 30 = hex addition C4
    C4 converted to binary = 11000100
    Inversion = 00111011
    00111100 Twos compliment checksum result = 3C converted to Hex

Can  IOServer handle checksums. There is no option to disable checksums, although I do understand that we can disregard them for the response message.


A: The ASCII driver does have the ability to generate and check checksum and crc. All we need to do is to add your checksum sum method to our code library. The ASCII definition will look something like this

Info
    Poll \x01%02u\a00%02X\c(5,0,0,0)\x03
    Read \x02%02u\a00\(%u)\x2e%02X\c(5,0,0,0)\x03
        Word value $1

%02u\a generate the two digit address, the address is defined by the Address field of the ASCII device.
%02X\c(5,0,0,0) generate the two digit hex negative check sum.


Q: I have a device that returns the numerical (sheet) count in hex (field of 5,with left padding zeros). How do I convert this hex number on the fly so IOServer will display to the OPC Client the decimal equivalent?

AUse
    0x$1 to convert hex string to decimal
    0o$1 to convert octal string to decimal
    0b$1 to convert binary string to decimal.
    $1 is the default to convert a decimal string to decimal


Q: I have been trying IOServer today with the view to using it to interface between an OPC client and a plain ASCII device. For each datapoint, I am aiming to be able to send out a string to my ASCII device something like "D3.UAI1.V " I want to read datapoints only when polled from OPC client, I want to extract a value from the reply string which will be something like "REPLY:24.5" I also want my OPC item name to be that same as the read string. I also need to be able to write a value to the device with a string like "D3.US5.V=34.5" I envisage having a fairly large def file for a typical project, as I need to use about 500 points. all with fixed but different addresses. Some will be RO, others R/W. If I understand correctly I would basically have a list of the address/string in the def file. Please can you assist in any way.
A: I have attached a configuration (ascsim.io, ascslave.def, ascmaster.def) that simulate a slave ASCII device and a master ASCII device over TCP/IP. 
    This configuration show the following.
    1. A slave device that will respond to read and write requests from the master.
    2. A master device that will issue read and write requests to the slave, only points that are requested by the OPC client will be polled. Use the group update time to control the polling rate.
    3. The read/write attribute are presented correctly.
    4. Use array to reduce that size of the .def file. We use metacharacter '\i' to handle array.
    5. Use multiple devices to represent Dx

We assume that you need a line feed at the end of each message.


Q: Can you help me with my protocol:
The Poll message is 
LDD
Where
    L :  (LOOP) would be ONE of these characters ( $!"%/)
    DD : (ADDRESS) a combination of characters from P to Y.
    so an example of polling string should look like
        !PQ

THE INCOMING STRING LOOKS LIKE THIS
        bbDDTTTLLLLL&
Where
    bb: (two bytes with 8 binary flags each) Each bit should be configured as a TAG
    DD: Same as ADDRESS Sent (only used to check if answer was from same transmitter polled)
    TTT: three characters for temperature. Temp TAG
    LLLLL : LEVEL (last two positions are for decimal places) Level TAG
    &: End of message

AYou can try the following definition
# Tank Data
Data
    Poll !%s\a
    Read (..)%2s\a(%3u)(%f)&
    # Digital Status
        Digital [16]"PE\tEquation Type=0,MO\tStation Mode,CA\tControl Action,SWM\tSoftware A/M Mode,DO\tDerivative,PVT\tPV Tracking,EN\tEnable,PVHA\tPV High Alarm,PVLA\tPV Low Alarm,DVPA\tDeviation Low Alarm,DVNA\tDeviation High Alarm,EWD\tError Within Dead Band,OLH\tOutput Limit High,OLL\tOutput Limit Low,SPOR\tSP Out of Range,INI\tPID Initialised" $1
    # Temperature
        Word Temp $2
    # Tank Level
        Real Level $3

    Add a device to the port for each device required with Device Address set to PP to YY.
    Note the use of the quoted string after the Digital array definition to allow the symbolic addressing of each binary flags.
    Use \x25 instead of % in the Poll String.

 
© Copyright IOServer Pty Ltd. All rights reserved.
E-mail:  Phone/Fax: +61 2 9805 0356 (Australia)

Last updated: 11 July 2012