Help With ANY pointers

Rui_M_T

Member
Join Date
Jan 2017
Location
Portugal
Posts
4
Hello Everyone,

I am making an FB that is going to retrieve information from a Pilz Multi.

The information given from the Pilz Multi is made up of Tables and segments and for now I am only going to read the information from table 1 which has 9 (0-8) segments of 14 bytes.

To retrieve the information, the table number and segment number must be sent to the Pilz via two output bytes. Then the requested segment is sent via 14 Input bytes that I will transfer to a DB to be shown on an HMI later on.

I am kinda new to Pointers so I am hoping someone can help me find the error in my program.

The problem I am having is that the FB is only sending information to the first two sets of 14 bytes and I cant find why, If it is working for the first and second group of 14 bytes it should also work for the remaining 7 group of 14 bytes. :oops:

I think there is a problem with the any pointer I created for the DB but I dont know where the problem is :cry:

Here is the program I have created:

NETWORK 1:

// ANY address Structuring

LAR1 P##DB_Address // load AR1 with ANY pointer
L B#16#10
T LB [AR1,P#0.0] // Constante in S7
L B#16#2
T LB [AR1,P#1.0] // Datatype in Pointer (02 = Byte)
L 14 //
T LW [AR1,P#2.0] // Repetition factor (14 = 14 bytes)
L #DB_Info_Number
T LW [AR1,P#4.0] // DB number
L B#16#84
T LB [AR1,P#6.0] // Memory area (b#16#84 = DB)


NETWORK 2:



// cheack if a read is active, if not continue to start conditions
//If read is in progress Jump to send the next requested segment
ON #Get_Info
JC NA
O #Read_In_Progress
JC Send

// Start - Begin by Requesting Table 1, Segment 0

A #Get_Info
JCN NA // if Get_Info is not active do nothing
L 1
T #Table_Request
L 0
T #Segment_request

// send the Requested table and segment to the Pilz Multi

Send: L #Pilz_Input
SLD 3
LAR1 // load AR1 with Output Pointer
L #Table_Request
T QB [AR1,P#4.0] // Send requested Table
L #Segment_request
T QB [AR1,P#5.0] // Send requested Segment

S #Read_In_Progress // set to know a read is in progress

// ANY address Structuring for area where the data is to be stored

LAR1 P##DB_Address // load AR1 with ANY pointer
L #Segment_request
L 14
*I
T LD [AR1,P#6.0] // Memory area in which the information is stored

// Wait For Feedback from Pilz
// If the segment value recieved is FF then this means fault, go to next segment
L #Pilz_Input
SLD 3
LAR1
L B#16#FF
L IB [AR1,P#5.0]
<>I
JCN Seg

//Pilz must send same table and Segment to be able to copy information

// L IB [AR1,P#4.0]
L MB 500 // For testing
L 1
==I
// L IB [AR1,P#5.0]
L MB 501 // For testing
L #Segment_request
==I
JCN END

// Copy the information retrived to the DB

CALL "BLKMOV"
SRCBLK :=P#M 456.0 BYTE 14 // For testing replace with Pilz Input
RET_VAL:=#Trash
DSTBLK :=#DB_Address

// Check When the ma segment number is reached and end the current read

Seg: L #Segment_request // Check for max segment and End the read Progress
L 8 // Table 1 has 8 segments
==I
JC NA

// Add 1 to read the next segment in the next cycle

L #Segment_request
+ 1
T #Segment_request
JC END

// If get_Info is not active or max segment reached then send 0 to the Pilz Multi

NA: L 0 // Load zero
T #Table_Request
T #Segment_request

L #Pilz_Input
SLD 3
LAR1 // load AR1 with Output Pointer
L #Table_Request
T QB [AR1,P#4.0]
L #Segment_request
T QB [AR1,P#5.0]

R #Read_In_Progress // End the read progress to start again a new read

END: NOP 0


The FB has three inputs:

an INT input #DB_Info_Number

An INT input #Pilz_Input

and a bool input #Get_Info



Thanks for any help given
🤞🏻
 
What are you trying to achieve with these ANY pointers ?
In what you have written abou the data from the Pilz multi device, I see no particular reason to code ANY pointers, certainly not by creating them manually.

You have to think in symbols and structures.
Use UDTs to define the data structures. Use DPRD_DAT and DPWR_DAT to read and write the data structures from and to the Pilz multi device. When coding the DPRD_DAT and DPWR_DAT instructions, specify the data to transfer via the symbolically defined addresses.
 
Hello JesperMP,

The idea of the ANY pointer is to give the address of the DB to SFC20 Move block. An INT Input of the FB will give the DB number and depending on the selected table number and segment number, the area of the DB will then be calculated and sent to the pointer.


The Pilz multi gives the information via 14 bytes so lets say in the hardware the Pilz is configured with input/output 450. I will send to QB454 the table number I want to access and QB455 the segment of that table I want to access. The Pilz will then output that segment information to IB456-IB467.
I then calculate the db area (using the table number and segment number i am sending to the Pilz) to copy IB456-IB467.
Once the information is coped, I then send a new table and segment I want to the Pilz where is will send via the same IB456-IB467 where i will calculate the address in the db for that information.... ext..


So when table 1 segment 0 is selected, the ANY pointer will have for example P#DB79.dbx0.0 BYTE 14. If segment 1 is selected the, ANY pointer will have P#DB79.dbx14.0 BYTE 14. If segment 2 is selected the, ANY pointer will have P#DB79.dbx28.0 BYTE 14 ... ect..

Where I work, I have about 12 different machines (PLCs) to apply this FB to and each on will have different input numbers and different DB numbers so I was hoping to simplify the reading of the information from the Pilz multi.

There are a total of 8 tables and a total of 49 segments in these 8 tables and I have created a DB with this structure to send the data to.
 
Most probably, the Pilz Multi device is not in the CPUs process image. The addresses you mention are outside an S7-300 CPUs (which I am assuming since you havent stated the exact CPU type) standard process image.
Because of that, you should use DPRD_DAT and DPWR_DAT as previously suggested.

When you specify the data on the RECORD pin on these blocks, you simply type the symbolic address of the entire structure (i.e. "my_DB".my_data). STEP7 then automatically creates the ANY pointer. You still only see the symbolic address even if it is actually an ANY pointer.

If you have multiple data areas, you should program multiple calls to DPRD_DAT/DPWR_DAT.

Without knowing the Pilz multi device, I am guessing that the Profibus data must be consistent. If there are multiple blocks of consistent data areas in the Pilz multi device, then each of these areas should be accessed by independent DPRD_DAT/DPWR_DAT calls.
 
With the code below I can't see any of the calls to SFC20 working - the area type will be zero and the byte address is not being shifted to convert it to an area pointer.



Code:
LAR1  P##DB_Address               // load AR1 with ANY pointer
      L     #Segment_request
      L     14
      *I    
      T     LD [AR1,P#6.0]              // Memory area in which the information is stored
 
It is used on a S7-319-3 PN/DP and the process-image is set to 500 so that ist the problem :cry:

The problem I have is all the information I request is sent always on the same inputs IB456-IB467. So what ever I ask the Pilz for, it will replay via IB456-IB467.

IB 456 - Byte 0 of requested segment
IB 457 - Byte 1 of requested segment
IB 458 - Byte 2 of requested segment
IB 459 - Byte 3 of requested segment
IB 460 - Byte 4 of requested segment
IB 461 - Byte 5 of requested segment
IB 462 - Byte 6 of requested segment
IB 463 - Byte 7 of requested segment
IB 464 - Byte 8 of requested segment
IB 464 - Byte 9 of requested segment
IB 464 - Byte 10 of requested segment
IB 464 - Byte 11 of requested segment
IB 464 - Byte 12 of requested segment

If I use DPRD_DAT and DPWR_DAT I sill have the same problem I am having with the BLKMOV. I want to call the same block and use the pointer to indicate where to send the data to the DB instead of calling the block 49 times with different outputs and with DPRD_DAT and DPWR_DAT i can only read out a maximum of four byte.
 
Hello L D[AR2,P#0.0],

Thanks for the help, this seamed to be the problem.
I forgot to shift the area calculation :mad:

It works now 🍺

Thanks again
 

Similar Topics

Hi I started programming in step7 but I'm not very skilled in it yet... I think that the question at my answer will be very simple for many of...
Replies
16
Views
11,303
Hi all I need help on this As in my project used Schneider TM241 controller. Now I want to communicate Elite energy meter with controller by...
Replies
3
Views
67
Hi all, I am having issues accessing my Cimplicity software - the site code changed after re-install and I am no longer able to attain a new key...
Replies
10
Views
105
Good day all! Can someone help me with the procedure to update Beijers E700 firmware? The Panel I am working on is firmware 2.04v and I would...
Replies
1
Views
49
Hi, We have an application that has a device that goes through a reboot (appears un-graceful) What then happens is the MVI module appears to hang...
Replies
0
Views
58
Back
Top Bottom