Size of Data in SCL STL

erdemsvri

Member
Join Date
Jul 2009
Location
Germany
Posts
172
Hello

I want to write a stack function.
And I want to cast the input and output data type to any so I wont think about data type using stack function.

Is there anyway or function which can return number of the bytes or bits of the input data of type any for this stack?

Thanks...
4ktudv.png
 
What do you mean with Stack ??
And do you just want to know the numbers of bytes from the in to the output?
 
When I say Stack I mean FIFO.

I just want to know when a new data is added to fifo or stack I want to learn the size of that input data so I will increment stack pointer...
 
I have never heard of any pointers before. How are they implemented? Can you give an example?

I was thinking to do the stack by specify two arrays

one will hold the data and the other one will hold the bytes of data like

array1 of bytes will go like: real word real byte word
array2 will be like: 4 2 4 1 2 and so on
and a flag will hold how much data is written flag = 5;

so when a push a int:
flag will be 6 and the second array will be 2 4 2 4 1 2

How will I implement that stack with anypointers?
 
I assumed you are using Siemens S7 3xx PLCs

ANY pointers are Siemens' implementation of adding a type to a pointer. The ANY pointer is 10 bytes long and has a structure like this

byte n 16#10
byte n+1 Type
word n+2 number
word n+4 DB number
dword n+6 Area pointer

Go to the on-line help and search for ANY in the index. There is a good description there. The tricky part is pointing to arrays of UDTs. The ANY pointer is just of type byte and the total number of bytes. Some people get tricky and pass only a pointer to the first UDT so the number of bytes is the UDT size but then you don't know how many UDTs there are in the array. However, I don't think this will be a problem in a stack based application since I doubt you will want to pass pointers to whole arrays of UDTs on a stack.

Using the stack of ANY pointers will make all your stack elements 10 bytes long and make stack management easiser but a lot of code/functions will be required to do make all the stack PUSH and POP routines for different data types. It will not be efficient but it should be clean once you get it done.

This is interesting. I can understand why you want to do this.
 
What do you mean with Stack ??
So people call a stack a LIFO for last in, first out.
Thim, a stack allows one to push data on to it. Inside the FC or FB the parameters are read from the stack instead of from the input area. A FC or FB can return data to the main program by pushing the return data onto the stack where the main program pops it off and uses it.
 
So people call a stack a LIFO for last in, first out.
Thim, a stack allows one to push data on to it. Inside the FC or FB the parameters are read from the stack instead of from the input area. A FC or FB can return data to the main program by pushing the return data onto the stack where the main program pops it off and uses it.

Thx peter
FIFO and LIFO I know very well, we use it alot but i was not aware of the term Stack.

I'm working for a company that design Dosing and transport systems for liquid and powder applications.
Fifo is used for example reservation of Weighthoppers etc
 
Hello

Thanks for your answer very much. It is very helpful just the answer I am looking for.

ANY pointers are Siemens' implementation of adding a type to a pointer. The ANY pointer is 10 bytes long and has a structure like this

byte n 16#10
byte n+1 Type
word n+2 number
word n+4 DB number
dword n+6 Area pointer

Go to the on-line help and search for ANY in the index. There is a good description there. The tricky part is pointing to arrays of UDTs. The ANY pointer is just of type byte and the total number of bytes. Some people get tricky and pass only a pointer to the first UDT so the number of bytes is the UDT size but then you don't know how many UDTs there are in the array. However, I don't think this will be a problem in a stack based application since I doubt you will want to pass pointers to whole arrays of UDTs on a stack.

I am checking the online help right now. When I understand how to use it I will write the code.I dont want it to be that complex.I am not going to use the stack for arrays of udts

Using the stack of ANY pointers will make all your stack elements 10 bytes long and make stack management easiser but a lot of code/functions will be required to do make all the stack PUSH and POP routines for different data types. It will not be efficient but it should be clean once you get it done.

This is interesting. I can understand why you want to do this.

I implemented a stack code for int on the project I was working and think why not write a stack code for all data types so wont never think again about the data type...

When I face something like that I mean I have to write a code for a type or a project specificly it becomes something just valid for the type or the project itself and type of code which I dont like. The best code I think is free from type and project doesnt depend on platform which means I can use it everywhere everytime (I know it is impossible :))

I have some free time right now and when I have that I always try to implement the ideas I have written before and try to make up a library of codes useful like just I before mentioned so I can call them when I need.

The idea behind is that.I hope I made it clear why I want to do this and it is a good exercise by the way I already learned something: any pointers...

PS: I have written stack means FIFO sorry about that wrong piece of information. Peter already corrected it for me

Stack means LIFO Last in First out...

