Step7 - Is it possible to transfer data to an Array as a Block Parameter

RMA

Member
Join Date
Sep 2004
Location
North of Hamburg, Germany
Posts
2,052
Another one for Simon! This is related to the BLOCK_DB question in as much as it's the same program. I need to pass over the Cell address in the Cognex Camera where my data is to be found. This address is in Excel form i.e. "G107" and needs to be passed to the camera as a String. I declared an Array with 6 entries as a Parameter (to cope with cell addresses like "AB1234", although 4 Characters will usually suffice). The FB accepted the Array as a parameter but I can't find any way to give the above cell address as a Parameter. Perhaps not surprisingly, a STRING input 'G107' didn't work, but neither did DW#16#47313037.

Is this sort of thing possible? Would it work with a STRING (I thought I was making things easier for the subsequent manipulation by using an Array), or must I separate the Parameters into Column as CHAR or BYTE and Row as INT. This could then easily be strung together inside the FB.

Cheers

Roy
 
Roy,

Before I offer an explanation of how I handle something similar to what you do, can you explain how this information is passed onto the cameras? Is it via Profibus or serial or another way. Also where are you recieving the cell information into the PLC, is this via OPC or a DB already within the PLC?

Does my questions make sense?

Paul
 
Communication with the cameras is via Ethernet. The commands are in the form of STRINGS which are laid in a Send-Buffer in the Camera programs IDB. The results land back in the Receive-Buffer of the same DB.

The handling of the whole business is a bit complex, but it works OK. Now, however, the customer wants to get some additional information from the camera (the camera program has already been modified accordingly, so rather than muck about with the original camera FB I've taken a copy of it and stripped it to the bare bones and call it in the Step (which was previously an unused Reserve Step) immediately following the camera test.

The input data of the Cell address gets modified from "G107" to "GVG107 CRLF" (GV = Get Value) and this STRING gets sent to the camera.
 
Here is an example of passing an array of chars to a function. The array is declared in static data so you can initialse it there.

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

VAR_INPUT
  CellString : ARRAY  [1 .. 6 ] OF CHAR ; 
END_VAR
BEGIN
NETWORK
TITLE =
	  L	 #CellString[1]; 
	  L	 #CellString[2]; 
	  L	 #CellString[3]; 
	  L	 #CellString[4]; 
	  L	 #CellString[5]; 
	  L	 #CellString[6]; 
END_FUNCTION

FUNCTION_BLOCK FB 2
TITLE =
VERSION : 0.1

VAR
  APieceOfString : ARRAY  [1 .. 6 ] OF CHAR  := ' ', ' ', 'G', 'V', '0', '1'; 
END_VAR
BEGIN
NETWORK
TITLE =pass ann array of chars
	  CALL FC	 1 (
		   CellString			   := #APieceOfString);
	  NOP   0; 
END_FUNCTION_BLOCK
 

Similar Topics

While trying to download an FC to a Siemens plc CPU315-2DP , we are getting the following error . What does it mean ? How to solve this problem ...
Replies
8
Views
3,140
Now that my program to save the maximum values of my analog inputs is actually working, we come to the next problem - how to access the data for...
Replies
15
Views
9,313
is there any free trial version available for step7 professional and wincc comfort v17. i searched and downloaded TRIAL Download STEP 7...
Replies
1
Views
90
Hello. I need your help. I work at STEP7. There are two CPU 317-2 PN/DP controllers (317-2EK14-0AB0), working on PROFIBUS, as Master (CPU_1) and...
Replies
6
Views
201
This is the first time I am working with Simatic Manager Step7 as I started my siemens journey with TIA which is pretty easy and do a lot of stuff...
Replies
3
Views
193
Back
Top Bottom