×

Subscribe to newsletter

subscribe to our weekly newsletter to get notified with latest story and article Subscribe now!




PLC BLOG | Mitsubishi | Mitsubishi FX Series Arithmetic Instructions: PLC Programming with ADD, SUB, MUL, DIV

Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


Mitsubishi FX Series Arithmetic Instructions: PLC Programming with ADD, SUB, MUL, DIV

arithmetic instructions perform mathematical operation and calculation on numerical data. Arithmetic Instructions are very useful in industrial control system. Mitsubishi fx series cpu have ability to perform mathematical instruction. for example if you have a program to calculate capacity of cylindrical water tank. To measure the capacity of the cylindrical water tank, you will need to do some simple calculations. your calculation is to multiply the area (A) of the round end by the height H. you can obtain height by level transmitter and formula for area is A= πxR2. where R is the radius of water tank which is fixed in our case. so volume of cylindrical water tank is area (A) x height (H), but the result in meter3. for capacity in liter multiply volume by 1000. so in this case you need multiplication instruction in your. you can use also assigned a konstant value in your Arithmetic Instructions by Using K and H. in this article only about instrunction we discuss flags of Arithmetic Instructions in next article.


Mitsubishi FX Series Addition Arithmetic Instructions

addition instruction is used to add two source numerical value and result stored in the destination value. numerical value may also constant value example k10, k45 etc. in Addition instruction have two Source S1 and S2 and a destination D where the result store. in Mitsubishi FX Series following are addition instruction which are categorized by numerical value type
  • ADD S1 S2 D : this instruction used for addition of 16 bit numerical value range for Add instruction is -32768 to 32767.
  • DADD S1 S2 D :this instruction used for addition of 32 bit numerical value range for DADD instruction is -2147483648 to 2147483647.
  • ADDP S1 S2 D: this instruction executed in pulse triggered mode, it's a 16 bit addition instruction
  • DADDP S1 S2 D: it's a 32 bit addition instruction work same as ADDP.
  • DEADD S1 S2 D: this instruction is used for adding floating point number. Fx1s and FX1N controller not support this function.

Mitsubishi FX Series Addition Arithmetic Instructions

above is the example of Mitsubishi FX Series Addition Arithmetic Instructions
  • in first rung simple add instruction which add D1 and D2 and store result to D3. when X001 is set to high than add instruction is executed.
  • in second rung constant value K10 and K20 is added and result is stored in d4. we know K used represent constant value.
  • in third rung is a example of DADD which add two double integer, for adding a double integer use proper source address. in this DADD instruction D9 and D13 is source value of double integer and d15 is destination for result.
  • in fourth and fifth rung is example of Pulse triggered addition ADDP, DADDP instruction value of this pulse triggered instruction add only for one program cycle or source value changed during program.
  • sixth rung is a example program of DEADD which add two floating number and store result to destination.
  • in seventh rung two value negative value is added and result is stored in destination d12. you can also use one negative value or both negative values.


Mitsubishi FX Series Subtraction Arithmetic Instructions

Subtraction instruction is used to subtract two source numerical value and result stored in the destination value. following is the subtraction instruction in Mitsubishi FX Series PLC
  • SUB S1 S2 D : this instruction used for Subtraction of 16 bit numerical value.
  • DSUB S1 S2 D :this instruction used for Subtraction of 32 bit numerical value.
  • SUBP S1 S2 D: this is a pulse triggered instruction for 16 bit numerical value
  • DSUBP S1 S2 D: this is a pulse triggered instruction for 32 bit numerical value.
  • DESUB S1 S2 D: this instruction is used for subtraction of floating point number. Fx1s and FX1N controller not support this function.

Mitsubishi FX Series Subtraction Arithmetic Instructions

above is the example of Mitsubishi FX Series Subtraction Instructions
  • in first rung simple Subtraction instruction this instruction is executed when X001 is set to high result of this instruction is stored in D3.
  • in second rung constant value K-10 and K20 is subtracted and result is stored in d3.
  • in third rung is a example of DSUB which subtract two double integer. D6 and D9 is source value for subtraction.
  • in fourth and fifth rung is example of Pulse triggered Subtraction SUBP, DSUBP instruction value of this pulse triggered instruction subtract only for one program cycle or source value changed during program.
  • sixth rung is a example program of DESUB which Subtract two floating number and store result to destination.


Mitsubishi FX Series Multiplication Arithmetic Instructions

Mitsubishi FX Series Multiplication Arithmetic Instructions use for multiplication of two source value S1 and S2 result of this instruction is stored in destination. Following are the available instruction in Mitsubishi Fx series plc
  • MUL S1 S2 D :Multiplication of 16 bit numerical value.
  • DMUL S1 S2 D :Multiplication of 32 bit numerical value.
  • MULP S1 S2 D: Pulse triggered Multiplication instruction for 16 bit numerical value
  • DMULP S1 S2 D: pulse triggered Multiplication instruction for 32 bit numerical value.
  • DEMUL S1 S2 D: Multiplication of floating point number. Fx1s and FX1N controller not support this function.

