Tough question of Siemens programming

AlecTek

Member
Join Date
Sep 2010
Location
Vancouver
Posts
155
Hi,

I'm wondering how to program a function that has an integer(or word) input but return the value contains in the address of the input.

for example, I have a RTD with address of 512, my function gets the input of 512 and gives back the temperature of PIW512.

----------------------
Function getRTD: int;
Var_Input
Addr:int;
end_Var

getRTD:=???????;
End_function
-----------------------

It would be fine if the program is written in LAD or STL. But if you know how, please also tell me how to return a digital I/O's value (probably in byte or word). Thanks!

Best Regards
 
in the block create 4 TEMP's

PerPointer Type = DWORD .. Pointer
IntVal Type = WORD .. Temp location for value in PIW
Ret_Stat Type = WORD .. For return status of scale
Read_Val Type = REAL .. For read value


Code:
L #Addr
SLD 3
T #PerPointer

L PIW[#PerPointer]
T #IntVal

Call SFC105


Use Intval as input for SCF105, would also need inputs for max and min values
 
In SCL:

Code:
FUNCTION getRTD : INT
VAR_INPUT
    Addr:INT;
END_VAR
getRTD := WORD_TO_INT(PIW[Addr]);
END_FUNCTION
 
in the block create 4 TEMP's

PerPointer Type = DWORD .. Pointer
IntVal Type = WORD .. Temp location for value in PIW
Ret_Stat Type = WORD .. For return status of scale
Read_Val Type = REAL .. For read value


Code:
L #Addr
SLD 3
T #PerPointer
 
L PIW[#PerPointer]
T #IntVal
 
Call SFC105


Use Intval as input for SCF105, would also need inputs for max and min values

In SCL:

Code:
FUNCTION getRTD : INT
VAR_INPUT
    Addr:INT;
END_VAR
getRTD := WORD_TO_INT(PIW[Addr]);
END_FUNCTION

Thank you very much for your help. I had a few days off so I didn't try those methods and response.

I got that SFC105 is the system funtion for the address-value conversion from Peter, but SCL seems much easier to me, so i tried it today and it works well on PIW, IW and QW.

L D[AR2,P#0.0], Can you show me how to get the value of PQW? My SCL can only do
PIW[Addr]:=WordVar;
but not
WordVar:=PIW[Addr];

Thank you guys again!
 
Once came across something like this below.
Indirect adressing of IO points. It confused the s..t out of me as the IO used that way didn't show up in the x-ref



L #LSL_Addr_Byte
SLD 3
L #LSL_Addr_Bit
+D
LAR2
A I [AR2,P#0.0]
....
 
Thank you for discussing this question.

I read some documents, and I understand the point of HenkieD's program. The one by my hand, called Pointers and Indirect Addressing in S7 PLCs, says that an area pointers is a 32bits struct which include 8 bit type bits, and byte address bits, and 3 bit address bits.

for example, P# M12.3 = 10000011 00000000 00000000 01100011

Therefor, that program loads an address, shift left for 3 bits, then add the bit address (3 bits). AND IT SHOULD ADD THE AREA TYPE BITS (first 8 bits), then form an address pointer.

I am not sure if the instruction A I [AR2,P#0.0] is to read the Analog input of the pointer, but that is how it works.

Anyway, i tried with SCL to read the area pointer of PIW512, but failed. I don't know if area point is only for STL, but since I can use PIW directly in SCL, i stopped working on it.
 

Similar Topics

Good Morning, I have a customer who would potentially like to install tail roll sensors on their conveyors in their quarries. The plc will monitor...
Replies
14
Views
4,143
Someone had posted a touch screen here a couple weeks back that looked to be real tough. It even took a shotgun blast. I can't seem to find that...
Replies
1
Views
1,568
Not sure why I'm having a tough time but all my logic seems to be right but its not working. I'm trying to get the LEN function to get a value...
Replies
0
Views
1,497
Dear guys, the FIFO is a pain for me. I am using siemens s7 to program it. When I use FC84 ATT table to store the data, it can work properly. But...
Replies
7
Views
4,489
Well... let's see what you can come up with... We have a hydraulic press. The hydraulic pressures contained in two accumulator systems close the...
Replies
58
Views
34,258
Back
Top Bottom