Trouble with pointer....please help !!!

bartjanisse

Member
Join Date
Mar 2006
Location
Wijchen
Posts
7
Hi all,

I have the following FC:

FC100

INPUT
TRACK_NR := dint
FUNCTIE_NR := dint
BITJE := bool

INPUT/OUTPUT
FUNCTIE_WOORDEN := array[0..19] of dint


Network 1:

L P##FUNCTIE_WOORDEN
LAR1
//;
L #FUNCTIE_NR
SLD 5 // Multiply by 32
L #TRACK_NR
+D
+AR1
//;
U #BITJE
= [AR1,P#0.0]


I call this FC from a FB like this

FB1

STAT
FUNCTIE_WOORDEN := array[0..19] of dint

CALL FC 13
TRACK_NR := 0
FUNCTIE_NR := 0
BITJE := TRUE

problem:

when i look in the DB which belongs to the FB1 i would expect that FUNCTIE_WOORDEN[0] <> 0. But all i see is zero.

Can someone explain me what I am doing wrong ?

Thank a lot in advance,

Bart Janisse
 
Hi,

Thanks a lot for your time. I did monitor the FC but I can't figure out why it's not writing the bits.

but when i use the code below it's working. But this is a spoil of memory....any thoughts ???

Thanks again

Network 1:

L FUNCTIE_WOORDEN[0]
T TEMP_FUNCTIE_WOORDEN[0]
L FUNCTIE_WOORDEN[1]
T TEMP_FUNCTIE_WOORDEN[1]

etc. etc.

Network 2:

L P##TEMP_FUNCTIE_WOORDEN
LAR1
//;
L #FUNCTIE_NR
SLD 5 // Multiply by 32
L #TRACK_NR
+D
+AR1
//;
U #BITJE
= [AR1,P#0.0]

Network 3:

L TEMP_FUNCTIE_WOORDEN[0]
T FUNCTIE_WOORDEN[0]
L TEMP_FUNCTIE_WOORDEN[1]
T FUNCTIE_WOORDEN[1]

etc. etc.
 
Your FC13 should be as follows:

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

VAR_INPUT
  TRACK_NR : DINT ; 
  FUNCTIE_NR : DINT ; 
  BITJE : BOOL ; 
END_VAR
VAR_IN_OUT
  FUNCTIE_WOORDEN : ARRAY  [0 .. 19 ] OF DINT ; 
END_VAR
VAR_TEMP
  iDB : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =
      L     P##FUNCTIE_WOORDEN; 
      LAR1  ; 
      L     W [AR1,P#0.0]; //get db number
      T     #iDB; 
      OPN   DB [#iDB]; 
      L     D [AR1,P#2.0]; //get area pointer
      LAR1  ; 
      L     #FUNCTIE_NR; 
      SLD   5; // Multiply by 32
      L     #TRACK_NR; 
      +D    ; 
      +AR1  ; 
      A     #BITJE; 
      =      [AR1,P#0.0]; 
END_FUNCTION
 
You really saved my day...thank you so much for it.

But lets see if I can understand it:

When i monitored my program I saw that after these instruction

L P##FUNCTIE_WOORDEN
LAR1

that my adress register 1 contained the value "V 9.0". I read that the V stands for prevous local data. Does that mean that it is actually the local data of the fb from where this fc is called ?

Thanks again,

Bart Janisse
 
Yes. Arrays are passed as db pointers(word+dword==db+area pointer).

The DB pointer is copied to the local data area of the FB and the FC is actually passed a pointer to the local data.
 

Similar Topics

After the new very nice update to this site I could not log in with my original password, tried to recover my account but did not recieve a email...
Replies
14
Views
400
Hi everyone. I have an issue with an Allen Bradley PLC model 1769-L30ER. This PLC had a previous program with a different IP address but when I...
Replies
4
Views
534
Hello, We are having trouble setting up a generic ethernet module for a Yaskawa GA80U4168 drive in RSLogix 5000 Version 20.01. All of the...
Replies
1
Views
619
I was interested in buying several of the Personal PLC tutor courses from the PLC training store on this site (http://www.plcs.net/store.shtml)...
Replies
4
Views
995
Disclaimer: English isn’t my native language, so apologize for any incoming grammatical or spelling mistake. Hello everyone. I’m trying to make...
Replies
3
Views
2,129
Back
Top Bottom