Complex IN parameters in FCs

jormaga

Member
Join Date
Sep 2010
Location
Madrid
Posts
9
Hi again!

I've encountered the following problem:

When I try to use a FC with a complex parameter (DATE_AND_TIME, POINTER, ANY...) I'm not able to use it. With simple parameters it's obvious to work with them via the L command, but with these ones greater than the ACU size I don't know how to work with. One way is obvious to work with FB instead of FC but I'd like to know if it's possible to do it with a FC (I think there should be a way to do it, because the FC 6 is a function with a DATE_AND_TIME in parameter).

More graphically what I try to do is:

CALL FC100 (myFunction)
IN := #dtTempDT //Date and Time parameter

Inside FC100:

Input parameter declared as IN0 Date And Time

CALL FC 6
IN := IN0
OUT := DB1.DBW 10

I get an error when I handle IN0 (#IN0 or whatever...)


Regards,

Jorge
 
You will need to copy the date and time to a local variable and pass on the copy to FC6, here's an example:

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

VAR_INPUT
  dtDAT : DATE_AND_TIME ; 
END_VAR
VAR_TEMP
  dtCopy : DATE_AND_TIME ; 
  wDB : WORD ; 
END_VAR
BEGIN
NETWORK
TITLE =pass on date and time to FC6
      L     P##dtDAT; //pointer to param
      LAR1  ; 
      L     W [AR1,P#0.0]; //db number
      T     #wDB; 
      L     D [AR1,P#2.0]; //area pointer
      LAR1  ; 
      OPN   DB [#wDB]; //open parameter DB
      L     D [AR1,P#0.0]; //fetch lower 4 bytes of date and time
      L     D [AR1,P#4.0]; //and upper 4 bytes of date and time
      LAR1  P##dtCopy; //point to local copy
      T     D [AR1,P#4.0]; //insert upper 4 bytes into local copy
      TAK   ; 
      T     D [AR1,P#0.0]; //insert lower 4 bytes into local copy
      CALL FC6 (//call FC6 with copy of date and time passed as a parameter
           IN                       := #dtCopy,
           RET_VAL                  := DB1.DBW    10);
END_FUNCTION
 

Similar Topics

Yes it's very legacy.. but sometimes it's necessary to use old stuff for fun.. and because it's so much cheaper. Crimson 3.0 had the ability to...
Replies
4
Views
1,611
Hello all, I am fairly new to programming HMI's and am working with Crimson 3.1 for the first time. I am trying to recreate an annunciator of...
Replies
12
Views
6,362
What application in your experience has demanded the most complex PLC program? I suppose I should clarify what manner "complex" I'm asking about...
Replies
37
Views
12,411
I have this complex code tag that returns as a string variable. For some reason it returns the two strings with a ?? between them -- not the...
Replies
2
Views
3,508
I have my L5K file imported into my project, and the tags I need in the "available addresses". Is there a way to access my PLC tags in a complex...
Replies
2
Views
2,954
Back
Top Bottom