Siemens PLC Learning note 13-(Arithmetic operation instruction and control instruction)

Source: Internet
Author: User

Today, writing a study note of the PLC, this article will introduce the most basic operation of the PLC and control instructions, this article will be directly on.

1. Basic Arithmetic Operation instruction

1) Integer arithmetic


2) Long integer operation


3) Real arithmetic


STL Programming Example (arithmetic operations for 16-bit integers)

liw10//the input word IW10 load accumulator 1 Low word lmw12//the accumulator 1 low word loaded into the low word accumulator 2//The storage word MW12 loaded accumulator 1 Low word +i//the accumulator 2 low word and accumulator 1 Low word added, the result is saved to the low word of accumulator 1 +68// Adding the contents of the low word of the accumulator 1 to the constant 68, the result is saved to the low character of the accumulator 1 tdb1.dbw25//the contents of the accumulator low word (the result) to the DBW25 of the DB1.
2. Extended Operation Instructions

3. Program Control Instructions

1) Jump Instruction

The jump instruction interrupts the order of execution of the original program and jumps to the execution code at the destination address. The general target address is specified by the label after the jump instruction, you can jump forward or jump backwards, the maximum jump distance is 32768 to 32767 words.

Jump instruction is divided into: unconditional jump instruction, multi-branch jump instruction, conditional jump command

A) unconditional jump instruction

Unconditional jump instruction, label Ju. When it executes, it interrupts the current program directly and jumps to the target specified at the end of the label.


Example: (Jumps to L1 when a program executes to a jump command)


b) Multi-branch Jump Instruction

The multi-branch jump instruction format is as follows:

JL < marking >

If the low-byte content in the accumulator 1 low is less than the number of the Ju instruction between the JL instruction and the label specified by the JL instruction, the JL instruction jumps to one of the Ju locations and is further redirected to the destination address by the Ju command, if the low-byte content of the accumulator 1 low is 0, The first JU directive under the JL instruction is executed directly, and if the low byte content of the accumulator 1 Low is 1, the second Ju instruction under the JL instruction is executed directly; if the number of destinations to jump is too large, the JL instruction jumps to the first instruction after the last Ju instruction in the destination list.

Example:

lmb0//jumps the destination address designator into the low byte of the accumulator 1 low jllstx//if the contents of the low byte of the accumulator 1 low are greater than 3, then jumps to lstxjuseg0//if the contents of the low byte of the accumulator 1 low are equal to 0, then jumps to seg0juseg1// If the contents of the low byte of the accumulator 1 low are equal to 1, then jumps to seg1juseg2//if the contents of the low byte of the accumulator 1 low are equal to 2, then jumps to seg2juseg3//if the contents of the low byte of the accumulator 1 low are equal to 3, Then jump to seg3lstx:jucomm//jump out of the seg0:...//program segment 1jucomm//jump out of the seg1:...//program segment 2jucomm//jump out of seg2:...//program segment 3jucomm//jump out seg3:...// Program Section 4jucomm//jump out of comm:...//program exit

2) Conditional Jump instruction

(JC uses the most)


Example: (When I0.0, I0.1 are 1 o'clock, jump to L2, otherwise jump to L1 execution)



4. Subroutine Call instruction


Above is the STL directive, in the ladder diagram, the corresponding icon is dragged into the editing area.




Siemens PLC Learning note 13-(Arithmetic operation instruction and control instruction)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.