Thank you all.
 
The implication is that you want the FIFO to contain an arbitrary mix of data types.

I can see how you will add data to the FIFO because you will call your add to FIFO function with the required data type - I don't see how you will get data from the FIFO unless you assign your get from FIFO function with every data type as it's output parameters and then only assign the output parameter according to the data type in the FIFO
 
FIFO and LIFO I know very well, we use it alot but i was not aware of the term Stack.
PLC people tend to use the term LIFO. Micro controller people and C programmers use the word stack. There is a register called a stack pointer in most microcontrollers.

Hi Peter,
I don't even understand what he is triing to do, sure i don't understand why he wants to do it
erdemsvri is looking for a clean and easy way to pass parameters to a FC and FB that will work the same for both FCs and FBs. It will be a method he understands and over which he has control. I understand that. I really hate working with other peoples stuff too.

I think that the stack routines will add too much overhead to his test system. The S7 is going to be a busy CPU controlling motion and pressure. I also think that while writing the stack routines the erdemsvri will learn enough about the S7 where he will feel the stack is unnecessary.

erdemsvri, you really should just get SCL.
 
The implication is that you want the FIFO to contain an arbitrary mix of data types.

I want a LIFO not FIFO.I mistyped first.

I can see how you will add data to the FIFO because you will call your add to FIFO function with the required data type - I don't see how you will get data from the FIFO unless you assign your get from FIFO function with every data type as it's output parameters and then only assign the output parameter according to the data type in the FIFO

You can take a look at the pic I attached and figure out.

There will be 2 data blocks

1. will hold the data itself
2. will hold the number of data bytes

like this

push md200 push db3.dbb2 push array[1..50] of int

Data_DB:data, data, datas.....

SIZE_DB:4,1,100,

So by looking at the last int of Size db I will figure out how many bytes to write to the output.

Thanks..

adsız.jpg
 
PLC people tend to use the term LIFO. Micro controller people and C programmers use the word stack. There is a register called a stack pointer in most microcontrollers.


erdemsvri is looking for a clean and easy way to pass parameters to a FC and FB that will work the same for both FCs and FBs. It will be a method he understands and over which he has control. I understand that. I really hate working with other peoples stuff too.

Yes. I am new in S7 and I worked with microcontrollers when I study engineering a lot so my head always works for the same way.

I think that the stack routines will add too much overhead to his test system. The S7 is going to be a busy CPU controlling motion and pressure. I also think that while writing the stack routines the erdemsvri will learn enough about the S7 where he will feel the stack is unnecessary.

erdemsvri, you really should just get SCL.

Peter, you really become a interpretor for what I am trying to say.

As I said I am new in PLC and trying to figure out STL and SCL. Mostly I use LAD right now but I dont like that so try to implement different ideas with STL and SCL.I am trying to learn SCL and STL at the same time so when I implement something in SCL I try to do the same with STL.

By the way we will go the factory on next monday for that test machine Peter we havent started that yet, I had the program codes finished but didnt try the real system so will see if S7 can answer to the system requirements there.

If S7 cant we can go with something else so can I contact you? By the way I had called Teknik Destek Grubu for Delta Motion Controller and talked to them and asked for a configuration and a price but they havent returned yet.

So will talk later about that...
 
If S7 cant we can go with something else so can I contact you?
Yes, you can private message me or e-mail me. My e-mail address is easy to find. Just put peter@ in front of our domain name or you can go to our website
http://www.deltamotion.com
and e-mail us.

By the way I had called Teknik Destek Grubu for Delta Motion Controller and talked to them and asked for a configuration and a price but they havent returned yet.
Hmmmm. I will look into that.

Meanwhile, you may find this interesting.
http://www.controleng.com/article/3...php?nid=2363&rid=#reg_visitor_id#&source=link
 

Similar Topics

as already mentioned in the title, document 1756-rm014_-en-p.pdf mentions a limit of decorated data (XML format) to 100k. Is there a way to...
Replies
0
Views
617
Hi all, Working on a project in Studio 5000 setting up a UDT to read an Input Instance from an EIP device. I have everything set up and it's...
Replies
2
Views
894
I am using a SMC ex260, The guide shows you can use SINT or INT 2 byte Input 4 byte output I don't have the hardware yet to test this, but I was...
Replies
3
Views
1,165
Hello i have currently a problem with data archive that are used to display on trends i have approximately 50 tags recording with an update rate...
Replies
0
Views
1,279
Does anyone know of a way of obtaining the size of a data type (actually a UDT) or tag in bytes? Similar to the sizeof() operation in 'c'. For...
Replies
7
Views
3,097
Back
Top Bottom