Matlab file descriptions

Figure windows and associated scripts
Low level rf API
Circular buffer
Network analyzer
Other files

Figure windows and associated scripts

llrf.m
Clears the workspace and runs the Matlab controller software.
llrf100909_gui2b.m
The diagnostic window. contains the scope, circular-buffer controls, etc.
llrf100909_ini2.m
Script that performs some initialization functions of the diagnostic window (_guid2b.m).
llrf100909_opGui2b.m
The control window. Controls ff, fb, interlocks, etc.
llrf100909_opIni.m
Script that performs some initialization functions of the control window (_opGuid2b.m).
TuningPanel.m
A window used for monitoring the logic side of the cavity tuning system.
llrf100909_adc2.m
A script that reads the scope channels and updates the scope display. Invoked by the diagnostic window _gui2b.m.
llrf100909_axis2.m
Script that updates the scope-plot horizontal axis scale and unit when the zoom is changed. Invoked by _gui2b.m.
llrf100909_dac.m
A script that computes ff waveforms and writes them to the ff table. Invoked by the control window _Opgui2b.m.
llrf100909_fm.m
Has to do with frequency sweeping the rf out of the controller. It hasn't been used for several years.

RF API

rfboard.m
A class that provides an rf-aware interface to rf logic via Opal Kelly's FrontPanel. See rfboard.m.html. The class contains methods for:

Circular buffer

Some circular-buffer functionality is embedded in the diagnostic window _gui2b.m.

CircBufFetch.m
Utility that retrieves data from sdram, unwraps it as appropriate for a circular buffer, aligns the start of the buffer to the zeroth channel, and clips the length of the entire buffer to a multiple of 20 samples.
[buf wrapctr pageloc memsize page] = CircBufFetch(ifc);
Data in buf are I, Q, -I, -Q quadrants of five interleaved channels, i.e., I1, Q2, -I3, -Q4, I5, Q1, -I2, ..., in an int16 array. wrapctr is the wrap counter, pageloc is the location of the start of data in words, memsize is the size of the SDRAM in words, and page is the value of the page. The data in buf is ordinarily all that is needed from this function.
CircBufPlot.m
Plots part or all of 0.41-s circular-buffer dumps. Start and end times in seconds are specified. The data are down sampled if necessary to bring the number of points plotted below about 2^14. There are five channels, and each gets a plot within the one frame.
CircBufPlot(0.14, 0.34);
CircBufSpect.m
Plots segments of specta obtained from the circular buffer centered on a frequency offset and span.
CircBufPlot(channel, freqoffset, freqspan);
All points of the spectrum in the span are plotted, which means that a large span plots a large number of points. The spectral resolution is fixed at 1/time span = 2.5 Hz.

Other files

CLSRamp.m
Generate and trigger a booster ramp with intervals roughly those of J. Stampe's email of 11/15/2012.
CLSRamp(injection, extraction, duration, timeout);
injection
the complex-valued injection level on a ±32768 scale
extraction
the complex-valued extraction level on a ±32768 scale
duration
the ramp duration in seconds
timeout
timeout parameters in seconds
Compile.m
Compile the Matlab code for the controller to an executable that can be run on any computer that has the Matlab runtime installed. See:
http://www.mathworks.com/support/solutions/en/data/1-1AJI4/?solution=1-1AJI4
Crosstalk.m
Used to measure crosstalk between channels when using a 'ChannelTest' controller build, a build that is used for bench testing. A signal is applied to one of the eight ADC channels, scope traces are acquired and read out, and the crosstalk is computed. The gain of the channel to which the signal is applied is also measured. The signal is provided by feed forward table using 'CW, 360 deg phase ramp' selection of the waveform selector.
ft = Crosstalk();
Returns a 2-d array whose first index is the channel, and the second distinguishes the measured upper sideband from the lower sideband.
FBPulse.m
Might be the same as CLSRamp.m.
fbRampSegment.m
Loads an 's' function into the ramp table determined by the beginning and end points, sets the inter-waypoint interval, and triggers a ramp.
fbRampSegment(ptr, first, last, interval, timeout);
first and last are complex-valued phasers, while interval is in clockcycles. timout ensures that if something goes wrong, the function will still exit with a message.

The function first waits for the current ramp to end, if it is running. For this reason, it is not necessary to wait before calling this function again.

By 's' function is meant a function with the specified beginning and end points, and zero derivative at the ends. It is a sine wave in between. The zero derivative ensures that waveforms may be concatenated while the interpolation in logic can function properly at the interfaces.

