Step 7 Question using Inputs and Any Pointer

Mark Whitt

Member
Join Date
Jan 2013
Location
Columbus, OH
Posts
31
Hello Folks!

I'm still trying to get the hang of using STL and Pointers in Step 7 (V5.5).

For background, I'm writing a sample application that our customers can use for reference in the case where they will be using one or more of our weigh terminals in their process. This requires that they read a block of input words from the device and generate a checksum from them to compare against the checksum that the device itself is sending.

In the case where there are more than one of these devices on the ProfiBus network, I'd like to send the starting Input address to the checksum routine and have it calculate the checksum for any device submitted. This requires the passing of a pointer or Any Pointer to the FC function that I've written.

The function works fine if I hard code the starting Input address into the function itself. But when I try to pass the address via a pointer, things no longer work, and I'm at a loss to figure out why.

Additional background is that I try to write the samples using ladder logic where possible to make them easier to understand for as many people as possible, and then switch to STL when necessary because that's what is available to everyone by default.

Here's a picture of the routine that calls the checksum function:
FC1.JPG


And here is a picture of the checksum routine itself:
FC103.jpg



I know that the Any Pointer in the calling routine is set for a size of 2 Bytes, which is wrong. But I've tried other sizes (240, 224, and so on) with the same results.

I'm sure the problem is something simple, but at this point my eyes are crossing and I'm just not seeing it. So, any help would be appreciated.

Thanks in advance!

Mark
 
Any pointers consist of an ID (byte), type (byte), count (word), DB number (word), and area pointer (dword).
Here's an example accessing the above data.

any1.jpg
 
Thanks, L D[AR2,P#0.0] !!

That's exactly what I needed. It works now!

Now I'll ask one more question just for my information.

I also attempted to do this using just a pointer instead of an Any pointer, but was not successful. I had the following input to the FC call:

CHK_SOURCE = P#I272.0

And the code in the function looked like this:

L P##CHK_SOURCE
LAR1


L #Loop_Counter
LOOP: T #Loop_Counter
L W [AR1,P#0.0]
CAW
L #tmp_CheckSum
+I
T #tmp_CheckSum
+AR1 P#2.0
L #Loop_Counter
LOOP LOOP

L #tmp_CheckSum
CAW
T #CheckSum
NOP 0

This would fail, again because the pointer is not loading as I expected.

Can someone help me to understand why this failed?

Again, many thanks for the help!
 
A pointer consists of the DB number (word) and the area pointer (dword).

Code:
L W[AR1,P#0.0] //read the DB number
L D[AR1,P#2.0] //read the area pointer
 
Thanks again, L D[AR2,P#0.0] !

Yes, that works.

For anyone else that had the same problems I had, here is the final version of the code using a regular pointer:

IN:CHK_SOURCE (type pointer) = P#I 272.0, set in the call to the function.
OUT:CheckSum (type Int)

TEMP:tmp_CheckSum type Int
TEMP:Loop_Counter type Int


Network 1 sets #tmp_CheckSum to zero, and #Loop_Counter to 112.

Network 2:
//--- GET POINTER OF POINTER
L P##CHK_SOURCE
LAR1
L W [AR1,P#0.0] // read the DB number
L D [AR1,P#2.0] // read the area pointer
LAR1

Network 3:
L #Loop_Counter
LOOP: T #Loop_Counter
L W [AR1,P#0.0]
CAW
L #tmp_CheckSum
+I
T #tmp_CheckSum
+AR1 P#2.0
L #Loop_Counter
LOOP LOOP

Network 4:
L #tmp_CheckSum
CAW
T #CheckSum
NOP 0

One other major stumbling block I had that I'll metion here is that I originally started out trying to use the PIW range for inputs because the IW range always returned zeroes for me. That's because I didn't understand that I had to go into the hardware setup, call up the object properties (go to the Cycle/Clock Memory Tab) for the processor, and change the sizes for the process-image Input and Output areas to include the range for the I/O of the devices on the ProfiBus (in this case, I changed both to 512).

With that, I was able to use pointers to the Input area in the program where I was not able to use points to the PIW region. That discovery made my life much easier!

I hope these revelations also help someone else.

Regards,
 
You can use pointers to the PIW area so you do not have to have the address in the process image range.
 
Yes, you are correct. Where I ran into problems was using the BLKMOV library, and places where I tried to use an Any pointer.

Again, thanks for your help. People like you are what makes these forums work so well.
 

Similar Topics

Hi everyone, I have a short question about BLKMOV instruction, illustrated in the image below. I have the same piece of code in STEP 7 (ET200S)...
Replies
2
Views
2,697
When looking at the DB declaration ( see below pic), I did not see addresses like DB108.DBX203.0 or DB108.DBX205.0 and so on .... and yet they...
Replies
15
Views
3,243
Is it Gain or Proportional band? The HMI shows it as Proportional Band and the tag name is Gain???
Replies
3
Views
2,164
Tomorrow morning I have to use a rented Siemens PC to troubleshoot a Siemens HMI, programmed with WinCC, communicating to a couple of ABB drives...
Replies
5
Views
10,119
Hello all, In our factory we have quite a few step 7 plcs, the programs for which were written in step 7 v5.4, we have a desktop pc with v5.4 on...
Replies
1
Views
2,595
Back
Top Bottom