You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old May 26th, 2008, 06:20 AM   #1
sapoleon
Member
Argentina

sapoleon is offline
 
Join Date: Aug 2003
Location: salta, salta
Posts: 308
Siemens DB, UDT and Pointer

Hi,
I'm having a hard time trying to learn very fast how to do the things in Step 7. I see a lot of options, but I don't have now the time to try them.
I made a function not nice, to get and write data to a DB made of 30 UDTs of the same type. The thing is, I someone can give me a tip on how to do it with pointers.

The UDT1 consist of 2 INT and a DINT.
The DB305 consist of 30 UDT1. (named wagon01 to wagon30).

This makes me a nice database, where the first colum (first INT of the UDT) almost never change,and I have to write a value to the second and third colums.
I get allways which of the 30 lines I have to change, and what's the data to write.

My question is how do I know the correct position of the UDT and in the UDT where the data is to be taken of or writen to with a pointer?

(I made a very ugly function where I access a line according to a comparsison, that is to say, if the #lineNumber == 5, I write in this line, if now keep asking) I don't want even to post it....

Thanks

ps: btw, I AM reading the posts, and siemens support, and trying to make it by myself...
__________________
I am responsible for everything...
except my very responsibility.
J.P.Sartre
  Reply With Quote
Old May 26th, 2008, 08:53 AM   #2
L D[AR2,P#0.0]
Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 4,972
Why are you using UDT's as opposed to an array of structures in your DB ?

Here's a simple example if your udt size and structure is not going to change

Code:
FUNCTION FC 2 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
  iWagonNumber : INT ; 
  iSizeOfUDTInBytes : INT ; 
  dbWagon : BLOCK_DB ; 
END_VAR
BEGIN
NETWORK
TITLE =wagon[n] access where n=1....30
	  L	 #iWagonNumber; 
	  +	 -1; 
	  L	 #iSizeOfUDTInBytes; 
	  *D	; 
	  SLD   3; 
	  LAR1  ; 
	  OPN   #dbWagon; 
	  L	 DBW [AR1,P#0.0]; //L Wagon[iWagonNumber].iFirstUDTName
	  L	 DBW [AR1,P#2.0]; //L Wagon[iWagonNumber].iSecondUDTName
	  L	 DBD [AR1,P#4.0]; //L Wagon[iWagonNumber].diThirdUDTName
	  T	 DBW [AR1,P#0.0]; //T Wagon[iWagonNumber].iFirstUDTName
	  T	 DBW [AR1,P#2.0]; //T Wagon[iWagonNumber].iSecondUDTName
	  T	 DBD [AR1,P#4.0]; //T Wagon[iWagonNumber].diThirdUDTName

END_FUNCTION

Last edited by L D[AR2,P#0.0]; May 26th, 2008 at 09:15 AM.
  Reply With Quote
Old May 26th, 2008, 11:28 PM   #3
sapoleon
Member
Argentina

sapoleon is offline
 
Join Date: Aug 2003
Location: salta, salta
Posts: 308
Hi L D[AR2, P#0.0],

First of all, thanks for your answer and help.

I don't really know why I'm using UDT instead of Array of Struct exactly. First of all, I'm quite new with Siemens, and trying it's features, and making things according at what I read at the moment.
In any case, it will be (at least at this time I think so) a normal structure in the program. It is not going to be just in this DB, it will be used in some other, and maybe pass also like data for some other functions that I am making.
What I may have done, is an Array of the UDT's instead of writing them 30 times, but I was afraid, that that would make my life even more difficult if trying to understand and access them with a pointer... Is there any difference in the accessing if I made a DB with array[1..30] of UDT1?


__________________
I am responsible for everything...
except my very responsibility.
J.P.Sartre

Last edited by sapoleon; May 26th, 2008 at 11:30 PM.
  Reply With Quote
Old May 27th, 2008, 02:15 AM   #4
L D[AR2,P#0.0]
Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 4,972
No.
  Reply With Quote
Old May 27th, 2008, 04:59 AM   #5
sapoleon
Member
Argentina

sapoleon is offline
 
Join Date: Aug 2003
Location: salta, salta
Posts: 308
thanks again, I will try it next week
__________________
I am responsible for everything...
except my very responsibility.
J.P.Sartre
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
S7: Problem with Pointer and indirect addressing douyi LIVE PLC Questions And Answers 18 February 2nd, 2010 04:17 AM
DB Sizes arkansascontrols LIVE PLC Questions And Answers 12 February 1st, 2008 04:34 PM
Siemens S7 Indirect Addressing MaxRoberts22 LIVE PLC Questions And Answers 44 July 15th, 2007 03:31 AM
Copy UDT data to tempory data Werner LIVE PLC Questions And Answers 20 November 16th, 2006 08:42 AM
S7: Symbolic pointer reference to UDT element GWB LIVE PLC Questions And Answers 8 June 6th, 2005 08:02 AM


All times are GMT -5. The time now is 04:22 AM.


.