fbRampSequence.m
Runs an illustrative sequence of four ramps with varying end points, rates, and pauses between them.
fbRampSequence(sample frequency (Hz), start delay);
fbWait.m
Waits for busy flags to clear from Opal Kelly end point 0x20 (blocking call).
Wait(ptr, mask, interval);
ptr
Handle to the Opal Kelly interface.
mask
Bits of the end point to test.
interval
Time interval between tests.
NewPaths.m
Adds paths to the Matlab path. Should not need to be changed if the OpalKelly environment variable is defined and API and GuoBo are subdirectories of the program directory.
okHeader.m
Normally automatically compiled by gb_init for the stand-alone program (see Compile.m).
phasetest.m
Diagnostic function.
Piecewise.m
Computes I/Q waveforms linearly interpolated between waypoints.
plotref.m
Diagnostic function.
PlusMinus.m
Multiplies an array by +, -, +, -, ... .
PlusPlusMinusMinus.m
Multiplies an array by +, +, -, -, ... .
ramp.m
Generates an array from a function.
r = ramp(mag, phase, len, fctn);
mag
an intensity parameter
phase
a phase parameter
len
the number of real/imaginary pairs of the table
fctn
specifies a function representing the functional dependence of the ramp
format
specifies the format of the returned table.
0
2-d array, each row with index and complex value
1
2-d array, each row with index, real, and imaginary parts
2
2-d array, each row with real and imaginary parts
3
1-d array with real and imaginary parts interleaved

The returned ramp table is the product of the complex magnitude and phase, and the function specified by fctn. fctn may be complex-valued.

ramplinear.m

This function generates booster cycles with linear ramps up and down, but with transition intervals that smoothly connect the first ramp segments (bottom to up ramp, and up ramp to top), allowing interpolated ramps without glitches. The ramps have 512 interleaved I and Q (I, Q, I, Q, ...) sample pairs that can be directly programmed to the feedback ramp table. In fact, if there is an existing connection to a Opal Kelly device via the global variable ifc, then the feedback ramp table is loaded and the rampinterval control point is set for the appropriate ramp duration.

[ramp rampinterval] = ramplinear( ...
  magbottom,	phasebottom,	magtop,		phasetop, ...
  upduration,	topduration,	downduration, ...
  transitionwidth ...
);
  • magbottom and phasebottom are the ramp's magnitude and phase at the bottom of the ramp.
  • magtop and phasetop are the ramp's magnitude and phase at the top of the ramp.
  • upduration, topduration, and downduration are the durations of the up-, top-, and down-ramp segments in seconds, respectively.
  • transitionwidth is the width of the transitions between the segments in I/Q waypoints. Use a value in the 5 to 20 range.
  • In normal use, the ramp, hard coded for 512 I/Q table waypoints, is run with duration, set by the rampinterval control point, that is less than the full ramp cycle so that the ramp will finish and be idle prior to the start of the next ramp cycle. The last segment of the ramp following the end of the down ramp is only a handful of waypoints duration. From there the rampinterval control point is set to scale the ramp in time to get the correct durations of the ramp segments, leaving the ramp idle for an interval prior to the next ramp trigger. Due to the transition duration, there is a delay between the trigger and the start of the ramp.

    As was noted earlier, if there is a connection to an rf board via the global variable ifc, then the table is written to the board and the rampinterval control point is set for the appropriate segment durations.

    There is a delay of a few milliseconds from the trigger to the start of ramp due to the first transition. If this delay is critical or problematic, the first transition may need to be shortened or removed. The later transitions, where there is no beam, are set to fixed short durations.

    RefreshEnumerate.m
    Function used to set the timer interval as determined by the scope update rate in _gui2b.m.
    ScaleXAxis.m
    Utility called by _axis2.m.
    scope.m
    Plots scope dump files containing scope traces.
    scope

    There are no arguments. A file dialog appears, which is used to navigate to, and select, the dump file. Dump files are saved in the 'ScopeDumps' subdirectory.

    Scope dump files are saved by the Matlab control program when trigger sources are selected in the 'Auto-save snapshot' boxes, and those trigger sources are activated. For example, if the 'RFInh' box is checked, then scope traces are saved when rf inhibit is activated. Some check boxes are not visible for some builds.

    SFunction.m
    Generates a smooth table of (I, Q) pairs between start and end points, in a 1-d array. It uses the inverse sine function between the points.
    r = SFunction(start, stop, blksize);
    signed.m
    Converts or interprets the least-significant bits of a number to a signed Matlab data type.
    x = signed(value, bits);
    TextBoxes.m
    Called by _adc2.m to fill in the scope channel text in the diagnostic window.
    TunerStatusText.m
    Provides a string indicating status of the cavity tuning system. It is called by the control window _opGui2b.m.