Mitsubishi Electronics FX1S manual 14.4 Two’s Compliment, Inverted7 Additional1

Page 116

FX Series Programmable Controllers

Devices in Detail 4

4.14.4Two’s Compliment

Programmable controllers, computers etc, use a format called 2’s compliment. This is a mathematical procedure which is more suited to the micro processors operational hardware requirements. It is used to represent negative numbers and to perform subtraction operations. The procedure is very simple, in the following example “15 - 7” is going to be solved:

Step1: Find the binary values (this example uses 8 bits)

15

=

00001111

7

=

00000111

Step2: Find the inversion of the value to be subtracted.

Procedure: invert all 1ís to 0ís and all 0ís to 1’s.

7

=

00000111

Inverted 7

=

11111000

Step3: Add 1 to the inverted number.

Procedure: add 1 to the right hand most bit. Remember this is binary addition hence, when a value of 2 is obtained 1 is moved in to the next left hand position and the remainder is set to 0 (zero);

Inverted7 11111000

Additional1 00000001

Answer 11111001

This result is actually the same as the negative value for 7 i.e. -7.

Step4: Add the answer to the number the subtraction is being made from (i.e. 15).

Procedure: Remember 1+1 = 0 carry 1 in base 2 (binary).

Original value15

00001111

Answer found in step3

11111001

Solution

(1)00001000

The “(1)” is a carried “1” and is ignored as this example is only dealing with 8 bits.

Step 5: Convert the answer back. 00001000 = 8

The answer is positive because the MSB (the most left hand bit) is a 0 (zero). If a quick mental check is made of the problem it is indeed found that “15-7 = 8”.

In fact no subtraction has taken place. Each of the steps has either converted some data or performed an addition. Yet the answer is correct 15 - 7 is 8. This example calculation was based on 8 bit numbers but it will work equally well on any other quantity of bits.

4-42

