Is there any SFC/SFB/FC/FB ready made in siemens for my application?

drspanda

Member
Join Date
Oct 2005
Location
Damanjodi
Posts
155
Dear Experts,

My Task:

An analog input is to be monitored for 30min by the plc and its highest value during this 30min is to be stored at a particular location. After 30min the process should repeat.

I want to know is there any SFC/SFB from siemens....Otherwise I shall try to solve the problem myself.
 
I would solve the problem myself. What is the conversion time for the analogue input ? Make sure you sample it quickly enough so as not to miss any values.
 
I hate to be a jerk...but it sounds like 8 minutes of work.

Scale Analog, compare vs largest value to date, replace if greater, after 30min move to Final value, reset timer and largest value.

Write in in a FB and re-use as required.
Nick
 
Ok it took 12 minutes ;-) Paste into source block and generate FB. Written in LAD so a little long winded but easier to follow
Nick


 
FUNCTION_BLOCK "Largest_Analog"
TITLE =
VERSION : 0.1

VAR_INPUT
Raw_Analog : INT ;
Max : REAL ; //See FC105
Min : REAL ; //See FC105
Bipolar : BOOL ; //See FC105
END_VAR
VAR_OUTPUT
ScaledValue : REAL ; //Scaled Analog Value
LargestV : REAL ; //Largest Value for last period
END_VAR
VAR
Scaled_Value : REAL ;
LargetsSoFar : REAL ;
LastLargest : REAL ;
ErrorWord : WORD ;
TIM1 : "TON";
Flag : BOOL ;
ErrorFlag : BOOL ;
END_VAR
VAR_TEMP
Error : INT ;
END_VAR
BEGIN
NETWORK
TITLE =Convert Analog Value
A #Bipolar;
= L 2.0;
BLD 103;
CALL "SCALE" (
IN := #Raw_Analog,
HI_LIM := #Max,
LO_LIM := #Min,
BIPOLAR := L 2.0,
RET_VAL := #ErrorWord,
OUT := #Scaled_Value);
NOP 0;
NETWORK
TITLE =Check for Error
A( ;
L #ErrorWord;
T #Error;
SET ;
SAVE ;
CLR ;
A BR;
) ;
A( ;
L #Error;
L 0;
<>I ;
) ;
= #ErrorFlag;
NETWORK
TITLE =If no error move out scaled value. Otherwise move zero out
A( ;
A #ErrorFlag;
JNB _001;
L #Scaled_Value;
T #ScaledValue;
SET ;
SAVE ;
CLR ;
_001: A BR;
) ;
NOT ;
JNB _002;
L 0.000000e+000;
T #ScaledValue;
_002: NOP 0;
NETWORK
TITLE =Check for largest
A( ;
L #Scaled_Value;
L #LargetsSoFar;
>R ;
) ;
JNB _003;
L #Scaled_Value;
T #LargetsSoFar;
_003: NOP 0;
NETWORK
TITLE =Oscillator
AN #Flag;
= L 2.0;
BLD 103;
CALL #TIM1 (
IN := L 2.0,
PT := T#30M,
Q := #Flag);
NOP 0;
NETWORK
TITLE =Move Value and clear
A( ;
A #Flag;
JNB _004;
L #LargetsSoFar;
T #LastLargest;
SET ;
SAVE ;
CLR ;
_004: A BR;
) ;
JNB _005;
L 0.000000e+000;
T #LargetsSoFar;
_005: NOP 0;
NETWORK
TITLE =
L #LastLargest;
T #LargestV;
NOP 0;
END_FUNCTION_BLOCK


 
Last edited:
Errors listed...

The below are the errors generated after compilation:
ERRORS.JPG


I have followed this way:

1.used CPU hardware clocks 0.1sec.

2.positive rising edge as negative falling edges are used for the above clock pulse for example M0.1...

3. positive shot for M0.1 -> M1.0 and negative shot for M0.1 ->M1.1 are used.

4. in this way i am trying to sample the analog data at M1.0 and M1.1.

5. compare the data from step 4.

6. store the largest in MW100.

But I am not able to solve the problem because everytime MW100 is changing...I need some dynamic storage locations...Need help.
 
In the supplied source code, replace "Largest_Analogue" with FB100 (or whatever FB you want it to be called). Replace "SCALE" with FC105. You need to have FC105 present in your blocks folder. The code will then compile.
 
Errors reduced...

L D[AR2 said:
In the supplied source code, replace "Largest_Analogue" with FB100 (or whatever FB you want it to be called). Replace "SCALE" with FC105. You need to have FC105 present in your blocks folder. The code will then compile.

Thank you verymuch and I have done but i could observe some errors in line:

TIM1 : "TON"; and

CALL #TIM1 (

I have tried to replace "TON" with T1 even then I got errors.

so, I need your suggestion.
 

Similar Topics

can anyone plz guide me some information about SFB AND SFC
Replies
2
Views
2,447
All I need some help, I need to read and write some data to a device on my Profibus DPV1 Network. The device in question is an Anybus Card...
Replies
3
Views
5,366
K
Hi all :) I`m working on a project and I need a time puls function: I`ll get a variable time cycle 0,01-30.sec from the operator, and i need a...
Replies
10
Views
6,466
K
Hey. If you haven't already read me, first time I'm building a full project on Rockwell PLC. I started building the sequences last week and I...
Replies
3
Views
127
Hi all. I'm building my first Grafcet using Logix, but I started from another project. From what we usually do with other PLC's, I was expecting...
Replies
3
Views
153
Back
Top Bottom