TripStack.m

This Matlab function reads events from the TripStack event recorder, which records the source and time stamp of events in the controller as they occur. It takes as arguments a pointer (handle) to the Opal Kelly interface and a flag telling the function whether to print the events. It returns three values: a flag indicating whether the trip stack is currently armed, the number of events currently recorded, and a list of events in an n x 3 array, each of the n events having a parameter specifying the source, a count of fiducials, and a count of clocks since the last fiducial. The last two returned values constitute a time stamp.

[armed count eventlist] = TripStack(xptr, print)

After readout, the function re-arms the trip stack. With the print flag set to false,

>> [armed count eventlist] = TripStack(xptr, 0)
armed =
     1
count =
     2
eventlist =
           3   320613833         214
           0   320614014          72

Each row of eventlist correponds to an event. The first parameter of an event is the event source, where the code corresponds to the table in the 'Trip stack' work sheet of the LogicConfiguration.xls spread sheet. Those assignments may change. The second parameter is a bunch fiducial count, where bunch fiducials are described here. The third parameter is a count of sample-clock periods of the controller since the last fiducial. The calculation of relative times from the last two parameters is simply

time = (fiducials * n + clocks)/fs

where fs is the controller's sample frequency and 'n' is the number of sample clocks per fiducial (528 = five turns in NSLS-II).

A readout of a soft trip with the print parameter set to true might look like this:

>> TripStack(xptr, 1);
 - Trip stack is armed.
 - Event count is 2.
Source   Time = fiducials + turns + buckets
-------------------------------------------
Soft trip       272532490     4       245.0
RFInhibit       272532671     0      1200.0

Where the last two columns are calculated from the third column of eventlist. In this example, RFInhibit is delayed by the 2.40-ms ramp down of the soft-trip module in logic. The trip stack remains armed because it has not been filled to capacity (currently 15 events).