Jump to content

Recommended Posts

Posted
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]

Posted (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 by JesperMP
Posted
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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...