2/2/2017 12:04 PM | |
Posts: 10 Rating: (0) |
Hi, Here is my exercise: I’ve written value “0D” in DB50 byte 0 (First tell me if I need to work with optimized blocks). Which means in binary “00001101”. I want to store the value of each bool in each time a different DB. Example: Write “1” in DB101 bool 0.0 Write “0” in DB102 bool 0.0 Write “1” in DB103 bool 0.0 Write “1” in DB104 bool 0.0 Etc Please tell me the exact syntax, what I need to aware of, how to declare the tags, do I need to work with indirect addressing,… Hope you’ll find me the way to solve this. ------------------------------------------------------------------------------------------ |
Last edited by: Min_Moderator at: 2/3/2017 3:15:44 PMNew subject after splitting |
|
2/3/2017 4:35 PM | |
Joined: 7/7/2010 Last visit: 11/11/2024 Posts: 15388 Rating: (2443)
|
Since you want to use indirect addressing to access the DB's by number (rather than symbolic addressing accessed by name), and because you are going to bit-mask write single bits into existing data, you may want to consider something like this (in SCL): 1. Read DB50 byte 0 as DB50.DBB0 (using absolute addressing), or as "db name"."tag at byte 0". 2. Store that byte to a tag of BYTE datatype. 3. PEEK into the DB for each of the 4 DBs at byte 0 (byte offset = 0). Store each byte to a temp tag (looping perhaps as an alternative method) or for educational purposes, one tag for each DB so you can see changes roll through in a watch table more easily. 4. Mask the bit you want to change using slice access as per prior post. This will allow you to set a single bit within the saved byte PEEK's in step 3 from each of the DBs being changed from DB50. 5. POKE the adjusted values to the appropriate DBs. Seem reasonable?
|
science guy |
|
Follow us on