Printing CITECT .dbf file as trend

Couple of things:

In your Bed1Trend() your missing your parameters in the StrToTime call

Time() is a function and should be called as a function rather than a variable so add some brackets in both Bed1Start and Bed1Trend

If your tag is defined on a disk device you don't need to instantiate it in your code as an INT. Not sure if that is a problem but anything declared in a function normally won't be accessible to other functions.

Using the disk devices can be annoying with the addressing. I never worked out a good way to know which addresses are used but in newer versions of citect (2016 and above) the tag editor makes it a bit more obvious because you can sort by ascending and see the i2, i3, i4 etc in order. To be safe choose a high number maybe i200 or something as your address or depending on how many tags there are scroll through and find a gap

Alternatively you can store the tag in an actual PLC which might be easier.
 
Sorry, I missed some of the formatting when I typed it out - I'm unable to copy code to USB and don't have network access either, but that's a different story.

The code in Bed1Start is now:

Code:
FUNCTION

Bed1Start()

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

END

Bed1StartTime is also now a variable tag in a PLC type INT address D1250, but this value doesn't update when the code is called.

The code in Bed1Trend to do with the times and dates is formatted as above also.

Sorry for being a pain on this, I don't have CITECT training and I'm not sure how to write any debugging code and what my options are to find out what's not executing properly.

Thanks for the help
 
How are you running the code? Best way is to get back to a very simple test page with just a button and a label. Make the button run your function and the label display your tag.

If it's not updating, change the button to just make the tag = 50. If that is updating at least your tag is OK and it's something with your code. Citect doesn't have the best debugging but you can step through parts of cicode.

Also I can't remember if this is the case but with some languages I have used you can call a function as an input to a function. IE can't do:

StrToTime (Time())

But can do

int iTime = Time();
StrToTime(iTime);

Can't remember if Cicode is like that but it can help because you can display the interim steps on labels as well
 
So, the code works, apart from the Bed1Start.

It uses the same code for the StrToDate as Bed1Trend, so I know that code works.
I know the function gets called because I tried Bed1StartTime = 10.

I've tried the tag Bed1StartTime as and INT on the PLC and Disk device with no success. As a STRING type, I get a type mismatch error.

I'm unsure now what I need to do to get the variable to be the value and type I need it to be
 
With your Bed1StartTime Disk IO tag, assign it as a LONG, an INT is not going to hold the value. The convention for addressing of Disk IO is to have the letter represent the data type, so D1250 for a Digital, R1250 for a real and I1250 for an INT etc.

For your bed 1 start time you seem to be concatenating 2 values to try and get the current time, there is a value for the current time so just use that.

Code:
FUNCTION Bed1Start()
Bed1StartTime = TimeCurrent();
END

For the TrnPlot() function you seem to be getting confused with the "iTime" parameter. This is basically where you want the trend to end not the actual span, which would be the current date/time. Then using the period (time between trend points) and amount of samples that will give you your starting point.
For the period, in the sample code below i have just used the period from the first trend pen. If you put a 0 in for the period in the TrnPlot() function it will do the same.

Code:
FUNCTION Bed1Trend()
INT iStopTime;
INT iSpan;
INT iSamples;
INT iPeriod;

iPeriod = TrnInfo("Bed1Zone1",2) // Grab the configured trend period value from tag1
iStopTime =  TimeCurrent()); //Current time
iSpan = (iStopTime - Bed1StartTime);
iSamples = (iSpan/iPeriod);

TrnPlot("\\wagausprint01\Follow Me Printing", iSamples, iStopTime, iPeriod, "Bed 1 Steam Chart", 0, "Bed1Zone1", "Bed1Zone2", "Bed1Zone3", "Bed1Zone4", "", "", "", "", 1, "Bed 1 Curing Trend", 0, 70, 0, 70, 0, 70, 0, 70);

END

That should work, haven't tested or checked for typos etc. If you have issue post back and we will sort it out.
 

Similar Topics

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
116
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
322
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,544
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,534
i have FactoryTalkView Studio ME ver 12; i have a project with more than 40 displays. 1) How to print the entire project into a pdf. 2) I need to...
Replies
3
Views
755
Back
Top Bottom