Printing CITECT .dbf file as trend

downriver_bob

Member
Join Date
Nov 2017
Location
Gundagai
Posts
17
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
 
As a once off adhoc type thing or frequently?

You can download a dbf viewer or a dbf plugin for excel and then print from excel. Easiest way if you only want to do it once or twice
 
As a daily report type of thing. Currently the data is saved to the .dbf and then opened in excel, a macro run, and the resulting graph printed and the file then moved to another folder. I basically want to automate that process by printing the trend straight from CITECT.

The data point is a trend tag, and also logged in the.dbf. The starting and ending points change daily depending on production, so I can't use a time based trigger, but there is events that trigger, I'm just not quite sure how to initiate the print when the end of the cycle is triggered, to print from the start to the end of the cycle
 
What happens at the end of a production run? Do they do anything in Citect that stops the run?

If you have a tag that transitions when production is finished you can trigger an event based on the tag value and then set the tag back to 0 at the end of the cicode function. Our operators change the line from Product 1 to <no product> at the end of the day when they finish and we trigger some things off that.

Then all you need to do it have some tags that hold the start time and the end time, update them in the cicode event that runs, and use the normal trend print functions
 
Yes, they stop the run with a button in CITECT.

What trend print functions are used for this? I've looked at the CITECT help and I don't quite understand how to specify a start and end time. What you have explained is exactly what I was thinking, I just don't know what commands to use to generate the trend.

Thanks
 
Thinking back to a previous factory i worked at.. I think that they never ran Citect as a service. And so the event would run on the server instance, navigate to a trend page and then use TrnPrint.

Alternatively you can use TrnPlot which I don't think uses the context of a page but I don't think I have used it before.
 
Thanks for the help so far, I've got TrnPrint working to a point, but nothing with TrnPlot.

TrnPrint function works if I have the plot setup display enabled, if it disabled nothing happens

TrnPlot just seems to hang when it is called and nothing happens.

TrnPlot would be the preferred method, I have attached my code below, what am I missing here?

Code:
FUNCTION
TrendTest()
INT Time;

Time = StrToDate("1/10/19") + StrToTime("05:00:00");

PageDisplay("Trend")

TrnPlot("\\wagausprint01\Follow Me Printing", 20, Time, 10, "Bed 1 Steam Chart", "Saw1_transfer_raised", "Bed3Zone2", "", "", "", "", "", "", 0, 1, "Bed 1 Curing Trend", 0, 50, 0, 50);

TrnPrint("\\wagausprint01\Follow Me Printing", "Trend Title", 22, 1, 0)

Trend_Test_Trigger = 0;

END
 
Can you create an integer and assign it the error code like:
INT iError;

iError = TrnPlot(blah blah);

Then check the value of iError.

Also it looks like maybe you have an extra argument in your function call.

TrnPlot("\\wagausprint01\Follow Me Printing", 20, Time, 10, "Bed 1 Steam Chart", "Saw1_transfer_raised", "Bed3Zone2", "", "", "", "", "", "", 0, 1, "Bed 1 Curing Trend", 0, 50, 0, 50);

Should be:
TrnPlot("\\wagausprint01\Follow Me Printing", 20, Time, 10, "Bed 1 Steam Chart", "Saw1_transfer_raised", "Bed3Zone2", "", "", "", "", "", "", 0, "Bed 1 Curing Trend", 0, 50, 0, 50);

For black and white or

TrnPlot("\\wagausprint01\Follow Me Printing", 20, Time, 10, "Bed 1 Steam Chart", "Saw1_transfer_raised", "Bed3Zone2", "", "", "", "", "", "", 1, "Bed 1 Curing Trend", 0, 50, 0, 50);

For colour
 
I believe the ordering is correct. 0 being the AN, 1 being print in colour.

From the doco:

The AN of the chosen trend. If you enter 0 (zero), the display mode will default to 258. (This is the display mode that is passed into TrnGetTable() when it is called internally by TrnPlot().) If you call TrnPlot() from a report, you need to enter 0 (zero) here.

