Sign in to follow this  
Followers 0
CookieMonster

Array Identifier

12 posts in this topic

Hi, I'm more familiar with Logix but am currently working on a Siemens Project using S7-300. I have a UDT array DIG[ ] and some code which scrolls through the real world" input/output's and maps them to the array. It looks something like "EqpStatus".DIG[1].X (X being the UDT Bools,Ints etc) Anyway my problem is that when I do this using Logix, I can assign an alias tag to each of the array elements so I know which input/output it has mapped to but I don't seem to be able to do this in S7? is this possible?

Share this post


Link to post
Share on other sites
Hi 'monster'. No unfortunately you cannot assign a symbol on top of the array adress. If you are not using some kind of array indexing in SCL via the symbolic adresses, then an alternative could be to simply create all the UDT instances one-by-one in stead of in an array. You can then give them individual names. You can still manipulate the 'array' with indexing, only it takes more manual programming work.

Share this post


Link to post
Share on other sites
Bugger! So you can't attach symbolic names to array elements at all? this could be a problem! Does anyone know why S7 is like this?

Share this post


Link to post
Share on other sites
Sorry for delay, Well we use an array of a UDT which contains BOOLs and INTs values such as .Ip and .AOut1, .AOut2, AOut3 etc etc. I also have some source code which maps outputs & inputs for example .AOut1 to output M0.0 which is "Valve_1". Array element 2 maps to M0.1 "Valve_2" etc. So if i want to turn on a valve from multiple inputs I can use AOut1, 2, 3, 4 etc. The problem being that in LOGIX I can assign a symbolic name to each array element and then I know which element is controlling each valve or output or input. So in S7 the only information I can get is the address eg. DB1.DBX31.5 or the name DEqpStatus.DIG[1].AOut1 BUT in LOGIX I can also assign a symbolic name like Valve_1 or Flow Transmitter etc etc Basically anything that gives some information about what piece of equipment that array element is controlling. My problem being that I can't seem to do this in S7!

Share this post


Link to post
Share on other sites
Hi Monster. I am still not sure what it is that you want to achieve. You are describing what you are doing, but now what you ultimately want to achieve. To me it sounds like you are making some kind of reusable code, and you want to access the variables from elsewhere in the program. Without knowing too much about your application, it sounds like an array is not the proper method, regardless of that you have done it in CLX. For your information, I program my standard 'objects' as FBs + associated IDBs. I can acess the variables from elsewhere, in this manner: "Motor_11".Command.start and "Valve_20".status.open for example. Is it something like this you want to achieve ?

Share this post


Link to post
Share on other sites
Hello, Thanks for your replies, I do appreciate having someone to discuss this with!!!! Ok i'll try to be more transparent! I want to indirectly address my I/O's using an array of digital equipment and an array of analogue equipment. Each element will be mapped to a piece of equipment eg. array element DigitalInput[1] will be mapped to I0.0. Now, regardless of what I0.0 actually is I want to symbolically address Digital Input[1] as the name of that piece of equipment. But so far it seems I can't do that. So...what you are sounds like what I want to achieve. Are you saying that you create a FB and IDB for each piece of equipment? I have hundreds of digital items and a handful of analogues. that might get messy!

Share this post


Link to post
Share on other sites
What JasperMP says is: if you have many pieces of same equipement. And each of them you want to control with same piece of code (with different addresses of course). Then in the S7 world you create or a FC - piece of code with symbolic inputs and outputs which can have assigned real addresses, or a FB - same as FC but can also have static variables inside. (static means preserved between calls). To JasperMP: I had some experience with AB SLC500 and Micrologix. There is nothing like FCs and FBs. So you can't create blocks of code with interface. To reuse code you have to do funny things. So if this Logix the guy is experienced with is similar... Edited by jacekd

Share this post


Link to post
Share on other sites
I dont know what problem it is you are runnning into. You can do the way you want it. Any way you do it there is some manual labor in passing names and i/o addresses. Personally I prefer to use 'regular' calls to FBs + IDBs because I can call an object "motor_33A2" and not "motor[7]". The first can be the name use in other documentation. Below is ONE way of doing it: You create a UDT called "motor" with variable declaration inside like this for example: cmd STRUCT start BOOL FALSE stop BOOL FALSE speed NT 0 END_STRUCT status STRUCT OK BOOL FALSE run BOOL FALSE speed INT 0 END_STRUCT You then create a shared DB "group1" for example with an array "motor" of type "motor". You probably want to put the code that services the motor 'objects' into an FC. (FC declaration part) IN contactor_on BOOL motor_data "motor" OUT contactor_coil BOOL (FC code part) A #motor_data.cmd.start A #motor_data.status.OK = #contactor_coil Somewhere you must call the FC to be serviced. This is where you pass the i/o and assign the associated DB data. You have to repeat this for all the motor object in your project. CALL "motor_start" contactor_on :=I0.0 motor_data :="group1".motor[2] contactor_coil:=Q0.0 (finally, code on a higher level commanding the motor on a lower kevel) A "group1".motor[2].status.OK = "group1".motor[2].cmd.start jacek, CookieMonster has probably worked with ControlLogix. ControlLogix has both UDTs and reusable code in the sahpe of FBs and FCs. Edited by JesperMP

Share this post


Link to post
Share on other sites
Oh by the way. Very important when programming symbolically like this: Set Address prority to "Symbolic". You do this by opening the "Properties" when the "blocks" folder in the project tree is selected. Then there is a tab "Adress priority".

Share this post


Link to post
Share on other sites
Okay, Thanks for all your feedback and replies. I have created a DB and will populate with each piece of equipment (as a UDT). I now have two options I can either write a function which "mirrors" the array elements or I can change my code so that I don't scroll through an array but rather scroll through the DB. Either way will work its just deciding the best for this proj! Jesper, thanks for the coding demo its very nice. The only problem I can see is that you have motor[x] and there are many motors its difficult to identify individual motors. Thanks again, much appreciated!

Share this post


Link to post
Share on other sites
Then in stead of creating an array of 100 motors, define motor instances one-by-one in a shared DB. For each instance you can then name them individually. Tip: Create 10 instances, then select them all and copy-paste them 9 times to get 100 instances. Then tidy up by assigning each one a meaningful name. Comment: If you have SCL (similar to ST in CLX), then it is dead easy to index thru an array. If you do that I mentioned about building a list of instances manually, then you can still indecx thru the "array", only it takes a bit more manual work. The REAL point to be aware of is that you have to be careful if you change the UDT declaration. With an array you indexing code would be largely unaffected, whereas with a manually coded indexing you would have to go back and check your code each time. Edited by JesperMP

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0