Assigning an ARRAY of an UDT DATALIST (S7)

JesperMP said:
Yes, it is correct, BLKMOV can be used that way. I just made a test, and you can indeed have overlapping memory areas, reagrdles of what the help text says.

But you have to address that pointer the hard way. Not a big deal, but I think that in the code that I posted you can see immediately what is happening, and it automatically updates because it is 99% symbolical. A pointer does not offer that. I guess some well placed comments could counter this problem.

Box the sfc20 call in a FC. Add 2 any pointers as in parameters one pointing to the complete length of all entries and one pointing to one entry. Then you can change the datablock as you please and the symbols will automatically update.
 
I understand that. There are a many many roads to Rome.
Your suggestion adds some extra code and means that the pointer will be generated at runtime. Whatever the solution will be, it is a compromise of programming style, complexity, program size and efficiency.
 
JesperMP said:
I understand that. There are a many many roads to Rome.
Your suggestion adds some extra code and means that the pointer will be generated at runtime. Whatever the solution will be, it is a compromise of programming style, complexity, program size and efficiency.


I already made a solution in STL with dynamically generated pointers that works but I understand that Combo wants to do it in SCL. I'm interested to see the resulting code in SCL as it's a language that I need to learn more about. In particular, I would like to know which solution provides the most efficient routine at runtime.

Nick
 
heyhey

I could have done it in stl, with your example, but I feel more free in SCL, even if I'm not such a good programmer in SCL, I just try :)

If you run the code in PLCSIM and WInCC Flex 2007 in simuation runtime, then you can test it, It works.

When you need more then 12 batches or there comes a new parameter, then my code will be a desaster to change, but, it doesn't need to change, I'm sure.



Manglemender said:
I already made a solution in STL with dynamically generated pointers that works but I understand that Combo wants to do it in SCL. I'm interested to see the resulting code in SCL as it's a language that I need to learn more about. In particular, I would like to know which solution provides the most efficient routine at runtime.

Nick
 
Hi Combo,

You should get used the idea of using symbol priority in your S7 projects. Right click on Blocks and select properties; on the addressing tab, select symolic priority. This has many advantages. If you wanted to add an element to your UDT for example; after updating the UDT, right click on blocks and select "Check Block Consistency", select the option to recompile everything and that's it done! This works because the ANY pointers used are either symbolic or dynamically generated from a symbolic reference (this was the reason that I changed your DB from an Array to multiple copies of the UDT). The code that I wrote will work just the same with 50 entries or 500 becuase it runs in a loop and calculates pointers dynamically.

I look forward to seeing the working code in SCL, I hope to learn from it.

Nick
 
hmm

You can download it here: https://www.yousendit.com/download/Q01HRGwxUnJFd2RFQlE9PQ


Manglemender said:
Hi Combo,

You should get used the idea of using symbol priority in your S7 projects. Right click on Blocks and select properties; on the addressing tab, select symolic priority. This has many advantages. If you wanted to add an element to your UDT for example; after updating the UDT, right click on blocks and select "Check Block Consistency", select the option to recompile everything and that's it done! This works because the ANY pointers used are either symbolic or dynamically generated from a symbolic reference (this was the reason that I changed your DB from an Array to multiple copies of the UDT). The code that I wrote will work just the same with 50 entries or 500 becuase it runs in a loop and calculates pointers dynamically.

I look forward to seeing the working code in SCL, I hope to learn from it.

Nick
 
manglemender said:
I already made a solution in STL with dynamically generated pointers that works but I understand that Combo wants to do it in SCL. I'm interested to see the resulting code in SCL as it's a language that I need to learn more about. In particular, I would like to know which solution provides the most efficient routine at runtime.
I too would be interested in seeing the differences. If I have the time I would even offer to try and run the code on a PLC and see the real difference. It could be a nice topic for the downloads section.
We would have to write an exact requirement spec for the test to make comparable code.
As I see it we have these variants:
SCL code with directly adressed variables (JesperMP).
SCL code with adresses passed as parameters (Combo).
STL code with dynamically calculated adresses (manglemender).
Using BLKMOV wherever possible.
Using BLKMOV wherever possible with dynamically calculated parameters (Bratt).

Combo said:
https://www.yousendit.com/download/Q01HRGwxUnJFd2RFQlE9PQ
OKAY,
I'M TRYING WITH THE LITTLE SCL KNOWLEDGE I HAVE, EVEN IF IT IS NASTY..
IF YOU GUYS HAVE THE TIME, CHECK IT OUT...
I THINK I'M CLOSE TO MY GOAL
You have to test it to see if it works. I wont do the test for you.
I dont like that you have a structure in one large ARRAY block of DINTs. I would create an ARRAY of UDTs, or an ARRAY of STRUCTs like I proposed earlier. And I would add a lot more comments to tell what you do and possibly why you do it. Both of these suggestions are only to make the code more maintainable.
 
JesperMP said:
As I see it we have these variants:
SCL code with directly adressed variables (JesperMP).
SCL code with adresses passed as parameters (Combo).
STL code with dynamically calculated adresses (manglemender).
Using BLKMOV wherever possible.
Using BLKMOV wherever possible with dynamically calculated parameters (Bratt).

