DB UDT's and STL

JOLTRON

Lifetime Supporting Member
Join Date
Aug 2006
Location
MI
Posts
692
I am wondering if I am going the long way about this.
I have a UDT with the status and information of a part we run. This UDT holds 100 bytes of information. Assorted items like Dints with real number values of LVDT's that gage the part, Leak rate of the part, and characters of a decoded 2D datamatrix.

Basiclly I want to take the information from this part and store it in a DB along with the last 50 parts. Is the only way to copy a UDT where the destination is offset each time with an ANY pointer.
If so this is my first attempt and wanted to know if I am on the right path or should be any of this differently. Thanks for any and all criticism.

Sorry for copy and pasting as text couldn't see how to enter code.

NETWORK 1
//Open Datablock to be used
// OPN "DB_DataTracking" //Open Past Part Buffer DB
//Load Max number of "Offset", Increment "Offset", Compare to Max
L 50 //Max number to allow before reseting
L "OffsetNumberIndirectAddr" //Number for "Offset" (MB12)
+ 1 //Increment "Offset" by 1
T "OffsetNumberIndirectAddr" //Increment "Offset" by 1 (MB12)
>=I //if "Offset" >= Max number specified above
JC skip //jump to skip otherwise reset offset
//Reset "Offset" if Max is reached
L 1 //Load 1 and transfer to
T "OffsetNumberIndirectAddr" //Reset offset to 1 (MB12)
//Calculate Indirect Address for current data to be moved to
skip: L P#DBX 100.0 //Load Pointer of 100.0
*D //Mulitply by "Offset" (MB12)
T "NdirctAddrsPastPartBuffr" //Create Indirect address (MD25)

NETWORK 2
LAR1 P##AnyPoint
L W#16#1002 //Byte 1 - Any pointer header, Byte 2 - Data Type = BYTE
T W [AR1,P#0.0]
L 100 // Set repetition factor to 100
T W [AR1,P#2.0]
L 203 //DB203 to be used
T W [AR1,P#4.0]
L "NdirctAddrsPastPartBuffr" //Byte Offset determined above (MD25)
T D [AR1,P#6.0]

NETWORK 3
CALL "BLKMOV"
SRCBLK :="SerialStages".EXIT_INFO
RET_VAL:=#tempint
DSTBLK :=#AnyPoint
NOP 0
 
Last edited:
I didn't test your code, but the approach is fine. One thing I'd do is make the destination pointer a local variable instead of MD25. It isn't absolutely necessary, but I use locals when there isn't a reason for any other function to reference a variable.

Also, if you want to use MD instead of a local, it's good practice to start at an even byte boundary instead (i.e. MD 26 or MD 28).
 
Your pointer arithmetic is wrong - you cannot multiply P#DBX100.0 by anything as it will destroy the area encoding, use the following instead:

Code:
	  L	 P#100.0					 //Load Pointer of 100.0
	  *D								//Mulitply by "Offset" (MB12)
	  L	 P#DBX 0.0				   //area pointer to DBX
	  +D								//add offset
	  T	 MD	25					//Create Indirect address (MD25)

Use the following for the DB so that it comes up in the xref

Code:
	  L	 100						 // Set repetition factor to 100
	  T	 W [AR1,P#2.0]
	  OPN   DB   203
	  L	 DBNO						//DB203 to be used
	  T	 W [AR1,P#4.0]
 
Simon, Thank you greatly for taking the time to look at that.
It would have taken me forever to catch that.

S7GUY, Thank you also for your advice. I recently took a class that went over the basics of STL and indirect addressing and in all of his examples he used MD's instead of local. Never really understood why. As far as the odd Word and Dword, that's just kind of a habit of mine. I just use the next available area.
 
Last edited:
You can't copy a UDT. UDT's, once created, can only be represented in your logic, to do what they have to do, when they need to do it. It is a way of doing coding, from a master to a slave, or maybe more than one.

It could actually be only limited to your required scan time, and the speed of the process. Besides that, you can manufacture magic with UDT's, fully integrated with some HMI and SCADA systems, even remote stations.

Scan time falls low. Availability good. Traffic on the network reduced, if required. Logic simple, no bouncing bits all over the place.

UDT's is the next level of indirect addressing. You don't need a pointer in your code.

Regards

Ps.
 
Here's an example project that performs the processing required but in a slightly more flexible manner. By passing the base address and the first element of your storage areas in as parameters, you can work out the size of the UDT and the number of them programmatically instead of having to use hard coded numbers.
 
Manny,


I don't really know if I'm following what your saying.

Basicly I created a UDT1 which holds
Array of 20 characters
Pass/Fail data of 5 stations
Data for 11 LVDT's
Leaktest rate
etc..

I also have a DB with 50 of my UDT1.
So after 1st part goes through the full cycle copy the "Final information" of my type UDT1 to my DB203 that holds the record of the last 50.

So cycle 1 would send "Final information" of type UDT1 to DB203 PreviousPart1 of type UDT1

Cycle 2 would send "Final information" of type UDT1 to DB203 PreviousPart2 of type UDT1

And I see I could have done this without an ANY pointer but that would have taken 50+ networks.


Simon,
Thanks for the example project I'll try implementing that later next week.
 
Simon,

Thanks alot. This works great. It is great how flexible it is. And so simple, yet I wouldn't have thought of doing it that way.

Thanks,
-Joel
 

Similar Topics

Afternoon all, I'm working on setting up a large excel recipe table for porting updates through the Linx Gateway RTD/DDE function into my recipe...
Replies
2
Views
134
I am trying to copy an array of real numbers into a UDT with a real data type element. I have attached a snip below showing my COP instruction...
Replies
4
Views
218
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
174
Does anybody have any samples of how to "Create and Use" UDT's in CCW Developer Edition? (I am using v22) I can't find any information from...
Replies
3
Views
333
Hello, I have been looking for a reference for the order that a UDT is copied in the COP instruction. More specifically - I have a set of code...
Replies
5
Views
564
Back
Top Bottom