0
|
1 |
## \file
|
|
2 |
## Stream Device Protocol for eurotherm 2000 series EI Bisynch
|
|
3 |
## \param GAD = First char of address, e.g. address = 1, GAD = 0, address = 12, GAD = 1
|
|
4 |
## \param LAD = Second char of address, e.g. address = 1, LAD = 1, address = 12, LAD = 2
|
|
5 |
|
|
6 |
locktimeout = 5000;
|
|
7 |
|
|
8 |
## Unfortunately, this is designed with a checksum terminator.
|
|
9 |
OutTerminator = "";
|
|
10 |
replytimeout = 200;
|
|
11 |
## Setting a small readtimeout means that we can get data without needing a terminator
|
|
12 |
readtimeout = 100;
|
|
13 |
extrainput = Ignore;
|
|
14 |
|
|
15 |
#STX = "\x02"
|
|
16 |
#ETX = "\x03"
|
|
17 |
#EOT = "\x04"
|
|
18 |
#ENQ = "\x05"
|
|
19 |
#ACK = "\x06"
|
|
20 |
|
|
21 |
## Read value
|
|
22 |
## \code
|
|
23 |
## send: [EOT](GAD)(GAD)(LAD)(LAD)(CHAN)(C1)(C2)[ENQ]
|
|
24 |
## reply: [STX](CHAN)(C1)(C2)<DATA>[ETX](BCC)
|
|
25 |
## \endcode
|
|
26 |
## - $1 = GAD
|
|
27 |
## - $2 = LAD
|
|
28 |
## - $3 = command mnemonic
|
|
29 |
#############################################################################
|
|
30 |
read { InTerminator = "\x03"; out "\x04\$1\$1\$2\$2\$3\x05"; in "\x02\$3%f"; }
|
|
31 |
|
|
32 |
## Read value, but in hex
|
|
33 |
readhex { InTerminator = "\x03"; out "\x04\$1\$1\$2\$2\$3\x05"; in "\x02\$3>%x"; }
|
|
34 |
|
|
35 |
## NOTE: we rely on readtimeout for the in commands.
|
|
36 |
## Could use maxInput, but that screws up record initialisation (once inTerminator is set it can't be overwritten in the \@init handler)
|
|
37 |
##
|
|
38 |
## Write value
|
|
39 |
## \code
|
|
40 |
## send: [EOT](GAD)(GAD)(LAD)(LAD)[STX](CHAN)(C1)(C2)<DATA>[ETX](BCC)
|
|
41 |
## reply: [ACK] or [NAK], discarded as no terminator
|
|
42 |
## \endcode
|
|
43 |
## - $1 = GAD
|
|
44 |
## - $2 = LAD
|
|
45 |
## - $3 = command mnemonic
|
|
46 |
## - $4 = device prefix, \$(P)\$(Q)
|
|
47 |
#############################################################################
|
|
48 |
write { InTerminator = ""; out "\x04\$1\$1\$2\$2\x02\$3%f\x03%6<xor>"; in "\x06"; @init{ read; }; @mismatch{ in "%(\$4:ERR.PROC)r"; }; }
|
|
49 |
|
|
50 |
## Write a value in int rather than float
|
|
51 |
writeint { InTerminator = ""; out "\x04\$1\$1\$2\$2\x02\$3%i\x03%6<xor>"; in "\x06"; @init{ read; }; @mismatch{ in "%(\$4:ERR.PROC)r"; }; }
|
|
52 |
|
|
53 |
|
|
54 |
### \brief Controller configuration mode
|
|
55 |
##
|
|
56 |
## This mode enable setting a number of controller configuration settings
|
|
57 |
## (see Communications Handbook PDF pages 5-25 onwards)
|
|
58 |
##
|
|
59 |
## We set the mode by sending a command 'IM2' and get out of the mode with the command 'IM0'
|
|
60 |
## While in configuration mode the controller makes itself address 0 so any configuration commands
|
|
61 |
## have to be sent to address = 0
|
|
62 |
setConfMode { InTerminator = ""; out "\x04\$1\$1\$2\$2\x02IM2\x03%6<xor>"; in "\x06"; @mismatch{ in "%(\$3:ERR.PROC)r"; }; }
|
|
63 |
|
|
64 |
## Escape from the configuration mode in to normal operation mode
|
|
65 |
clearConfMode { InTerminator = ""; out "\x040000\x02IM0\x03%6<xor>"; in "\x06"; @mismatch{ in "%(\$1:ERR.PROC)r"; }; }
|
|
66 |
|
|
67 |
## Get the current mode of the controller: 0=normal mode, 2=configuration mode
|
|
68 |
getConfMode { InTerminator = "\x03"; out "\x0400%(\$1:ADDR.VAL)i%(\$1:ADDR.VAL)iIM\x05"; in "\x02IM%i."; }
|
|
69 |
|
|
70 |
## \brief Set device precision.
|
|
71 |
##
|
|
72 |
## The number of decimal places in the controller is also the precision the data is returned when communicating over serial.
|
|
73 |
## This parameter can only be set when in Configuration Mode (see above)
|
|
74 |
setDecPlaces { InTerminator = ""; out "\x0400%(\$1:ADDR.VAL)i%(\$1:ADDR.VAL)i\x02QD%i\x03%6<xor>"; in "\x06"; @mismatch{ in "%(\$1:ERR.PROC)r"; }; }
|
|
75 |
|
|
76 |
## Read the number of decimal places used in the controller
|
|
77 |
getDecPlaces { InTerminator = "\x03"; out "\x0400%(\$1:ADDR.VAL)i%(\$1:ADDR.VAL)iQD\x05"; in "\x02QD%i."; }
|
|
78 |
|
|
79 |
## The ramp rate time unit. Note this parameter can only be set when in Configuration Mode
|
|
80 |
setRampRateUnit { InTerminator = ""; out "\x0400%(\$1:ADDR.VAL)i%(\$1:ADDR.VAL)i\x02QJ%i\x03%6<xor>"; in "\x06"; @mismatch{ in "%(\$1:ERR.PROC)r"; }; }
|
|
81 |
|
|
82 |
## Read out the ramp rate time unit
|
|
83 |
getRampRateUnit { InTerminator = "\x03"; out "\x0400%(\$1:ADDR.VAL)i%(\$1:ADDR.VAL)iQJ\x05"; in "\x02QJ%i."; }
|
|
84 |
|
|
85 |
## \brief Write any ASCII string command to the device.
|
|
86 |
##
|
|
87 |
## It will read the device address (although only the LAD part) from another record: \$1:ADDR.VAL
|
|
88 |
addrWrite { InTerminator = ""; out "\x0400%(\$1:ADDR.VAL)i%(\$1:ADDR.VAL)i\x02%s\x03%6<xor>"; in "\x06"; @mismatch{ in "%(\$1:ERR.PROC)r"; }; }
|
|
89 |
|
|
90 |
## \brief Read back any ASCII string paramter from the device.
|
|
91 |
##
|
|
92 |
## This will also read the device address from an external record.
|
|
93 |
addrRead { InTerminator = "\x03"; out "\x0400%(\$1:ADDR.VAL)i%(\$1:ADDR.VAL)i%s\x05"; in "\x02%(\$1:ADDR:RESP.VAL)6c"; }
|
|
94 |
|
|
95 |
|
|
96 |
|