The code that I wrote uses BLKMOV with dynamically calculated ANY pointers as per Bratt suggestion but i could easilly re-write it without the use of SFC 20 to see which executes faster.

The time consuming part must be the ripple up when a record is removed from the job list. We could write some code to do this mybe 500 times and measure how long it takes for each method?

We have an old 315-2DP in the office that we use when a real PLC is required rather than a simulator.

Nick
 
hey

Well, it works

About UDT's or Struct's, I agree and I will test it,

I needed something that worked for tomorow on the meeting with the customer.

I didn't succeed in using UDT's in SCL, that's why I fastly wrote something out in stl with constant values.


But I will retry it with UDT's

JesperMP said:
I too would be interested in seeing the differences. If I have the time I would even offer to try and run the code on a PLC and see the real difference. It could be a nice topic for the downloads section.
We would have to write an exact requirement spec for the test to make comparable code.
As I see it we have these variants:
SCL code with directly adressed variables (JesperMP).
SCL code with adresses passed as parameters (Combo).
STL code with dynamically calculated adresses (manglemender).
Using BLKMOV wherever possible.
Using BLKMOV wherever possible with dynamically calculated parameters (Bratt).


You have to test it to see if it works. I wont do the test for you.
I dont like that you have a structure in one large ARRAY block of DINTs. I would create an ARRAY of UDTs, or an ARRAY of STRUCTs like I proposed earlier. And I would add a lot more comments to tell what you do and possibly why you do it. Both of these suggestions are only to make the code more maintainable.
 
JesperMP said:
But you have to address that pointer the hard way. Not a big deal, but I think that in the code that I posted you can see immediately what is happening, and it automatically updates because it is 99% symbolical. A pointer does not offer that. I guess some well placed comments could counter this problem.

I just used absolute pointer addressing in the example I posted to show that overlapping is possible. In real life, I use symbolic priority and all pointers are displayed as such, and also update automatically when the structure or udt changes. I never have to touch the code.

I can see the advantage to SCL, but it really isn't that far removed from STL. I think what makes it appear much simpler is that the STL equivelent to SCL is very strange looking. Just as the ladder editor inserts all of the extra instructions into the STL to let it be represented graphically, SCL does the same thing.
 
S7Guy said:
I just used absolute pointer addressing in the example I posted to show that overlapping is possible. In real life, I use symbolic priority and all pointers are displayed as such, and also update automatically when the structure or udt changes. I never have to touch the code.
Will that work with the example you posted ?
You copy from part of a defined structure to another part of the same defined structure. And thats the problem because you can pass a complete structure symbolically, not part of it.

You can pass for example
"MyList".MyArray to "MyList".YourArray
"MyList".MyArray[10] to "MyList".MyArray[12]
"MyList".MyArray[10].Number1 to "MyList".MyArray[12].Number2

But you cannot pass for example
From "MyList".MyArray[2..12] to "MyList".MyArray[1..11]

If it is possible I would like to know how.
 
Last edited:
Now I see where you're going with this. No, you cannot display it as such symbolically exactly how you describe. In a case like that, I would have to build the pointer dynamically. Typically, I would use a udt that represents a pointer, and determine everything except for bytes 7-9 during startup. Then, it's just a matter of using the instance to calculate the bit address at runtime. If you look at the SCL in STL representation, it pretty much does the same thing, except that the entire pointer is calculated at runtime.

Like I said, I have nothing agaiinst SCL at all. I probably should sit down with it someday and convert an old project over and run some benchmark tests. My assumption would be that STL would be much faster, but with many applications that wouldn't matter.
 
Hey guys

I went to the customer and...

this is the conclusion:

now I showed an example with 12 batches. My screen in WINCC FLEX has 12 fields where I can show bathes in the list.


okay:

what they want is: more parameters like type, thickness, etc...

That is not a real problem todo, it changes the calculation a bit, that's all...


But, they want the possibillity of 200 batches...

If I have 10 parameters, then that's 2000 DINT in 1 DB, is that possible... ?


And how shoould I show this, make screens with 20 fields / screen ?
 

Similar Topics

I can't seem to figure out how to add descriptors to I/O points on an RMC using PCCU. Say, for example, I want to use "Valve_1" as a descriptor...
Replies
0
Views
76
Hello all. A little ashamed of myself that I can't remember how to do this but..... I have a 1734-AENT that I set the wheels to "888" applied...
Replies
9
Views
4,112
Hey everyone I'm working on a PLC project for a series of 4 vacuum pumps. I need to be able to rotate each pump into a different priority based on...
Replies
18
Views
6,481
Hi all, I am in the throes of commissioning a single S7-1517 cpu and I'm utilising both ethernet ports, X1 and X2, with individual IP addresses...
Replies
2
Views
1,728
With FactoryTalk ME is it possible to use a single Trend object and list of pens being displayed using macros? Would like to have one Trend object...
Replies
2
Views
1,773
Back
Top Bottom