CHAPTER 1 DATA SCALING SERVICES _____________________ 1.1 OVERVIEW Scaling services are available as library routines to allow the application programmer to easily and efficiently convert the data returned by the selective data acquisition system to appropriate formats for display and computation. The services are transparently available to console and central node applications. Each routine for a property's data requires a Process Data Block and the data upon which it is to operate. Any programmer may call these routines from any language which allows access to the R5 pass by reference calling sequence and the PDP-11 F77 function value register definitions as defined in Section 2.2.1 of the PDP-11 FORTRAN-77 ______ __________ Object Time System Reference Manual (V4.0, order number AA-1874C-TC). ______ ____ ______ _________ ______ Calling sequences used by a FORTRAN programmer and the data structures used by the scaling service routines are shown for each property. The type of operation requested as well as the type of the returned result is implicit in the name of the function. This frees the user from including extraneous symbol names and generally makes for a more readable program. Recall that the type of data returned from a device is specified by the property; the routine descriptions listed below are listed by the properties which return the data they operate upon. Each routine in a section, therefore, corresponds to a different method of processing the data returned by a property. The data structures are shown for illustrative purposes. A fully developed suite of library routines does not require knowledge of them. 1-1 DATA SCALING SERVICES _____________________ 1.2 PROCESSING READING AND SETTING PROPERTY DATA 1.2.1 The READING And SETTING PDB's The reading scaling services can operate on input data which is one, two, or four bytes in length and originates from either the READING property or the SETTING property. (Don't forget that the setting property of a device may be requested to obtain the current setting, therefore scaling the return or reading of the setting makes perfect sense.) Processed data is always returned as a two or four byte word-aligned value by the data collection system. A storage block has been defined to hold device-specific information for processing the data associated with a given device's READING or SETTING property data. These storage blocks are called Process Data Blocks or PDB's. The READING and SETTING property share a common PDB format though a separate PDB is required for each property. PDB's are generally defined as variable length structures. At this time the ones for the READING and SETTING properties have a maximum length of 36 bytes. The total length of the PDB is stored in the first byte of the PDB (including the first byte). The format of the READING and SETTING property PDBs is shown below. Length Symbolic (bytes) Offset ---------- -------- +-------------------------------------------+ 1 PDBLEN | length of PDB in bytes | |-------------------------------------------| 1 PDRSFL | MC | LS | DS | CS | | | IDL | |-------------------------------------------| 4 PDRSPU | primary units text ('Volt','Ohm_','Tick') | |-------------------------------------------| 4 PDRSCU | common units text ('Amp_','DegK','uSec') | |-------------------------------------------| 1 PDRSPT | primary transform index (raw to 'volts') | |-------------------------------------------| 1 PDRSCT | common transform index ('volts' to eng.u.)| |-------------------------------------------| 6*4 PDRSCC | common transform constants | +-------------------------------------------+ IDL Two bit field specifying the expected length of unprocessed input data. This field may only take on the values zero, one, and two (representing lengths of one, two and four bytes). All other values are undefined at this time. MC Bit defining whether this device should be treated as a motor controller for purposes of displaying its setting and calculating new setting requests or as a D/A (or other absolutely settable device). (0=D/A, 1=stepper motor controller) 1-2 DATA SCALING SERVICES _____________________ LS Bit defining the preferred precision for interactive display purposes. Short format implies that a six character display is sufficient while long requires 8 (or perhaps more) characters for output. The long format is intended to provide for output of 24-bit timer values. Most other data can use short format. (0=short, 1=long). DS Bit defining the default method of display for interactive users, either decimal or scientific notation (0=decimal, 1=scientific). CS Bit defining whether or not this property is considered to be a controlled setting. If it is a controlled setting (bit set), generic programs such as the parameter page should not support the setting of this property. PDB Format for the READING and SETTING Properties 1.2.1.1 Input Data Length - The IDL field in the flag byte is used to determine the number of bytes of input data. This quantity should be the same as the default data return length used by the selective data acquisition system. This is not a coded field though only three discrete values should ever appear in it; zero, one, or two. 1.2.1.2 The Primary Transform - The READING and SETTING PDB's contain information which describe the necessary processing to convert unprocessed data to the primary units of measure such as volts, clock ticks, ohms, etc. This is called the primary transform and is specified by the primary transform index which is an even-valued one byte number. This index is used by ___________ the scaling routines to index a jump table to select the proper primary transform code for execution. Any required constants of conversion are implicit in the index (ie. not stored in the PDB but in the code). Transforms 0 through 12 and 16 assume integer data which is signed (two's complement) and left justified in the specified input field (length as specified by IDL). The other tansforms operate on unscaled data which is special in some way or other. Four characters of text describing the units of the result of the transform are also available in the PDB. This text is always left justified and space filled ASCII. At this time the following primary transforms are defined: Index Transformation _____ ______________ 0. X = FLOAT(input) / 3200. ! 10.24 VFS A/D's 2. X = FLOAT(input) / 3276.8 ! 10.00 VFS A/D's 1-3 DATA SCALING SERVICES _____________________ 4. X = FLOAT(input) / 6553.6 ! 5.00 VFS A/D's 6. X = FLOAT(input) / 13107.2 ! 2.50 VFS A/D's 8. X = FLOAT(input) + 32768. ! 091 CAMAC timers 10. X = FLOAT(input) --> all DEC ! null transform FLTD 12. X = FLOAT(input) / 320.0 ! temperature resistors 14. X = CAMAC 2323 data handler 16. X = IEEE-DEC floating format ! (standard) 18. X = FLOAT(input) * .001040625 ! temperature resistors 20. X = 8/16-bit unsigned data handler 22. X = input ! null transform 24. X = IEEE-DEC floating format ! (byte-swapped for 68000) 26. X = FLOAT(ABS(input/256))/82.1865-0.310269935 28. X = FLOAT(input) --> 68000 I*4 ! null transform FLTD 30. X = FLOAT(lo byte of word) ! signed byte 32. X = FLOAT(hi byte of word) ! signed byte 34. X = FLOAT(ABS(lo byte of word)) ! unsigned byte 36. X = FLOAT(ABS(hi byte of word)) ! unsigned byte 38. X = FLOAT(ABS(lo byte of word))/82.1865-0.310269935 40. X = FLOAT(input)/256.0 ! unsigned byte 42. X = 16-bit unsigned 0 to 10V DAC handler 44. X = 7-digit BCD input handler 46. X = FLOAT(input) ! unsigned longword 48. X = (IEEE FP -> dec fp) / 0.036 50. X = IEEE to DEC conversion ! clamped to -10.24 to 10.235 52. X = FLOAT(input) ! raw data is byte swapped 54. X = FLOAT(input) * 0.000488296 + 4.0 ! 4-20 mA PLCs 56. X = (FLOAT(input)-32768.0)/3276.8 ! unsigned word 58. X = FLOAT(unsigned input) / 256.0 60. X = (IEEE FP -> DEC FP) * 500.0 62. X = 16-bit unsigned 0 -> 10.24V DAC handler 64. X = FLOAT(input) ! scaled to +/- 1.0 66. X = FLOAT(input) / 3200.0 ! input > 0 68. X = (not scalable - for special display types only) 70. X = FLOAT(input) / 1000.0 72. X = (FLOAT(input)-32768.0)/3200.0 (unsigned 16 bit) 74. X = FLOAT(input) * 0.00064088 (0 - 21 mA A/B PLCs) 76. X = FLOAT(input) (word swapped unsigned 32 bit integer) 78. X = IEEE to native (clamped to 0.0 to 5.0) 80. X = IEEE to native (clamped to 0.0 to 10.0) 82. X = 12-bit unsigned 0 -> 10V handler 84. X = IEEE to native float (byte inverted) 1.2.1.3 Common Units Transform - The READING and SETTING PDB's contain information which allows the result of a primary transform to be further processed to a value expressed in terms of the Common Units of measure for the device of interest. Input data is always the floating point result of the associated primary transform. An even-valued byte called the Common ___________ Transformation Index obtained from the PDB is used to index a jump table which dispatches to the appropriate code. Each PDB contains a potentially unique set of common transformation constants which may be used by the specified transformation. (The data-base may actually take advantage of duplicate entries, where possible, in central disk storage and in the return of information to requestors.) The following common transforms are currently defined: Index Transformation _____ ______________ 1-4 DATA SCALING SERVICES _____________________ 0. X' = X 2. X' = (C1 * X / C2) + C3 4. X' = (X - C1) / C2 6. X' = C1 * X / C2 8. X' = C4 + (C1 * X) / (C3 + C2 * X) 10. X' = C3 + (C2 / (C1 * X)) 12. X' = C5+(C4*X)+(C3*X**2)+(C2*X**3)+(C1*X**4) 14. X' = EXP(C5+(C4*X)+(C3*X**2)+(C2*X**3)+(C1*X**4)) - C6 16. X' = C2 * EXP(-X/C1) + C4 * EXP(-X/C3) 18. X' = C3 * EXP(C2*(X+C1)) + C6 * EXP(C5*(X+C4)) 20. X' = LOG(X)/(C1*LOG(X)+C2)**2 + C3 22. X' = C2 * (10.0**(X/C1)) 24. X' = C2*(C3*X+C4) -or- C2*EXP(C5*X+C6) for X<>C1 26. X' = C6+(C5*X)+(C4*X**2)+(C3*X**3)+(C2*X**4)+(C1*X**5) 28. X' = C3/(C2+C1*X) + C4 30. X' = C5+(C4*X)+(C3*X**2)+(C2*X**3) -or- X'=C6 on XC1 44. X' = C2*EXP(C3*X) on XC1 46. X' = C2*EXP(C3*X**2+C4*X) on XC1 54. X' = EXP(C2*X**2+C3*X+C4) on XN2, 1->He) 66. X' = C1*(2.0^(C2*(X+C3)))+C4 68. X' = C6*(C2*LOGe(C1*X+C4)+C3*X)^C5 70. X' = C1*EXP(-X/C2)+C3*EXP(-X/C4)+C5*EXP(-X/C6)+4 72. X' = C1*10^(C2+C3*LOG10(X)+C4*LOG10(X)^2+C5*LOG10(X)^3)+C6 74. X' = (C1+C2*X+C3*X^2)/(C4+C5*X+C6*X^2) 76. X' = C2*X^C3 on XC2 or log interpolation 88. X' = (C1+C2*X+C3*X^2)/(1+C4*X+C5*X^2+C6*X^3) 90. X' = Table lookup (C1,X) where (C2