Learn PLC Data IO Mapping Through 3 Examples!

At the end of the article, there are practical case materials for core SCL programming.Introduction: When programming, we sometimes need IO mapping, such as data exchange during communication and program standardization! The mapping methods can use ladder diagrams and SCL, with SCL being more convenient and efficient.When using SCL, the PEEK and POKE instructions are required.Example 1. Control Requirement:Read the status value of M0.1 into M0_7 (M0.7)Learn PLC Data IO Mapping Through 3 Examples!Example 2.Control Requirement:Send the values of 14 I points starting from the address I0.0 of the CPU1214C body into each element of the 14 Bool array in DB1, corresponding as follows:Learn PLC Data IO Mapping Through 3 Examples!Figure 1

1. Create a new FB1 program block and define the interface variables.

Line 1 of the program is a FOR loop that runs a total of 14 times, then maps the data using the PEEK_BOOL instruction.

From the correspondence in Figure 1, a pattern can be observed: the array element index starts from 0 and increments by 1, while the corresponding I point input address bit variable cycles from 0 to 7, and the byte address starts with 8 zeros followed by 1. Thus, the summary is that the byte address is the quotient of the index divided by 8, and the bit address is the remainder of the index divided by 8. In programming terms, the byte address is index/8, and the bit address is index MOD 8. Then, a FOR loop can be used to quickly implement bitwise assignment.

Learn PLC Data IO Mapping Through 3 Examples!2. Create a new DB2 data block.Learn PLC Data IO Mapping Through 3 Examples!3. Call the FB program block.Learn PLC Data IO Mapping Through 3 Examples!4. Test.Learn PLC Data IO Mapping Through 3 Examples!

Example 3.Control Requirement: Send the first DBW0 of each DB block from DB3 to DB10 into MW104 to MW118.

1. Create a new FC1 program block.

Use the POKE_BLK instruction to implement the mapping of multiple data:

area_src := 16#84, which represents the DB data block.

dbNumber_src := #Temp + 1, where #Temp starts from 2, so the DB block number starts from 3.

byteOffset_src is the starting byte, which starts from byte 0.

area_dest := 16#83,16#83 represents the M storage area.

byteOffset_dest := 100 + #Temp * 2, // starting byte of the target area M.

count := 2, which represents 2 bytes each time.

Learn PLC Data IO Mapping Through 3 Examples!2. Test.Learn PLC Data IO Mapping Through 3 Examples!

Recently, many friends have requested case books, saying that reading articles on mobile phones is not very convenient. I have taken the time to organize all the practical cases of core SCL programming. The cases are quite typical and include SCL syntax structure, cylinder control programs, alarm programs, motion control programs, analog control of frequency converters, V90 servo communication, and other practical cases.If you need it, you can add me on WeChat.If you can’t add me, feel free to message me!

Learn PLC Data IO Mapping Through 3 Examples!Learn PLC Data IO Mapping Through 3 Examples!Learn PLC Data IO Mapping Through 3 Examples!

Previous Recommendations

[Programming Thinking Improvement] Techniques for Calculating Runtime of Multiple Devices

PLC Program Framework Initialization Program Writing!

PLC Programming Framework for Automatic Control Program Writing

How to Achieve Multi-language Switching on Touch Screens

Universal PLC Program Framework for Manual Control Program

Essential for PLC Engineers: 3 Efficient PLC Data Collection and Storage Methods!

Universal PLC Program Framework for Alarm Program Writing

Double Efficiency! Practical Application of Array Data Types in PLC

Common Pitfalls in FC Program Blocks: How Many Have You Encountered?

Can’t Adjust PID? This Guide Will Help You Solve Everything! Limited Time Only!!!

How to Implement Encryption Functionality on Siemens Touch Screens?

Using PLC Ladder Diagrams to Write State Machine Cases

[Programming Thought Improvement]: Programming Method for Random Start of 5 Motors

[Nanny-level Communication Case]: S7 Communication Between 1200 PLC and 200 SMART

What Does the Universal PLC Programming Framework Include, and How to Program It?

Core Points of PLC Automatic Control Programming!!!

6 Common Knowledge You Must Know to Learn 1200/1500 PLC Programming

Open Up PLC Programming Ideas and Improve Programming Thinking Through 3 Cases!

Nanny-level S7 Communication Case, Including Communication Fault Troubleshooting!!

Leave a Comment