setup_io_PCS_Sfn.m
USAGE: setup_io_PCS_Sfn.m
PURPOSE: set inputs for io_PCS S-function
INPUTS:
tokamak = name of device, e.g., 'd3d', 'east', 'kstar', etc.
shot(OR shotnum) = number of shot
start_time = starting time for simulation of what you care about
init_sim_time = initial simulation time (seconds) = any time before baseline calc in PCS
ncpus = number of realtime cpus executing (or being simulated) in the PCS
master_cpu_num = number of cpu whos cycle time defines the multiplier for all cpus
cpu_order = order to feed data to cpus (master cpu first)
cycle_times = cycle times of real-time cpus, in order 1...ncpus
calc_delay_times = computational delay for each cpu, entry i corresponds to cpu i
cmd_delay_times = delay in sending commands from each cpu, entry i corresponds to cpu i
NUM_SIM_OUTPUTS = number of PCS channels (width of diags signal fed to the PCS interface block)
pcs_channels2 = indices of PCS channels corresponding to simulated signals fed to
the PCS interface block's input, indexed from 1 (see input_data2.m in
INTEL_DIR or INTEL64_DIR or run get_input_channels.m)
pcs_channels2_names = signal names corresponding to indices in pcs_channels (optional,
used only for human understanding)
simulation_includes.m = file containing definitions of command signal indices in PCS and
conversion factors from counts into DAC to command voltages
OUTPUTS:
pcs_connect_data = a structure with fields:
ncpus integer = number of cpus that PCS is compiled for
master_cpu_num integer = master cpu number in PCS
start_time float = time in seconds to jump to in beginning simulation (optional, default 0)
init_sim_time floag = time in seconds at which to start the process for baseline calculation
shotnum integer = shot number to get PCS initial condition data from
DA_GAIN = multiplier that converts digitizer volts to counts
Note: PCS sends out digitizer counts (not volts)
Further, PCS and matlab simulation maintain the VME ranges: 4096 counts = -10 to 10 V
But, sysmain_master.h multiplies commands by 16 to get DAC* commands in 16-bit count range
So count-to-volt conversion is (20/4096)*(1/16)=10.0/32767.0=3.0518e-04, which is the
inherent number (IN) for DAC* commands, DA_GAIN = 1/IN. IN values are documented in
simulation_includes.h.
use_fpcom = flag, if 1 use fpcom (unclipped) data for commands instead of intcom
(optional, default=0)
cycle_times float(ncpu) = cycle times of real-time cpus, in order 1...ncpus
calc_delay_times float(ncpu) = computational delay for each cpu, entry i corresponds to cpu i
cmd_delay_times = delay in sending commands, entry i corresponds to cpu i
num_pcs_inputs integer = number of PCS channels (defines input port size)
pcs_channels integer(num_pcs_inputs) = indices of PCS channels input to io_PCS;
these are <device>_sim outputs, indexed from 1 (see input_data.h)
pcs_channel_names = names of signals corresponding to pcs_channels (for human readability)
num_commands = number of intcommand channels (defines output port size)
intcom_channels = indices of intcommand channels defining PCS Sfn output,
indexed from 1
intcom_cpus = cpu numbers where intcom values are coming from, indexed from 1
cpu_order = order to feed data to cpus (master cpu first)
OTHER VARIABLES
pcs_channels_ids integer(num_pcs_inputs) = used in <device>_simX_model Selector block to id PCS
variables for Diag. Physics Out port
RESTRICTIONS:
METHOD
Script initializes variables needed by io_PCS S-function.
Inputs are needed from both <device>_sim and the PCS compiled to use in the simulation.
<device>_sim code is found in this directory.
PCS header files are found in the user's PCS directory by default
The intention is to allow for changes in the PCS to be made without
bothering this workflow.
Inputs to <device>_sim.mdl are PCS commands. Outputs are signals sent
to the pcs.
Conversely, inputs to io_PCS are <device>_sim signals and outputs are
PCS commands.
The signals generated by <device>_sim are defined in SIMULATION_TO_PCS.h.
The commands generated by io_PCS are defined in input_data2.h
<device>_sim_struct.output_signals contains PCS pointnames for the
signals in the simulink model,
<device>_sim_struct.output_signals begins with
<device>_system.output_signals(:,1) and continues with
signals added in <device>_sim2.mdl
<device>_sim_struct.input_signals: These are commands from the PCS used
to identify the intcom_channels, which are indices of the Sfn output
DAC are actual commands that go out.
FSF is the command calculated, FSC is the clipped value and should
agree with DAC
IPFEPS is the command calculated and IPCEPS is the clipped value
pcsinputs2 are the macros extracted from input_data2.h
pcs_channels2 are the indices of the macros for the pcs
therefore, pcsinputs2(pcs_channels2) are the macros for the pcs
To extract the indices of <device>_sim_struct.output_signals we need
for the pcs from the simulation data, we match pcsinputs2(pcs_channels2)
with <device>_sim_struct.output_signals
Dependencies