|
The example function will retrieve a BCD number from the D type (BCD) memory and convert it to a floating point number that will be stored in F8:2. The other function will convert from 2s compliment binary to BCD, and between radians and degrees.
A
FRD Source A D10:5 Dest. F8:2
TOD(value,destination) -convert from BCD to binary
FRD(value,destination) -convert from binary to BCD
DEG(value,destination) -convert from radians to degrees
RAD(value,destination) -convert from degrees to radians
Figure 15.9 Conversion Functions
Examples of the conversion functions are given in Figure 15.10. The functions load in a source value, do the conversion, and store the results. The TOD conversion to BCD could result in an overflow error.
plc basic functions -15.11
Addr. Before after
N7:0 0 1793
N7:1 548 548
F8:0 3.141 3.141
F8:1 45 45
F8:2 0 180
F8:3 0 0.785
these are shown in
D9:0 0000 0000 0000 0000 0000 0101 0100 1000 binary BCD form
D9:1 0001 0111 1001 0011 0001 0111 1001 0011
Figure 15.10 Conversion Example
15.2.4 Array Data Functions
Arrays allow us to store multiple data values. In a PLC this will be a sequential series of numbers in integer, floating point, or other memory. For example, assume we are measuring and storing the weight of a bag of chips in floating point memory starting at #F8:20 (Note the ’#’ for a data file). BACK | NEXT Easy Access To All Pages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|