Image 116
Contents Programming Manual Page FX Series Programmable Controllers ForewordFX Series Programmable Controllers FAX Back Combined Programming Manual J FX Series Programmable Controllers Hardware Warnings Software WarningsFX Series Programmable Controllers Contents STL Programming Applied Instructions Rotation And Shift Functions 30 to External FX Serial Devices Functions 80 to Execution Times And Instructional 10-1 Viii FX Series Programmable Controllers Chapter Contents Introduction OverviewWhat is a Programmable Controller? What do You Need to Program a PLC?Special considerations for programming equipment Current Generation CPU all versionsAssocciated Manuals Manual name Number FX Base Unit HardwareManual name Number FX DU, GOT and DM units Memo Basic Program Instructions FX Series Programmable ControllersBasic Program Instructions Detailed device information What is a Program?Outline of Basic Devices Used in Programming How to Read Ladder Logic ExampleProgram example Load, Load InverseOUT instruction Timer and Counter Variations OutDouble Coil Designation Use of dual coilsLast coil effect And, And Inverse Peripheral limitationsOr, Or Inverse ORILoad Pulse, Load Trailing Pulse Single Operation flags M2800 to M3071Pulse, And Trailing Pulse LDF ANF OUTOr Pulse, Or Trailing Pulse ORF ORBSequential processing limitations Or BlockBatch processing limitations Block ANB13 MPS, MRD and MPP MPS, MRD and MPP usageMultiple program examples Master Control and Reset MCRNested MC program example Set and Reset Resetting timers and counters16.1Basic Timers, Retentive Timers And Counters Timer, Counter Out & ResetRetentive timers Bit counters Availability of devicesNormal 32 bit Counters High Speed CountersPLF Leading and Trailing PulseInverse Usages for INVNo Operation No Operation20 End Program scanMemo STL Programming FX Series Programmable ControllersSTL Programming What is STL, SFC And IEC1131 Part 3? General noteLook Inside an STL How STL OperatesEach step is a program How To Start And End An STL Program Combined SFC Ladder representationEmbedded STL programs Activating new statesReturning to Standard Ladder Initial StepsTerminating an STL Program Using SET to drive an STL coil Moving Between STL StepsOut is used for distant jumps Using OUT to drive an STL coilOUT is used for loops and jumps Rules and Techniques For STL programs Basic Notes On The Behavior Of STL programsT001 K20 K50 Method 2 Special Single Pulse Flags Single Signal Step ControlMethod 1 Using locking devices Restrictions on using applied instructions Restrictions Of Some Instructions When Used With STLUsing ‘jump’ operations with STL Using STL To Select The Most Appropriate Program STL OUT SETUsing STL To Activate Multiple Flows Simultaneously Limits on the number of branchesLimits on the number of branches General Rules For Successful STL Branching Instruction FormatGeneral Precautions When Using The FX-PCS/AT-EE Software Programming Examples Simple STL FlowIdentification of normally closed contacts SET STLPoints to note Selective Branch/ First State Merge Example ProgramFull STL flow diagram/program Advanced STL Use Devices in Detail FX Series Programmable ControllersDevices in Detail Configuration details InputsAvailable devices Device MnemonicAlias O/P OutputsDevice Mnemonic Y General Stable State Auxiliary Relays Auxiliary RelaysDevice Mnemonic M Battery Backed/ Latched Auxiliary Relays External loadsSpecial Diagnostic Auxiliary Relays Special Single Operation Pulse RelaysGeneral Stable State State Relays State RelaysDevice Mnemonic S Battery Backed/ Latched State Relays PLC FX 1S FX 1N FX 2NAssigned states Monitoring STL programsSTL/SFC programming IST instructionAnnunciator Flags Pointers Jumping to the end of the programDevice availability Device Mnemonic PInterrupt Pointers Additional applied instructionsNested levels Pointer positionInput Interrupts Timer InterruptsRules of use Driving special auxiliary relays Disabling high speed counter interruptsAdditional notes Disabling Individual InterruptsConstant K Constant HDevice Mnemonic K Example device usage N/ADevice Mnemonic T TimersTimer accuracy Driving special auxiliary coils General timer operationSelectable Timers Using timers in interrupt or ‘CALL’ subroutines Retentive TimersInternal timer accuracy Timers Used in Interrupt and ‘CALL’ SubroutinesTimer Accuracy ConditionSetting ranges for counters CountersHigh speed counters Device Mnemonic CBattery backed/latched counters General/ Latched 16bit UP CountersGeneral/ Latched 32bit Bi-directional Counters Battery backed/ latched countersSelecting the counting direction Basic high speed counter operation Further uses NoneDriving high speed counter coils Basic High Speed Counter OperationAvailability of High Speed Counters Input assignmentCounter Speeds Calculating the maximum combined counting speed on FX1S Device specification Setting rangeDirection setting Using the SPD instructionRST 11.5 2 Phase Bi-directional Counters C246 to C250 Device size11.6 A/B Phase Counters C252 to C255 Example device usage None Data RegistersDevice Mnemonic D General Use Registers Data register updatesData retention Using the FX2-40AW/AP Use of diagnostic registersBattery Backed/ Latched Registers Special Diagnostic RegistersSpecial caution when using FX1S Writing to file registersFile Registers Program memory registersExternally Adjusted Registers UsesIndex Registers Use of Modifiers with Applied Instruction ParametersDevice Mnemonic V,Z Available formsMisuse of the Modifiers Using Multiple Index RegistersModifying a Constant Bits, Words, BCD and Hexadecimal Bit Devices, Individual and GroupedAssigning grouped bit devices Moving grouped bit devicesAssigning I/O Word Devices Interpreting Word DataFX Series Programmable Controllers Binary Coded Decimal value= Error Word Data Summary14.4 Two’s Compliment Inverted7 Additional1Floating Point And Scientific Notation Some useful constantsScientific Notation Floating Point Format FLT