Count down subtract continue

All variables in the temp area are not initialised or remembered between calls. You are using TEMP0 as if it is.
 
dahnuguy said:
This is not a big issue as far as getting this FC1060 to work. The issue is WHY does it not work. So if I know why this is not allowed I can apply that information to other situations.

I tried lots of different combinations, IN_OUT, STAT, etc.

It seems to me like it should at least work in a FB with a DB assigned.

SO maybe I have some other issue all together, I don't know.

The program you sent in the picture does not work because you are using a temporal variable to be decremented. This variable is initialized each time you proces the function. Instead of TEMP0 you should use an IN/OUT variable, because you are reading and writing values in it, like in the pictures I'm sending.
 
clemens said:
The program you sent in the picture does not work because you are using a temporal variable to be decremented. This variable is initialized each time you proces the function.

Just a small correction, the temps are not initialised each time you process the function.

The memory area that the temp used is a scratch flag area, so other functions may have used it, the fact is a temp BOOL for instance can be 'ON' or 'OFF' at the start of a block, it's start state may change from scan to scan depending on if it was used elsewhere.

Its condition in indeterminable at the start of the block call.
 
You are completely right. What I was trying to tell is that you can't expect a value you stored in one cycle to be there the next cycle.
 
just updating an old thread, skip it if it bugs you

Why have you used a function block (FB) as opposed to a function (FC) ?

I now understand your question and just bumped into this thread again.

I used an FB because I stored all the current and previous levels in the instance DB.

I know some people who use an FC with a DB to store variables and they think that is better than using a FB with instance DB.

I like using a FB, it generates the DB for you and there are several neat ways to use the instance DB in the code.

And FBs allow ANY pointers as inputs and some inputs work differently or not at all in FCs.

I understand why now, but back then it was all very irritating.
 

Similar Topics

I would like to have my Micro820 send a modbus message every first of the month just to show the system is up, alive and running properly. I don't...
Replies
6
Views
1,999
Hi All, Can this be done ? I looking at writing code for "stand alone" Micrologix500 (No other control purposes intended) - Trying to track...
Replies
3
Views
2,497
I am trying to set up a timer to count down from an input time in minutes to zero. Looking through the CCW software there is a function block to...
Replies
5
Views
2,606
hi all, i have 16 lines here and almost all are identical. each has a steel seam belt to transport product on. each belt stretches and must be...
Replies
8
Views
2,369
I am more used to RSLogix 500 programming, and while I have been doing it a little while I know I still have a lot to learn. The test engineers...
Replies
4
Views
2,208
Back
Top Bottom