Mitsubishi FX Series Multiplication Arithmetic Instructions

above is the example of multiplication instruction
  • in first rung example of 16 bit multiplication instruction (MUL) where two source value D0 and D2multiply and stored to D60.
  • in second rung example of constant value multiplication with using K Operand K10 multiply with K20 so result is 200 which store in d3.
  • third rung is a example of double integer multiplication, in this example value D6 and D9 multiply and stored to d12.
  • fourth and fifth rung is pulse triggered multiplication instruction. Instruction executed in a program cycle.
  • fifth rung is the example of floating point multiplication instructions DEMUL. both real number is multiply and result of multiplication is also a floating value which store in d50.


Mitsubishi FX Series Division Arithmetic Instructions

Mitsubishi FX Series Division Arithmetic Instructions use to divide source value S1 to S2, result of this instruction is stored in destination D. Division instruction use for 16 bit, 32 bit and floating point value. Following are type of DIV instruction available in Mitsubishi. We know The formula for a division is Dividend ÷ Divisor = Quotient + Remainder so in Mitsubishi Division Instruction Quotient is store in destination data register and remainder is store next data address of data register. For 16 bit numerical value if data register D1 is Dividend, D2 is divisor, D3 is Quotient than data register D4 is remainder. for 32 bit numerical value if data register D1 is Dividend, D5 is Divisor so D8 is quotient than D9 also used as quotient and remainder store in D10 and D11.
  • for 16 bit instruction
  • DIV S1 S2 D :Division of 16 bit numerical value.
  • DDIV S1 S2 D :Division of 32 bit numerical value.
  • DIVP S1 S2 D: Pulse triggered Division instruction for 16 bit numerical value
  • DDIVP S1 S2 D: pulse triggered Division instruction for 32 bit numerical value.
  • DEDIV S1 S2 D: Division of floating point number. Fx1s and FX1N controller not support this function.
when source and Destination is zero and Division operation perform than this instruction set a error flag and our plc show error message. we discuss error flag details so avoid divide 0 to 0.

Mitsubishi FX Series Division Arithmetic Instructions

above is the example of Division instruction Mitsubishi Fx series plc.
  • in first rung is DIV instruction example D0 is Dividend and D2 is Divisor when X001 is set to high than operation is executed in our case 36 divide by 10 so we know Quotient is 3 and remainder is 6, but in our program only Quotient is display on instruction and remainder is store on next address of data register. so D60 store quotient and D61 store remainder.
  • in second rung is division of two constant value example
  • in third rung is double integer Division instruction in this instruction quotient is store in D12 and D13 and remainder is store in D14 and D15.
  • in fourth and fifth rung is pulsed triggered division instruction, this instruction is executed in every change of input bit.
  • in fifth rung is a proper division instruction where you see the real value of result. in our example when 123 is divide by 10 than result of this instruction show 12.3 this instruction is used for real value also.


Mitsubishi FX Series increment (INC) Arithmetic Instructions

Mitsubishi FX Series increment (INC) Arithmetic Instructions increment value by 1. in this instruction source value is incremented by a value of 1 On every execution of the instruction.
  • for 16 bit operation value when +32,767 is reached, the next increment will write a value of -32,768 to the destination device.
  • For 32 bit operation when +2,147,483,647 is reached the next increment will write a value of - 2,147,483,648 to the destination device.

Mitsubishi FX Series increment (INC) Arithmetic Instructions

Above is the example of Mitsubishi FX Series increment (INC) Arithmetic Instructions in this example when X001 is set to high than value D0 is incremented by value 1, when destination value is reached to +32767 than in next increment value of destination set to -32768 (lower range of 16 bit value.).


Mitsubishi FX Series decrement (DEC) Arithmetic Instructions

Mitsubishi FX Series decrement (DEC) Arithmetic Instructions Decrement source value by 1 and store result into destination. On every execution of the instruction the device specified as the destination D, has its current value decremented (decreased) by a value of 1. In 16 bit operation, when -32,768 is reached the Next increment will write a value of +32,767 to the destination device. In 32 bit operation, when -2,147,483,648 is reached the next increment will write a value of +2,147,483,647 to the destination device.

Mitsubishi FX Series decrement (DEC) Arithmetic Instructions

above is the example of Mitsubishi FX Series decrement (DEC) Arithmetic Instructions in this example when X001 is set to high than value D1 is decremented by value 1, when destination value is reached to -32767 than in next decrement value of destination set to +32768.


 
Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


Suggested Post


 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

comment