Rod_Hackney Posted July 23, 2007 Report Posted July 23, 2007 I have a S7-312 processor and have an application that needs to index through and convert 40 DINT's to S5Time format. I have used FC 40 and using the pointer register to read and write to the FC block in the code below. But I need to be able to increment through the the memory words to process all 40 entries. I am new to S7 any suggestions appreciated. L P#0.0 T MD 0 L P# 160.0 T MD 4 L DBD [MD 0] T MD 12 Call FC 40 IN :=MD12 RET_VAL :=MW14 L MW 14 T DBW [MD 4]
JesperMP Posted July 23, 2007 Report Posted July 23, 2007 (edited) Hi Rod, Take at the look at the LOOP instruction: L 40 // load 40 cycles thru the loop _NXT: T MW10 // MW10 is the loop counter L P#0.0 T MD 0 L P# 160.0 T MD 4 L DBD [MD 0] T MD 12 Call FC 40 IN :=MD12 RET_VAL :=MW14 L MW 14 T DBW [MD 4] L MD 0 // step 1 word forward L L#16 +D T MD 0 L MD 4 // step 1 word forward L L#16 +D T MD 4 L MW10 // load the loop counter LOOP: _NXT // decrement loop counter and jump back to _NXT Edited July 23, 2007 by JesperMP
Rod_Hackney Posted July 23, 2007 Author Report Posted July 23, 2007 Thanks for your reply. Iwill give it a try.
JesperMP Posted July 23, 2007 Report Posted July 23, 2007 I just notice that despite you said that the data is in S5T format (size = 1 word), you are passing the value at one step to MD12. 1st I dont get why you dont pass it to a word. 2nd there is possibly a problem with MD12 overlapping with MW14 (MD12 = MW12 + MW14). Maybe it is not a problem because later the RETVAL writes to MW14, but it definitely confuses everything. If I were you I would tidy it up so there are no overlapping adresses.
Rod_Hackney Posted July 24, 2007 Author Report Posted July 24, 2007 I did end up change the above mentioned addresses in the final program. Thanks for your assistance
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now