Sunteți pe pagina 1din 4

PLC S.net - Interactive Q & A > PLC S.

net - Interactive Q & A > LIVE PLC Questions And Answers > Step 7 pointers

View Full Version : Step 7 pointers


Alfbox

PDA

February 19th, 2006, 01:16 PM

Hi, I program S7-300 C PUs but I'm not skilled in it yet. Now I'm facing the problem with comparing static array values with dynamically changing values in a DB. I need it for evaluating errors of Simotion Safety unit. The codes of errors are stored in the array and the DB is a buffer of errors of the SSU. If a new fault occurs, the DB is changed. I don't need to compare the whole DB with the array in one cycle. I know I should use the pointers but don't know how exactly. How to reveal the cell of array by means of indirect addressing? How to increase the "cell number" in a loop? Does anyone know or can paste a link with help? Thanks a lot

PLucas Alfbox

February 19th, 2006, 02:05 PM

I am not sure if this is what you are after, but Siemens have a function called TBL_FIND, this is FC 86. It can be found in the block library, Standard library -> TI-S7 C onverting Blocks. This might be what you are after. Paul

jacekd

February 20th, 2006, 02:02 AM

Search this forum first (can you see the "Search" in menu up there ?). I'm sure this will bring you the answer.

SimonGoldsworthy Alfbox - please see below my implementation of the array operation B[n]:=A[m] (The arrays are assumed to be zero based).

February 20th, 2006, 06:08 AM

C ut and paste the code into your source folder and then compile it. Note then when monitoring blocks that use any pointers, you will not be able to 'see' the variables at the block call - just access them in another network. I've not done any checking to make sure the arrays are of the same type, but you should get the idea of indirect addressing (and any pointers !) FUNC TION FC 6 : VOID TITLE =Generalised Array element access, B[n]:=A[m]; VERSION : 0.1 VAR_INPUT A : ANY ; m : INT ; n : INT ; END_VAR VAR_OUTPUT B : ANY ; END_VAR VAR_TEMP iType : INT ; iDBNumber : INT ; dwAreaPointer : DWORD ; iSize : INT ; bBOOL : BOOL ; wWORD : WORD ; dwDWORD : DWORD ; byBYTE : BYTE ; END_VAR BEGIN

NETWORK TITLE =de-construct any pointer for input array L P##A; LAR1 ; L B [AR1,P#0.0]; L B [AR1,P#1.0]; T #iType; L W [AR1,P#2.0]; T #iSize; L W [AR1,P#4.0]; T #iDBNumber; L D [AR1,P#6.0]; LAR1 ; NETWORK TITLE = //open db if required L #iDBNumber; L 0; ==I ; JC indb; OPN DB [#iDBNumber]; indb: NOP 0; L #iType; JL iype; JU inon; JU iBol; //type 01= bool JU iByt; //type 02= byte JU iByt; //type 03= char (process as byte) JU iwrd; //type 04= word JU iwrd; //type 05= int (process as word) JU idwd; //type 06= dword JU idwd; //type 07= dint (process as dword) JU idwd; //type 08= real (process as dword) iype: JU inon; iBol: NOP 0; L #m; +AR1 ; A [AR1,P#0.0]; = #bBOOL; JU op; iByt: L #m; SLD 3; +AR1 ; L B [AR1,P#0.0]; T #byBYTE; JU op; iwrd: L #m; SLD 4; +AR1 ; L W [AR1,P#0.0]; T #wWORD; JU op; idwd: L #m; SLD 5; +AR1 ; L D [AR1,P#0.0]; T #dwDWORD; JU op; inon: JU exit; NETWORK TITLE =de-construct any pointer for output array op: L P##B; LAR1 ; L B [AR1,P#0.0]; L B [AR1,P#1.0]; T #iType; L W [AR1,P#2.0]; T #iSize; L W [AR1,P#4.0]; T #iDBNumber; L D [AR1,P#6.0]; LAR1 ; NETWORK TITLE = //open db if required

L #iDBNumber; L 0; ==I ; JC ondb; OPN DB [#iDBNumber]; ondb: NOP 0; L #iType; JL oype; JU onon; JU oBol; //type 01= bool JU oByt; //type 02= byte JU oByt; //type 03= char (process as byte) JU owrd; //type 04= word JU owrd; //type 05= int (process as word) JU odwd; //type 06= dword JU odwd; //type 07= dint (process as dword) JU odwd; //type 08= real (process as dword) oype: JU onon; oBol: NOP 0; L #n; +AR1 ; A #bBOOL; = [AR1,P#0.0]; JU exit; oByt: L #n; SLD 3; +AR1 ; L #byBYTE; T B [AR1,P#0.0]; JU exit; owrd: L #n; SLD 4; +AR1 ; L #wWORD; T W [AR1,P#0.0]; JU exit; odwd: L #n; SLD 5; +AR1 ; L #dwDWORD; T D [AR1,P#0.0]; onon: JU exit; NETWORK TITLE = exit: SET ; SAVE ; END_FUNC TION

Alfbox Thank you, I've been waiting for such an answer. Please, think it over prior offend someone.

February 20th, 2006, 11:12 AM

Search this forum first (can you see the "Search" in menu up there ?). I'm sure this will bring you the answer.

Alfbox Thank YOU Simon, you're realy nice guy. I'll try it ASAP. _____________________ Alf

February 20th, 2006, 12:51 PM

jacekd

February 21st, 2006, 01:51 AM

:offtop: Alfbox, I have no idea why you feel offended. This topic was brought up in great details on this Forum many times. If you don't even give a **** to find it and you're just waiting for a ready-made solution from someone else you shouldn't feel offended with my attitude. How ever this is my very private opinion and others may disagree.

Alfbox

February 23rd, 2006, 04:00 AM

Jacekd, I didn't mind if you have posted a notice...Guy, look through threads, I've spoted it there. Your sarkasm offended me. I have gone through before I posted the topic and haven't found nothing similar. There are tons of topics about pointers, I agree, so it is hard to find the exact one. My way of seeking something is.. look, look better, ask You are right..I was waiting for ready-made solution as the majority in the forum.. To answer someone is not compulsory. There are plenty of topics which have been described many times. ___________ Alf

jacekd

February 23rd, 2006, 04:58 AM

I took me few minutes to find answer to "How to reveal the cell of array by means of indirect addressing? How to increase the "cell number" in a loop?" on this forum. If that is what you call "hard" then pls excuse me.

Alfbox Jacek, no comment

February 23rd, 2006, 06:03 AM

Alfbox

March 1st, 2006, 07:21 AM

Hi, its me again. I had to learn a lot, gone through many threads to learn some facts about Step7 pointers. Finaly I was able to write my first STL function moreover with pointers. IT WORKS fine. If anyone need help with Simotion Safety Unit error evaluating, please contact me. Thank you all. PLC S.net really helps. :site: .

S-ar putea să vă placă și