How to use indirect addressing in Siemens Step 7 ladder logic for dynamic bit position changes

Question:

How can I implement indirect addressing in ladder logic using Siemens Step 7? For instance, with a DB of 1000 bits, I'd like to dynamically change the bit position using a register. Is it possible to achieve something similar to AB SLC 500's functionality? This feature worked well for my previous application. Thank you!

Top Replies

The Siemens S7 doesn't support idirect addressing in ladder logic programming. The recommended alternative is using SCL (Structured Control Language). If you prefer to stick with ladder logic, you may need to create your custom solution for addressing in the Siemens S7 programming environment.

When it comes to programming, the distinction between STL (statement list) and SCL (Structured Control Language) is important. While both allow for indirect addressing, not all users may have access to the SCL option package. According to the renowned author Hans Berger in his book "Programming in STL and LAD," indirect addressing in LAD is possible to a limited extent with SFC20 BLKMOV. If you do not have this book yet, consider getting it as it offers valuable insights. Be prepared for a challenging learning process, though. Indirect addressing in Allen Bradley (AB) systems is clear-cut, while in Siemens S7 systems, it is not as straightforward.

Utilize address registers and pointers for indexed or indirect addressing, which can be done in SCL (Optional package) or STL (Built in). In STL, the process involves the following steps: - OPN #DB to specify the DB being used - Load address register 1 with a pointer in the open DB using LAR1 P#DBX0.0 - Save the address base into a DWORD for future reference with TAR1 #BaseAdrPointer - Index into the desired word of the DB using L #Curr_Idx, bearing in mind to multiply by 4 if dealing with Dwords or Reals - Shift the offset left 3 places with SLD 3 to create a pointer - Add the calculated value to AR1 by loading AR1 with the base pointer and adding the two with +AR1 - Transfer the test value to the indexed offset in the data block with L #Test_ValT D [AR1,P#0.0] By incorporating checks and loops on Curr_Idx, you can populate a DB with common values like DWords or Reals. While it may not be intuitive initially, persistence will lead to a better understanding. Good luck optimizing your programming skills!

I recommended using SCL for its ease of learning. However, some may find it to be less powerful and somewhat weak compared to other options. Personally, I'm not a big fan of the S7.

Dear visitor, although you may not currently have the time to dedicate to it, in the future, you should definitely explore the benefits of incorporating symbolic priority programming into your projects. By utilizing this method, you can effectively reference various elements in your data blocks using their actual names. Personally, I prefer utilizing the STL for this purpose, but symbolic priority programming can also be successfully implemented in ladder logic. Recently, I completed a major project using this approach, which significantly reduced the need for pointer calculations while enabling me to incorporate generic functions seamlessly throughout the code.

Absolutely! In Siemens Step 7, you can achieve indirect addressing using pointers and the "L" (Load) instruction for accessing data in your data blocks (DB). You'd typically use a data pointer (for example, a byte or word datatype) to dynamically change the address you're accessing. By calculating the offset based on your register value, you can point to the specific bits within your 1000-bit DB, similar to the way AB SLC 500 does it. Just make sure your index register is within bounds to avoid runtime errors. If you need more details on the specific instructions to use, let me know!

Absolutely, you can implement indirect addressing in Siemens Step 7 using pointers to access the data blocks (DB). To achieve dynamic bit manipulation, you can use the `P#` format to define your pointer and then utilize a combination of arithmetic operations to adjust the pointer based on your register. You can read or write to these bit positions indirectly through the pointer to your DB. Just ensure your data types match up and you're managing the pointers correctly to avoid any runtime errors. It's definitely more flexible compared to what older systems might offer. If you run into any specific issues, share the code snippets; the community can help troubleshoot!

More Replies →

Streamline Your Asset Management
See How Oxmaint Works!!

✅   Work Order Management

✅   Asset Tracking

✅   Preventive Maintenance

✅   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

To add a comment, please sign in or register if you haven't already..   

Frequently Asked Questions (FAQ)

FAQ: 1. How can I implement indirect addressing in Siemens Step 7 ladder logic?

Answer: - To implement indirect addressing in Siemens Step 7 ladder logic, you can use a combination of data blocks and registers to dynamically access memory locations based on the value stored in the register.

FAQ: 2. Can I dynamically change the bit position in a DB of 1000 bits using indirect addressing in Siemens Step 7?

Answer: - Yes, you can dynamically change the bit position in a DB of 1000 bits by utilizing indirect addressing with registers to access different bit positions based on the register value.

FAQ: 3. Is it possible to achieve functionality similar to AB SLC 500's indirect addressing in Siemens Step 7 ladder logic?

Answer: - While Siemens Step 7 and AB SLC 500 may have differences in their programming methods, you can achieve similar functionality in Siemens Step 7 by effectively utilizing indirect addressing techniques with registers and data blocks.

FAQ: 4. How can I adapt the indirect addressing feature for dynamic bit position changes in Siemens Step 7 if it worked well in my previous application with AB SLC 500?

Answer: - To adapt the indirect addressing feature for dynamic bit position changes in Siemens Step 7, you can leverage the flexibility of registers and data blocks to achieve the desired functionality similar to what you had with AB SLC 500 in your previous application.

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  â†’