TienNguyenD

Need a help for FC Step 7 s7 300 LADDER logic

12 posts in this topic

Excuse me.

I have got some problems for FC Step 7 s7 300 LAD,

When FC is running, ex: Q0.0 = 1;

then I break the power flow this FC, but Q0.0 still = 1.

so how can I do to turn off All components in this FC while i break it? ( its mean Q0.0 change 1 to 0 )

Share this post


Link to post
Share on other sites

If the FC isn't running, it can't execute code - including turning outputs off.  Not sure how this would work inside the FC.

You could add an input to the FC to act as an "Enable" and let the FC run unconditionally.  Have code inside of the FC clear what you want if the "Enable" signal goes low.

Good luck.

2 people like this

Share this post


Link to post
Share on other sites

Something like this should work.  If the enable input isn't on, it will jump to JOVR and reset Q0.1.  If the enable signal is running, if I0.0 and I0.1 are ON, Q0.1 is on, else off.

I don't have a way to test it, but it should be close.

resetcode.JPG

2 people like this

Share this post


Link to post
Share on other sites
On 2/23/2016 at 10:33 PM, TravisPedley said:

Something like this should work.  If the enable input isn't on, it will jump to JOVR and reset Q0.1.  If the enable signal is running, if I0.0 and I0.1 are ON, Q0.1 is on, else off.

I don't have a way to test it, but it should be close.

resetcode.JPG

With LADDER logic :

Someone suggested that I use : RET command
but I don't know how to use.
 
My problem is:

FC.jpg

FC2.jpg

FC3.jpg

FC1.jpg

Share this post


Link to post
Share on other sites

Like I said earlier, your FC cannot process anything if it isn't running.  That means turning outputs ON or OFF.  If I0.0 is off, then the code in FC1 isn't being scanned, which means that the outputs are left in whatever state they were last in.  If you must do it in ladder, then do it like the attached picture.  will get cumbersome if you have a lot of outputs, but that's what you have to do.

 

 

resetout.JPG

1 person likes this

Share this post


Link to post
Share on other sites

Or do it like this.  When you expand the code, just make sure the N.O. Enable is in the rung that fires the output.  The FC will scan nonstop assuming it is called in OB or equivalent subroutine.

This will ensure that when you want the output to be off because I0.0 is off, it will do it.

 

enable1.JPG

enable2.JPG

1 person likes this

Share this post


Link to post
Share on other sites
8 hours ago, TravisPedley said:

Like I said earlier, your FC cannot process anything if it isn't running.  That means turning outputs ON or OFF.  If I0.0 is off, then the code in FC1 isn't being scanned, which means that the outputs are left in whatever state they were last in.  If you must do it in ladder, then do it like the attached picture.  will get cumbersome if you have a lot of outputs, but that's what you have to do.

yes, i think so. Thank you

 

resetout.JPG

 

Share this post


Link to post
Share on other sites

Exactly:

When you switch off the FC, all the output inside the FC will remain activated if they were activated in the momento that you deactivate the FC. This is why your Q0.0 will remain activated.

You must resete the Q0.0 outside of this FC1 when you turn off the FC1.

 

--------------------------------------------------------------------------------------

www.tecnoplc.com

Share this post


Link to post
Share on other sites

I would not recommend using conditions to enable a block call. It can cause all sorts of problems, including what you have experienced. And has the potential to create some incredible troubleshooting headaches. This applies not just to outputs but any W (write) instruction, including counters, timers, bits, bytes, words, double words, M addresses, and DB addresses. Instead, I would write two additional rungs of logic and include them at the very beginning of your FC1 module. It would look something like this:

56fc47c9340c4_FC4BlockEndorRET.png.88c60

NW3 would be replaced by your existing logic in FC1.

Here's what happens:

Program scan of module code begins.

NW1 is evaluated: if input I0.0 is FALSE then Q0.0 will be reset. If input I0.0 is TRUE then Q0.0 will not be changed - regardless of what its current state might be (TRUE or FALSE).

Program scan continues to NW2 - regardless of the state of I0.0.

NW2 is evaluated: if input I0.0 is FALSE then the RET instruction is executed and the program scan of the module is immediately terminated. No additional rungs are evaluated. If input I0.0 is TRUE then the RET instruction is not executed and the program scan continues to NW3 (and any other networks that might exist).

Writing your logic in this manner allows output Q0.0 to be toggled ON or OFF from inside the same module instead of writing it ON from this module and writing it OFF from another module.

The RET instruction may be found in the overview tree:

56fc4b2016d8e_FC4OverviewTree.png.a5aafb

There are other ways to achieve the same result but I think this is the easiest understood by beginners.

Edited by pop29684
1 person likes this

Share this post


Link to post
Share on other sites

Hi,

I was troubleshooting a problem on Siemens CPU313C. It was showing wrong Pressure value on HMI all of a sudden. I checked the transmitter, it was oKay. Then the wires found OKay. Then I opened the logic and find the input variable and checked the raw data. It was also fine. There i saw that there was a custom FC1000 to scale the input. It was outputting the wrong value i.e showing half value of scaled. Suppose if the scaled value should be 200 then it is showing 100. When I opened the function following code is shown. Can anyone help what type of language is this and what does this mean??

fc1000.jpg

Share this post


Link to post
Share on other sites

OK, this code is written in STL language.  Line by line:

L #INPUT - load the value of the parameter "INPUT" into ACCU1 (accumulator 1)

ITD - convert the value in ACCU1 from INT (integer) to DINT (double integer), and store in ACCU1

L L#-100 - load the value of -100 into ACCU1, the previous value in ACCU1 moves to ACCU2 (in this case #INPUT which was converted to a DINT)

>D - check if the value in ACCU2 is greater than ACCU1 (in this case #INPUT > -100)

JNB n01 - jump to label n01 if the above logic is false (#INPUT is not >  -100)

L #INPUT - load the value of the parameter "INPUT" into ACCU1

ITD - convert the value in ACCU1 from INT (integer) to DINT (double integer), and store in ACCU1

DTR - convert the value in ACCU1 from DINT (integer) to REAL (floating point), and store in ACCU1

L #MAX - load the value of #MAX into ACCU1, the previous value in ACCU1 moves to ACCU2 (in this case #INPUT which was converted to a REAL)

*R - multiply ACCU2 by ACCU1 (#INPUT * #MAX) store the result in ACCU1

L 2.7648e+004 - load the value of 27648 into ACCU1 - this happens to be the maximum integer for S7 analog input values

/R - divide ACCU2 by ACCU1 (#INPUT * MAX / 27648) store the result in ACCU1

T #output - transfer ACCU1 to the parameter #output

JU n02 - jump unconditionially to n02

n01: L 0 - label is n01, which is used for the jump statements, load the value 0 into ACCU1

T #output - transfer ACCU1 to the parameter #output

= #alarm - like a coil in LAD language the value of #alarm is based on previous logic (in this case the >D instruction - in this case #INPUT > -100)

n02: NOP 0 - label is n02, which is used for the jump statements, NOP 0 is a no operation instruction (does nothing)

I think the "= #alarm" instruction is wrong.  I would use ""SET" on one line, then S #alarm" here, and use the lines "SET" then "R #alarm" just after the "JNB n01" line.

Basically it is checking if the input is greater than 100, if it is not, it outputs a value of 0 and turns on the alarm bit.  If it is greater than -100, then output the result of INPUT * MAX / 27648.

Edited by sigmadelta

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now