How to use Trend in Citect/calculate average

joigunni

Supporting Member
Join Date
Jan 2011
Location
Iceland
Posts
52
I have a sensor that detects the speed of conveyor belt, by counting a pulse. On the assembly line come bottles at regular intervals and which are counted with other sensors, so that each time a bottle passes I got a pulse from the bottle and another from the assembly line. If there is a one missing bottle in the line I get a pulse from the assembly line, but not from a bottle detector, then I can calculate the percentage efficiency “Percentage x conveyor belts-pulse = bottle-pulse”

Tag_Average = (Tag_conveyor*100)/Tag_Bottle


No problem. But if I want to get the average of the last 100 pulse from the assembly line, every time, then things get worse, is there a simple solution to this.
This would be no problem if I could use the trend and trigger it "sample period" with conveyor belts detector and not by time, and the trend has to move at the same rate as the pulse from the assembly line, maybe it is possible, but I can’t find it.



Something like that I think: :confused:

REAL TrendTable1[100];
FUNCTION prufa()
TrnGetTable ("Trend_Tag_Average",0,2,10,TrendTable1[0],0);
REAL Average
Average=TableMath(TrendTable1,100,2,0);
Tag_Average = Average
 
I've used something similar in the past:

FUNCTION getValue()
TrnGetTable("myTrend",0,1,100, myArray[0],0,0,"myDemo")

Minimum = TableMath(arrays, 100, 0, 0)
Maximum = TableMath(arrays, 100, 1, 0)
average = TableMath(arrays, 100, 2, 0)

END

This would provide Min/Max/Average.

myArray would be declared in Tags -> Local Variables

I would then use an Event that would refresh these values every second.

Seems to work.
 
Yes it works fine but don’t give me the actual average. I get the average of the last 100 time sample but not the last 100 pulse from the conveyor belt, it would be OK if the conveyor belt goes at steady rate, but for me it is not so, and sometimes it’s stops or go very slow. :(
 
why not calculate Pieces per Minute for both. If you take the time between pulses and divide into one minute then you get PPM. Then you would know conveyor PPM vs. bottle PPM. I could do this in ladder logic but not statement. Just an idea. The attachment is a example from a previous post about RPM for a new user that's why the explaination of logic but the same logic applies to PPM. Please don't take offense.
 
Last edited:

Similar Topics

I am using VijeoCitect v7.5 on Desktop having Windows-7 OS. While viewing trends, it is observed that trend is not appearing continuous and value...
Replies
1
Views
551
Hi everyone, I'm new at programming using citect and I'm trying to do a simple programm in cicode where i have a device that resgisters values...
Replies
2
Views
1,852
Recently we lost our recorded data from all our popup trend screens. The values are still shown just not the pen lines. Any help would be greatly...
Replies
5
Views
2,388
Hi, I have a CITECT system that records data into a .dbf file and would like to create a trend from the data and print it. Can anyone help? Thanks
Replies
19
Views
3,010
Hello I am using citect 7.40 and in this i want to popup an specific trend using Trendpopup() by clicking on a button. when i used this function...
Replies
3
Views
2,025
Back
Top Bottom