CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 31
Текст из файла (страница 31)
“0001” isstored in DM 0001 when the input data is a negative value. The following systemconfiguration is used.Temperature Sensor UnitInputsIR 001IR 002OutputsNoneTemperature unit setting:Two-decimal-place Mode:Input range setting:Temperature input 0 storage word:OFF (°C)OFF (normal)1 (Pt100, –200.0 to 650.0°C)IR 001Programming with BCD(24) Instruction25313(Always ON Flag)CMP (20)Detects completion of input 0 initialization.001#7FFE0200002000ON when input 0 has been initializedExecution conditionCMP (20)002Detects an open-circuit alarm or Unit error by checking converted temperature data for the error code7FFF.#7FFF25506(=)0100025506(=)ON when an open-circuit alarm or Unit error has beendetected for input 0.00115BDC (24)001DM0000MOV (21)When the input temperature data is non-negative,converts the contents of IR 001 (temperature datafor input 0) to BCD and stores the result inDM 0000.Stores #0000 in DM 0001.#0000DM000100115CLC (41)SBB (51)#0000001DM0010BCD (24)DM0010When the input temperature data is negative, converts the contents of IR 001 to the absolute value ofthe actual temperature and stores the result inDM 0010.Converts the contents of DM 0010 (absolute valueof negative temperature data for input 0) to BCDand stores the result in DM 0000.DM0010MOV (21)#0001Stores #0001 in DM 0001 to indicate a negativenumber.DM0001189SectionTemperature Sensor UnitsProgramming with SCL2(––) Instruction (CPM2A/CPM2C Only)25313(Always ON Flag)Detects completion of initialization.CMP (20)001#7FFE25506(=)02000ON when initialization complete.02000 Execution conditionDetects an open-circuit alarm.CMP (20)001#7FFF25506(=)01000ON when an open-circuit alarm has been detected.25506(=)SCL2 (–)001Parameter settings for data conversion:DM0010DM0000DM0010#0000OffsetDM0011#0001∆X (Hex)DM0012#0001∆Y (BCD)25504(CY)When the converted value is non-negative,stores #0000 in DM 0001.MOV (21)#0000DM000125504(CY)When the converted value is negative, stores#0001 in DM 0001.MOV (21)#0001DM0001OperationBinary to BCD conversionIR 001 163 162 161 160DM 0000DM 00010001/0103 102 101 1001: Negative, 0: Non-negative0: If data non-negative, “0000” stored in DM 00011: If data negative, “0001” stored in DM 0001190CY (when using SCL2 instruction)1/03-2SectionTemperature Sensor Units3-23-2-8 Two-decimal-place ModeIf pin 2 on the DIP switch is turned ON, values are stored to two decimal places.In this case, temperature data is stored as 6-digit signed hexadecimal (binary)data with 4 digits in the integer portion and 2 digits after the decimal point.
Theactual data stored in memory is 100 times the actual value, i.e., the decimal pointis not indicated. Methods for handling this data are described in this section.Note When set to store values to two decimal places, temperature data as far as twodigits after the decimal point is converted to 6-digit binary data, but the actualresolution is not 0.01°C (°F). For this reason, there may be skipping and inaccuracies in the first digit after the decimal point (0.1). Treat any resolution abovethat specified for the normal data format as reference data.Data StructureThe structure of the data stored in memory is shown below. The value will be 100times the actual temperature.Leftmost 3 Digits and Flags15141312Leftmost/Rightmost FlagTemperatureUnit FlagOpen-circuitFlagNot used.0: Leftmost1: Rightmost0: °C1: °F0: Normal1: ErrorAlways 0Rightmost 3 Digits and Flags15141312Leftmost/Rightmost FlagTemperatureUnit FlagOpen-circuitFlagNot used.0: Leftmost1: Rightmost0: °C1: °F0: Normal1: ErrorAlways 0Temperature datax165x164x163Temperature datax162x161x160Leftmost/Rightmost Flag: Indicates whether the leftmost or rightmost 3 digits are provided.Temperature Unit Flag:Indicates whether the temperature is in °C or °F.Open-circuit Flag:Turns ON (1) when an open-circuit is detected.
The temperaturedata will be 7FF FFF if this flag is ON.191SectionTemperature Sensor UnitsData ConversionExamplesSome examples of the data stored for various temperature inputs are providedbelow.Example 1Temperature:1,130.25°C×100:113025Temperature Data: 01B981 (hexadecimal for 113025)Leftmost 3 Digits and FlagsBitsDataFlagsx165x164x16315 14 13 1208 to 1104 to 0700 to 0301B0000Normal°CLeftmost001BTemperaturedataFlagsRightmost 3 Digits and FlagsBitsDataFlagsx162x161x16015 14 13 1208 to 1104 to 0700 to 0398110008Normal°CRightmost981TemperaturedataFlagsExample 2Temperature:–100.12°C×100:–10012Temperature Data: FFD8E4 (hexadecimal for –10012)Leftmost 3 Digits and FlagsBitsDataFlagsx165x164x16315 14 13 1208 to 1104 to 0700 to 03FFD00000F F DNormal°CLeftmostTemperaturedataFlagsRightmost 3 Digits and FlagsBitsDataFlagsx162x161x16015 14 13 1208 to 1104 to 0700 to 038E41000Normal°CRightmost1923-28Flags8E 4TemperaturedataSectionTemperature Sensor Units3-2Example 3Temperature:–200.12°F×100:–20012Temperature Data: FFB1D4 (hexadecimal for –20012)Leftmost 3 Digits and FlagsBitsFlagsx165x164x16315 14 13 1208 to 1104 to 0700 to 03FFBData00004F F BNormal°FLeftmostTemperaturedataFlagsRightmost 3 Digits and FlagsBitsFlagsx162x161x16015 14 13 1208 to 1104 to 0700 to 031D4Data1000Normal°FRightmostC 1D 4TemperaturedataFlagsExample 4Temperature:Open circuit (°F)Temperature Data: 7FFFFFFFLeftmost 3 Digits and FlagsBitsFlagsx165x164x16315 14 13 1208 to 1104 to 0700 to 037FFData0110Error°FLeftmost6Flags7F FTemperaturedataRightmost 3 Digits and FlagsBitsDataFlagsx162x161x16015 14 13 1208 to 1104 to 0700 to 03FFF1110Error°FRightmostNoteE F F FFlagsTemperaturedata1.
Leftmost digits are stored in the lower memory addresses. Treat the data inthe lower memory address as the leftmost digits when programming.2. Be sure that the data is read at least once every 125 ms to allow for the CPUUnit’s cycle time and communications time. Correct data may not be obtained if the read cycle is greater than 125 ms.193SectionTemperature Sensor UnitsProgramming Example20-point CPU Unit3-2The following programming example shows how to use 2-decimal-place Modefor the following PC configuration.20-point ExpansionI/O UnitTemperature Sensor UnitTemperature unit setting:OFF (°C)InputsIR 000InputsIR 001InputsIR 002IR 003OutputsIR 010OutputsIR 011OutputsNoneTwo-decimal-place Mode:ON (2 digits after decimal point stored)In this example, 100 times the temperature data for temperature input 0 is storedin binary form in DM 0100 to DM 0102.Temperature input 0IR 002BitIR 200Leftmost dataRightmost data15 14 13 12 11 1098765431DM 0100x162x161x160DM 0101x167x166x165x164Always 0Always 0DM 0102Always 00Temperature Unit Flag (0: °C, 1: °F)Open-circuit Flag (0: Normal, 1: Error)The following program would be used.1942x16300SectionTemperature Sensor Units3-225315(First Scan Flag)(1)Sets DM 0103 and DM 0102 to#0100 and #0000, respectively.MOV (21)#0000DM0102MOV (21)#010025313(Always ON Flag)DM0103CMP (20)Detects completion of input 0 initialization.002#7FFE25506(=)0200002000ON when input 0 has been initialized.01000Open-circuit alarm output00213 (open-circuit detected)00215 (leftmost digits)02001SET 02001Ready for data conversion.MOV (21)(2)Leftmost digits moved to IR 20000215 (leftmost digits)00220000215 (rightmost digits)(3)MOVD (83)Leftmost and rightmost digitsrearranged and moved toIR 202 and IR 201.002#0020201(4)MOVD (83)200#0300201(5)MOVD (83)200#0011202RSET 02001RSET 02002Data rearrangement completed.195SectionTemperature Sensor Units3-200207 (non-negative data)02002BCDL (59)201DM010000207 (negative data)(6)If the temperature data is non-negative, thebinary data in IR 202 and IR 201 is convertedto BCD and placed in DM 0101 and DM 0100.CLC (41)(7)If the temperature data is negative, the 2’scomplement data in IR 202 and IR 201 isconverted to binary data representing theabsolute value of the temperature inputand placed in HR 01 and HR 00.SBB (51)DM0102201HR00SBB (51)DM0103202HR01BCDL (59)HR00DM0100MOVD (83)#0008(8)The binary data in HR 01 and HR 00 is converted to BCD and placed in DM 0101 andDM 0100.(9)“1” is written to the bit in DM 0101indicating negative data.#0300DM0101RSET 02002Note The BCDL(59) instruction is only available with the CPM2A and CPM2C.The data movements corresponding to the numbers in the above ladder programming example are illustrated in the following diagram.IR 002: Leftmost 3 digits of temperature data01650165164IR 002: Rightmost 3 digits of temperature data1631621161(2)IR 200164160(3)163(4)(5)IR 2020DM0101 0/8(1)DM0103–IR 202HR 010106 105 1041002’s complement data0164163161 1603DM0100 10102101 100IR 201(9)If temperature data is negative, “8” is written here(i.e., “1” is written to the bit indicating negative data).(1) #0000#01000165 1640165 164DM0102IR 20100002’s complement dataHR 00163162161 160(7)The 2’s complement data in IR 202 and IR 201 is subtracted, as binary data,from the data in DM 0103 and DM 0102 and placed in HR 01 and HR 00.196(6)If the temperature data is non-negative, thebinary data in IR 202 and IR 201 is convertedto BCD and placed in DM 0101 and DM 0100.(8)If the temperature data is negative, the binarydata in HR 01 and HR 00 is converted to BCDand placed in DM 0101 and DM 0100.SectionCompoBus/S I/O Link Units3-33-3CompoBus/S I/O Link UnitsThe CPM1A, CPM2A, or CPM2C PCs can function as Slaves to a CompoBus/SMaster Unit (or SRM1 CompoBus/S Master Control Unit) when a CompoBus/SI/O Link Unit is connected.