I'll be honest, I don't really know what it's all about, and I'm dubious I need it at all, but I can't be 100% if I tried without, so I'll do that first to be sure.
 
Looks like your ordering is not quite right. You need to go in order of the Syntax at the top of the help page, not the order of the descriptions below.
Code:
TrnPlot(sPort, nSamples, iTime, rPeriod, sTitle, AN, Tag1......Tag8, iMode,sComment.....

Don't follow the example either in that help page as it is wrong (missing the An) which is surprising that it hasn't been updated as it has been like that for a very long time.

You do need the 0 for the An, it tells the code to grab the trend type from the first trend pen instead of the trend page.
Code:
	/* TrnPlot can be called to print a Trend's data when we aren't even
	   displaying a Trend page. For this situation hAn is set to zero, and we
	   get the type from the first pen rather than the displayed page. */

So your code should look like this.
Code:
TrnPlot("\\wagausprint01\Follow Me Printing", 20, Time, 10, "Bed 1 Steam Chart", 0,"Saw1_transfer_raised", "Bed3Zone2", "", "", "", "", "", "", 1, "Bed 1 Curing Trend", 0, 50, 0, 50);
 
Thank you for that little bit of info. Reordered the code and it ran perfectly. Very frustrating when the "help" is incorrect.

Now I just have to figure how how I'm going to capture and specify the start & stop times of the trend since it seems only the end time can be specified and must be worked backwards from there.

Thanks again for the help and the replies
 
Good to hear.

With regards to the date manipulation Citect stores dates as seconds. So you can store the end time and start time, subtract the two which gives you the interval. Then you can just set the rPeriod and nSamples in TrnPlot such that rPeriod*nSamples = the interval from start to finish. Documentation says that the period doesn't need to be the same as the trend tag but if it's just one tag i would make them the same
 
Thanks for the replies so far.

It seems like everything will work, but I haven't been able to capture the start time. I have a code file that is called when the cycle is started consisting of:

Code:
FUNCTION

Bed1Start()

INT Bed1StartTime;

Bed1StartTime = StrToDate (Date(2)) + StrToTime (Time);

END

Which is then used after the cycle is stopped in another code function that is called:

Code:
FUNCTION

Bed1Trend()

INT StopTime;
INT Span;
INT Samples;
INT Period;

Period = 600;

StopTime = StrToDate (Date(2)) + StrToTime ();

Span = (StopTime - Bed1StartTime);

Samples = (Span / Period);

TrnPlot("\\wagausprint01\Follow Me Printing", Samples, Span, Period, "Bed 1 Steam Chart", 0, "Bed1Zone1", "Bed1Zone2", "Bed1Zone3", "Bed1Zone4", "", "", "", "", 1, "Bed 1 Curing Trend", 0, 70, 0, 70, 0, 70, 0, 70);

END

The variable "Bed1StartTime" is defined in CITECT as a variable tag on our "disk" device which is some type of file on the hard drive. I'm not too sure how to use this properly, how to ensure I'm not doubling up on addresses etc.

Can anyone point me in the right direction on this?

I also tried using the expression in Bed1StartTime as the action in an event but also didn't seem to grab a value.

Thanks
 

Similar Topics

Hi all, I am having issues accessing my Cimplicity software - the site code changed after re-install and I am no longer able to attain a new key...
Replies
10
Views
158
My company built a small test machine using a Micro800 PLC and CCW software. We chose the Micro800 because the machine is very simple. We are...
Replies
2
Views
139
I had a student fooling around with settings tonight, and now when I try to print a program ladder, each rung prints on a separate sheet. Too many...
Replies
9
Views
352
Looking to Print over ethernet with a 5069-L320ERMS3 Compact GuardLogix 5380 Safety Controller. Printer model yet to be provided. But a few...
Replies
5
Views
1,581
I have a customer who has 20 of our systems using PanelView Plus 7 Performance Series A terminals. With how hard it is to find printer nowadays...
Replies
4
Views
1,602
Back
Top Bottom