Which instr is better ADD or CTU in SLC 5/05

AB2005

Member
Join Date
Nov 2006
Location
Lahore
Posts
318
Dears

I have been programming with SLC5/05. Here is an input which freq is almost 5-8c/s and connected with PLC input card 1747-IB32. For count up, which instruction is better, ADD or CTU? If I program the both instructions, i found a difference between accumulated value of both.
 
Do you use a one-shot prior to the ADD instruction? The CTU has a built-in one-shot on it's count input.

What is the discrepancy? Which count's more? Is the difference consistent?
 
as my distinguished colleague rdrast has mentioned, there is a built-in "one shot" function for the CTU - but there can be a difference in the operation of that built-in "one shot" and the operation of a regular OSR "one shot" particularly when the processor first goes into the Run mode ...

also ... how high are you counting? - and how - and at what point - do you RESET each of the two "counters" ? ... also ... in the ADD type counter are you using an N-type integer - or an F-type floating point location to hold the value? ...

if you'll answer these questions - and those from rdrast - we should be able help you sort this out ... and most important - can you post your RSS program file? ...
 
1)[FONT=&quot] [/FONT]Yes, I am using OSR inst in series of ADD.
2)[FONT=&quot] [/FONT]The input address is same but the accumulated value in ADD always increases time by time than in CTU.
3)[FONT=&quot] [/FONT]The max frequency of input is 26HZ.
4)[FONT=&quot] [/FONT]I am using F integer in ADD (ADD 0.1247 F8:0 F8:0) which accumulates max 4millions and resets after month end.
5)[FONT=&quot] [/FONT]In CTU (say C5:0) Instruction, after 30000 counts, counter resets and Add 1 in an Integer. Normally, after 2.5sec time interval I calculate as (CPT F8:1 ((N7:0 * 30000) + C5:0.ACC)) * 0.1247). I found F8:0 of ADD > F8:1 of CPT.

Hope this info help you.
 
Since you are adding floats, then the total is accumulating rounding errors, therefore your second method of adding integers and doing the scaling to a float at the end of the calculation will yield superior results.

It isn't an issue of CTU vs OSR+ADD, rather an issue of floating point accuracy that is making the difference in your case.
 
yes, my distinguished colleague OkiePC has nailed why the numbers come out "different" ...

if you were to use the ADD to "add one" each time it "counts" and THEN/AFTERWARDS do the math calculation on that accumulated value, then you should get the same results with the ADD arrangement as with the CTU ... but - just remember that with floating point math in a PLC, there are usually some rounding off errors - so that EITHER WAY the final mathematical value that you're calculating/computing might not always be precisely "correct" ...

in other words, NEITHER of the methods you've listed might be 100% correct - but they might still be "close enough" to work in your application ...
 

Similar Topics

what is the s: instruction in logix pro 500? newbie here
Replies
4
Views
1,588
Quick question for you guys. I'm a little confused about something. I have a 1762-IF4 analog module and a pressure switch wire to it. The...
Replies
2
Views
1,947
Hey guys. I cannot figure out how to use a FFL function inside a aoi.. The control structure seems not to working.. I testet the code outside...
Replies
2
Views
3,501
can any body tell me abt BSL instruction in Rslogix5000?purpose of "length" and "control".i knw abt "sourcebit" and "inputvalue"
Replies
1
Views
1,686
I'm just getting started with ControlLogix (V17) and am trying to create a very simple Add-On instruction, using Structured Text, that increments...
Replies
2
Views
2,156
Back
Top Bottom