Using Indirect Addressing in TIA for Words and Double Words

Question:

One example of what I need is an output word like QW125. However, I may change the number 125 to something else, such as QW(P), where P=127. Then I can use QW127 in my program. I have looked into Peek and Poke, but they only work with bytes at the most. I require something similar to work with words and double words.

Top Replies

Do you have a CPU with a 1500 series? In that case, consider developing your own POKE_WORD/DWORD functions by utilizing the STL library. Unleash the power of your CPU with custom memory manipulation functions.

Although I have not utilized them extensively, pointers are available as well.

While pointers can be a powerful tool, I have not had much experience using them. However, it is important to note that improper use of pointers can lead to serious consequences, akin to pointing a loaded shotgun at your own feet, placing your finger on the trigger, and speeding down a rough dirt path. It's crucial to handle pointers with caution to avoid potential pitfalls.

When setting up a communication protocol like 1200/1500, it's important to consider how to efficiently address and access data in your program. One effective method I use is defining a User Defined Type (UDT) with an array that can be accessed indirectly, then assigning it to the initial IO address. This allows for easy access to the data in the system using standard array notation: tagname.array[indexno]. To ensure smooth operation, it's crucial to map the IO addresses correctly.

Looking at your requirement, it seems like you're trying to manipulate strings rather than deal with memory addresses, as Peek and Poke are designed for. Consider using string formatting functions or concatenation for achieving this. If, for example, you're working in Python, you could use something like `QW{}`.format(P) where P is the number you want to substitute. This would allow you to change the number as needed without resorting to low-level memory operations.

You may want to look into using bitwise operators in your program. They allow you to manipulate data at the bit level which can be helpful when working with words and double words. Consider using bitwise AND (`&`), OR (`|`), XOR (`^`) and NOT (`~`) to modify your bit patterns based on your requirements. Concatenation of bit patterns could come in handy for creating values such as QW127. This will give you the flexibility you need, much more than what Peek and Poke can offer.

Have you considered using arrays or structs to create a custom data type that allows you to easily define and manipulate word or double word outputs? This way, you can implement a method where the prefix remains constant (like 'QW') and you can dynamically insert the numerical value based on your needs, avoiding the limitations of Peek and Poke. It could also be a cleaner solution and make your code more maintainable!

It sounds like you're diving into a bit of low-level programming! If you need to handle larger data types like words and double words, have you considered using pointers or structs in your programming language? This way, you can manipulate larger data without being restricted to just bytes. You could define a structure to hold your values and then reference them with meaningful names, making it easier to work with variables like QW(P). Also, if you're using a language like C or C++, the union feature might be helpful as it allows you to access the same memory location in different ways, which could suit your needs perfectly.

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: FAQs:

Answer: 1. How can I use indirect addressing in TIA for words and double words? - To use indirect addressing for words and double words in TIA, you can assign a variable to represent the memory address you want to access. For example, you can use a variable like P to represent the memory address 127, and then access the word or double word stored at that address using the variable.

FAQ: 2. Can I work with words and double words using Peek and Poke in TIA?

Answer: - Peek and Poke instructions in TIA are designed to work with bytes at the most, so they may not be suitable for accessing words and double words directly. You may need to use indirect addressing with variables to access words and double words in your program.

FAQ: 3. How can I dynamically change the memory address for output words in TIA?

Answer: - You can dynamically change the memory address for output words in TIA by using variables and indirect addressing. By assigning a variable to represent the memory address you want to access, you can easily change the address at runtime without modifying your program logic.

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  â†’