Newbie - STL Question

JayD

Member
Join Date
Aug 2009
Location
Australia
Posts
53
Heya,

Am new at this but here goes:

I am struggling with creating an FC that retrieves a UDT from a Shared DB that contains an array of UDTs.

I create an ANY pointer to the shared DB and use it as the source for a BLKMOV. Then for the destination of the BLKMOV I want to simply use an output UDT, but no love.

Do I have to create a second destination ANY pointer to point to the output UDT? If so what is the syntax for this?

Any feedback would be appreciated.

Cheers
JD
 
Cut your code down the minimum required, copy it into a library, archive it and attach it to a post.
 
S7 - BLKMOV to UDT output in FC

Mr/Ms L D[AR2,P#0.0],

Thanks for your reply. As requested the sample code is attached. FC225 is where my issue is.

My preference is to simply define the output as the BLKMOV's destination. In trying to figure it out I wrote something in SCL and read the STL conversion. It used an ANY pointer to the output.

I don't know how to use an ANY to point to data that isn't in a shared DB.

Hope you can help.

Cheers
JD
 
All FC parameters are passed by pointer. All FB parameters are passed by value in the instance DB.

You cannot use SFC20 to pass data back to the block that called FC225, instead you must code your own copy using a loop.

Here's my implementation:
 
Sort of but it didn't smell like teens ;-)
After you were once more faster answering, I noticed to late that you also added a example program, so it wasn't necassary to explain how to do it with an anypointer what is basiclly the same
 
Fanx for the answer! (I likes both of yas tunes reference - it scored the "Hottest Song of All Time" in my home country).

Anyways - I thinks I understand most things except for a couple of questions:

1, What is the differences between an ANY and a UDT in data structure?
2, Why is the 1st byte of an output UDT equal to the instance DB number?
3, Why is the 3rd to 6th byte of the UDT reference the memory location of the UDT's 1st byte?
4, Also does the UDT have an element that defines the length of the structure?

Hope these make sense - I just would like to understand so I don't have to bug you guys next time.

Fanx Again
JD
 
1, What is the differences between an ANY and a UDT in data structure?
..
..
4, Also does the UDT have an element that defines the length of the structure?


When you define a in as ANY and then put the UDT at the call and you start investigating the anypointer then you will find all the info about the UDT. This way you can find the length of the UDT (be aware the length is in BYTE)
You can also find the location where the UDT starts.
This way you can work your way arround this in indirect adressing.
 
1. Please re-phrase the question - what is the difference between any (a predifined data type) and a UDT (a user defined data type)

2+3. All FC parameters are passed by pointer. The pointer to a UDT is called a DB pointer and consists of the DB number followed by the Area pointer.

4. No
 
Thim,

Thanks for the explanation. I understand the extraction of the UDT's details (incl. byte length) via the ANY.

What I don't get, is the following lines of code (where MISSION is a UDT):

L P##MISSION
LAR1
L W [AR1,P#0.0]
T #iDestMissionDB
L D [AR1,P#2.0]
LAR2 // Memory Location of MISSION

This implies that a UDT has a header, similar to how a STRING has a header of max length and actual length. So am wondering what the structure of a UDT is?

JD
 
L D[AR2,P#0.0],

I am starting to get it- Finally! But more questions:

5, So "P##MISSION" points to a DB pointer (that points to the MISSION UDT)?

6, Why doesn't a DB pointer contain (need) the length?

7, Also if a FC has a basic data type (eg INT) as a parameter what type of pointer is used?

Thanks for your quick replies.

JD
 
5. Yes
6. The format of a DB pointer is DBNumber,AreaPointer (word,dword). It does not contain the length. (Use the ANY pointer if you need the length)
7. Area pointer(dword)
 

Similar Topics

Hello all, I'm a new member here. I've joined as I want to learn about PLC programming. I've got a few questions to begin with. To get me...
Replies
37
Views
4,563
Howdy folks. Been doing PLC programming for like 15 years now in LD and ST, but I'm trying to learn SFC now and have a kind of dumb question... I...
Replies
4
Views
1,407
Hello. New to Unity and had a couple quick questions. Can a Modicon M340 output to a small multiline LCD screen and not a full HMI?
Replies
4
Views
964
Hi. I'm learning AOI programming in RSLogix 5000. I created an AOI with several input and output parameters but when I choose the AOI in the main...
Replies
17
Views
3,220
Good morning, I've had an inverter fail with firmware revision 5.002, the only spare is Rev 7.001, when updating the project with the new...
Replies
2
Views
1,260
Back
Top Bottom