Manglemender
Member
Work always seems to get in the way of fun.
Write an FC that determines the following data for an array:
1.DBNumber where array is located
2.Area pointer of start address of the array
3.The size of the array in bytes
4.The size of an array element in bytes
5.The size of the array in elements
The FC will have two any pointer input parameters, the first points to the array, the second points to an element of the array. The FC will use an any pointer return value to point to a udt containing the determined data for the array as detailed above.
Example call and UDT shown below:
L #divider
L 8
<I
JC ZERO
L #divider
L 8
/I
T #tempArrayInfo.wSizeOfElementsInBytes
JU M001
ZERO: L 0
T #tempArrayInfo.wSizeOfElementsInBytes
M001: NOP 0
*** Could become... ***
L #divider
L 8
<I
JC ZERO
L #divider
L 8
/I
JU M001
ZERO: L 0
M001: T #tempArrayInfo.wSizeOfElementsInBytes
New task. Write an FB that will search all DB's in the plc for a given word. Report the DB number and Area pointer for the first occurrence of the word. Exclude the instance DB used for the FB from the search. Search the DB only on even byte addresses. If the word is not found, set the DB number to zero. A risng edge on bStart will start the search and clear bFinished. The search may take place over several scans of the FB. When the search is complete bFinished should be true.
L DBLG
+AR1 P#2.0
Hi!
I am desperately looking for some simple sample programs to learn Step7. Something like the manual of Working with Step7 (http://www.fer.unizg.hr/_download/repository/STEP7.pdf) but more advanced.
It can be some LAD or STL tasks, configuring HW, SCL and Graph language also!
Thank you very much for any help!
Miro
Expand and allow the user to specify the byte.bit of the Q that is to flash. Example shown will flash Q4.3
Compute the area address by combining the byte and bit addresses and then use indirect addressing to refer to the Q output. Here's an example using AR1
Here's my implementation. I checked 256 DBs per scan over 256 scans to check all possible 65535 DBs. I used SFC24 to determine if the DB existed before checking it. I used
to determine the length of the DB (in bytes) and as the comparison is a word, the loop count for comparisons is the db_length/2. I used theCode:L DBLG
to increment the index into the DB whilst searching. I used a separate FC for checking the DB for the pattern matchCode:+AR1 P#2.0
Your use of SFC20 is equally valid but extra code is required to generate the any pointer inside the loop - you could have used the SFC20 return value to identify when the DB did not exist or you ran off the end of the DB.
You could have fetched a word for the comparison instead of a byte at a time (that's why I specifed the search to be on even byte addresses).
I take it the L DBLG command gets the length of Instance DBs as well then? The help file says 'Loads the length of shared DBs'.?