"Can anyone help me" sister thread

L D[AR2P#0.0]

Lifetime Supporting Member
Join Date
Nov 2006
Location
UK
Posts
6,694
Attached is a S7-300 project that flashes Q0.0 and has been run using PLC-SIM.
Which block would I need to modify and what would be the required changes to flash Q0.1 instead ?
 
S7 Pointers

Hi,
This Is The Modified Code Of FB1:
/////////////////////////////////////////////////////
OPN DB 2 // This Line Is A Myth
L #iCount
+ 1
T #iCount
TAR2
T #dwData
LAR1 P##iCount
A [AR1,P#1.3]
FP #bFlashEdge
JCN nofl
SET
S DIX 4.1 // Here Is The Trick
R DIX 4.2 // DIX 4.1 & 4.2 Will Make The Pointer Pointing To Q0.0 Rather Than DB0.0
L #dwData
LAR1
CAR
CDB
// AN #bFlasher // This Flashes Q0.0
// = #bFlasher

AN [AR2,P#0.1] // Here You Flash Q0.1
= [AR2,P#0.1]

CDB
SET
R DIX 4.1
S DIX 4.2
L #dwData
LAR1
CAR
nofl: NOP 0

This Is The Original Code :
OPN DB 2
L #iCount
+ 1
T #iCount
TAR2
T #dwData
LAR1 P##iCount
A [AR1,P#1.3]
FP #bFlashEdge
JCN nofl
SET
S DIX 4.1
R DIX 4.2
L #dwData
LAR1
CAR
CDB
AN #bFlasher
= #bFlasher
CDB
SET
R DIX 4.1
S DIX 4.2
L #dwData
LAR1
CAR
nofl: NOP 0


Using AR2(By Using CAR Instruction) In An FB Is The Most Confusing Thing In STL.
If You Have Any Question Just Send Me An E-Mail.

Regards

Bashier Wattad-Graeber
 
Last edited:
An interesting answer which achieves the correct end result but through incorrect analysis. (BWG - see your private messages)

Note that this is a made up problem for holiday amusement.
 
Last edited:
Ar2

I have spent exactly 1 minute to find out(in debug mode) where Q0.0 is accessed. thats why i didn't bother to analyse the rest of the program. I think got me wrong when i said using CAR instruction. This instruction was used just to hide the fact that AR2 was used as a pointer to Q0.0. The programmer has loaded the pointer in AR1 then swaped the contents of the registers using CAR.

Just To Correct My Analysis.


Using AR2 in an FB as a pointer to other memory (Proccess image) area can be confusing of sometimes a recipe for disaster and it will be hard to follow the PLC program. And bare in mind that when using AR2 as a pointer other than DB0.0 in an FB, access to IN/OUT/INOUT/STAT data in the opened instance DB can cause to data loss if AR2 wasn't restored with its original value at the entry point of the FB (i.e AR2=DB0.0 or DBX.0 in case of multi instance inside a multi instance) .Instead AR1 is usually used to point to other memory areas.
If for example the first input in an FB is a boolean input and you use AR2 to point to a boolean STAT in the same FB, after saving the FB, the address pointed by AR2 will show the address of the first boolean input in the FB :
i.e.
FB with boolean input X and 1 STAT Y

Before saving the code will look like this

L P##Y
LAR2
A DIX[AR2,P#0.0]
= Q0.0

After you save the FB the code will look like this :

L P##Y
LAR2
A X
= Q0.0
 
[QUOTE='L D[AR2,P#0.0]...this is a made up problem for holiday amusement.[/QUOTE]

BWG - you seem to have missed the point here....
(There have been a few of these 'fun only' posts over this holiday period)

If anyone else fancies having a go at this, BWG's post #2 isn't a complete spoiler as there is another solution....
 
BWG - Modify the original FB1 to replace

Code:
	 AN	 #bFlasher
	 =	 #bFlasher

with

Code:
	 A	 #bFlasher
	 =	 #bFlasher

If you were correct, Q0.0 would stop flashing.
 
Phew - just made it with only one more day of holiday left :)

Well done Bratt and krk (who, incidentally, submitted the correct answer 90 mins after I posted the problem).
 
Dear L D[AR2,P#0.0]
Iam completely bowled out with your puzzel
Iam looking at this for a day now and still with no clue
What I can make out is that you can change frequency by adjusting the offset in A [AR1,P#1.3].
Also i added the line S DIX 7.0 which brought q0.1 into picture but it was now not flashing.{I reseted this bit but no use}
CDB is what making all the difference. What I can guess is that CDB makes the IDB #bFlasher into DB which is then linked with Q0.0, and hence the flashing, but cant see the clear relation.
Can you push me forward without disclosing the whole secret??
There are so many questions
Thanks for this wonderful assignment
 
Open FC1 and then monitor it to see if it's being executed.... then do the same with FC2
 
Last edited:
God
FC2 to FC19 is getting executed somehow.Cant believe it.
Call structure shows OB1 is calling all FC's.
Any Sufficiently Advanced Programing is Indistinguishable from Magic.


Ok working will come back.........

 

Similar Topics

I have an old PLC (circa 2007) consisting of Telemecanique/Modicon/Schneider Electric devices. The system has developed errors and unfortunately...
Replies
2
Views
230
Replies
49
Views
10,754
Hello, I am trying to figure out how to create / write / delete a .csv file on the SD card of an Allen Bradley PLC. There is a sample project...
Replies
1
Views
1,429
I have attached a picture. I just need to know if the option I've chosen is the correct one and if possible an explanation too. thanks
Replies
14
Views
3,649
Dear sir. i have one Automation Direct hmi, if you have the CMORE Programming software,i will send you .eap file in email, can you please...
Replies
3
Views
2,439
Back
Top Bottom