beautypg.com

Campbell Scientific CR5000 Measurement and Control Module User Manual

Page 101

background image

Section 6. Data Table Declarations and Output Processing Instructions

6-7

WorstCase Example

This program demonstrates the Worst Case Instruction. Five type T
thermocouples are measured. The event is similar to that in the example for
the DataEvent instruction; the trigger for the start of a data event is when
TC(1) exceeds 30 degrees C. However in this example, the stop trigger is set
immediately true. This is done to set a fixed size for the event which can be
duplicated in the worst case tables. To use the worst case instruction with
events of varying duration, the event table size must be selected to
accommodate the maximum duration expected (or needed). The event consists
of 20 records prior to the start trigger and continues until 100 records
following the start trigger.

The ranking criteria is the number of readings following the trigger that TC(1)
stays above 30 degrees C. The greater the number the “ worse” the event.

Const RevDiff 1

'Reverse input to cancel offsets

Const Del 0

'Use default delay

Const Integ 0

'Use default Integration

Const NumCases 5

'Number of Worst Cases to save

Const Max 1
Public RefTemp

'Declare the variable used for reference temperature

Public TC(5)

'Declare the variable used for thermocouple measurements

Public I, NumAbove30

Declare index and the ranking variable

Units RefTemp=degC

'

Units TC=degC

DataTable (Evnt,1,125)

DataInterval(0,00,msec,10)

'Set the sample interval equal to the scan

DataEvent(20,TC(1)>30,-1,100)

'20 records before TC(1)>30,
‘100 records after TC(1)>30

Sample(1,RefTemp,IEEE4)

'Sample the reference temperature

Sample(5,TC,IEEE4)

'Sample the 5 thermocouple temperatures

EndTable

BeginProg

Scan(500,mSec,3,0)

ModuleTemp(RefTemp,1,5,30)

TCDiff(TC(),5,mV50C,5,9,TypeT,RefTemp,RevDiff,Del,Integ,1,0)

CallTable Evnt
If Evnt.EventEnd(1,1)

Check if an Event just Ended

I=100

Initialize Index

NumAbove30=0

Zero Ranking Variable

Do

Loop through the Event table

NumAbove30=NumAbove30+1

‘Counting the # of times TC(1)>30

I=I-1

Loop While I>0 and Evnt.TC(1,I)>=30

Quit looping when at end or TC(1)<30

WorstCase(Evnt,NumCases,Max,0,NumAbove30)

‘Check for worst case

End If

NextScan

EndProg