SAOfwif¶
-
class
MonitorControl.BackEnds.ROACH1.simulator.
SAOfwif
(parent=None, roach='roach1', template='sao', firmware_server=None, firmware_key='sao_spec', port=None, roach_log_level=20, clock_synth=None, integr_time=1, write_to_disk=False, TAMS_logging=False, timing_report=False)¶ Bases:
MonitorControl.DeviceReadThread
Class for one ROACH with SAO 32K spectrometer firmware
Attributes:
spectrum_count - current accumulation number gains - RF gain (only 1 ADC and 1 RF input) data_file_obj - where raw data are stored logger - logging.Logger instance max_count - number of accumulation in a scan rf_gain - gain of RF input scan - number of the current group of accumulations
Attributes inherited from SAOhwif:
fft_shift - contents of register fft_shift fpga - ROACH hardware
Attributes Summary
Methods Summary
ADC_samples
([trig_level, timeout])Returns ADC samples.
action
()This provides the action for the child readers.
Calibrate the FPGA.
ctrl_get
()Reads and decodes the values from the control register.
ctrl_set
(**kwargs)Set control register bits.
fft_shift_set
([fft_shift_schedule])Sets the FFT shift schedule (divide-by-two) on each FFT stage.
Get the ADC input level properties and a set of samples
Get the mean RF section input level.
Returns the current number of raw spectra accumulated
Get the adc temp
Get the ambient ADC temp
get_clk
()Get an estimate of the FPGA clock speed.
Sets (and returns) the names of the firmwares available on this host
Get the gains of the RF channels
Suggested by Jonathan.
get_params
([key])Look up the parameters for the design identified by the key
This is what read hardware would do.
help
()initialize_roach
([RF_gain, RFid, …])Initialises the system to defaults.
Get the accumulation length.
integr_time_set
([integr_time])Set the accumulation length in seconds
quit
()read_register
(register)To allow a client to read register
Initiate the sync pulses
Attributes Documentation
-
accum_reg_keys
= ['status', 'sync_start', 'sys_scratchpad', 'acc_cnt', 'sync_cnt', 'sys_clkcounter']¶
-
command_help
= "\n ADC_samples(trig_level=-1, timeout=1)\n Returns ADC samples.\n integr_time_set(integr_time=1)\n Set the accumulation length in seconds\n ctrl_get()\n Reads and decodes the values from the control register.\n ctrl_set(**kwargs)\n Set control register bits.\n\n This is designed to do the minimum number of writes to the 'control'\n register, allowing bits simultaneously to be set, unset, toggled and\n pulsed.\n fft_shift_set(fft_shift_schedule=0)\n Sets the FFT shift schedule (divide-by-two) on each FFT stage.\n get_ADC_input()\n Get the ADC input level properties and a set of samples\n get_RF_input()\n Get the mean RF section input level. This is the ADC level minus the\n gain of the RF section\n get_accum_count()\n get_gains()\n Get the gains of the RF channels. This only works for ADC type 'katadc'.\n The gain is set by a 20 dB amplifier followed by a -31.5 to 0 dB\n attenuator controllable in 0.5 dB steps. So the actual gain goes from\n -11.5 dB to +20 dB in 0.5 dB steps.\n get_next_spectrum()\n invokes ``get_spectrum`` to get the spectrum from the spectrometer\n get_spectrum()\n initialize_roach(RF_gain=10, integr_time=1)\n Initialises the system to defaults.\n quit()\n read_fpga_uscram(store=0)\n rf_gain_set(gain=20)\n Enables the RF switch and configures the RF attenuators.\n For KATADC boards. KATADC's valid range is -11.5 to 20dB. The RF switch\n is in MSb.\n write_to_data_file(data)\n Save a record\n sync_start()\n Initiate the sync pulses\n\n Methods inherited from MonitorControl.BackEnds.ROACH1.ROACHhwif.ROACHhwif:\n\n get_params(key)\n Look up the parameters for the design identified by the key\n get_register_values()\n Report on the contents of regular registers.\n listdev()\n List the devices defined in the firmware.\n report()\n Get a summary of information for this ROACH\n\n Methods inherited from MonitorControl.BackEnds.ROACH1.ROACHhwif.ROACHppc:\n\n check_borph_status()\n See if the borphserver is running bormally and fix it if not.\n get_bitfile()\n What boffile is running?\n get_boffiles(filter_tutorials=True)\n What boffiles does it have?\n get_firmware_ID()\n Get the firmware IDs of the currently loaded boffiles\n get_firmware_keys()\n Sets (and returns) the names of the firmwares available on this host\n is_alive()\n Is it alive?\n roach_command(self, command)\n Send a command to the ROACH PPC."¶
-
file_attr_keys
= ['sys_board_id', 'sys_rev', 'sys_rev_rcs']¶
-
max_data_file_size
= 1000000000.0¶
-
scan_attr_keys
= ['control', 'fft_shift', 'adc_ctrl0', 'acc_len']¶
Methods Documentation
-
ADC_samples
(trig_level=- 1, timeout=1)¶ Returns ADC samples.
-
action
()¶ This provides the action for the child readers.
The ‘DeviceReadThread’ objects created during initialization invoke their parents’ (this object) ‘action’ method.
It keeps track of the number of spectra in a scan. It saves the data with associated header values for each spectrum. When the number of spectra equals the requested number, it stops and reports.
-
calibrate
()¶ Calibrate the FPGA.
-
ctrl_get
()¶ Reads and decodes the values from the control register.
-
ctrl_set
(**kwargs)¶ Set control register bits.
-
fft_shift_set
(fft_shift_schedule=0)¶ Sets the FFT shift schedule (divide-by-two) on each FFT stage.
Input is an integer representing a binary bitmask for shifting. If not specified as a parameter to this function (or a negative value is supplied), it programs the default level.
-
get_ADC_input
()¶ Get the ADC input level properties and a set of samples
This is input to the chip
-
get_RF_input
()¶ Get the mean RF section input level.
This is the ADC level minus the gain of the RF section
-
get_accum_count
()¶ Returns the current number of raw spectra accumulated
A single spectrum consists of an accumulation of some number of raw spectra. This is written into register
acc_len
. When this number of raw spectra have been accumulated,acc_cnt
is incremented.The spectrometer does not stop running and
acc_cnt
will keep on incrementing until the spectrometer is reset.
-
get_adc_temp
()¶ Get the adc temp
-
get_ambient_temp
()¶ Get the ambient ADC temp
-
get_clk
()¶ Get an estimate of the FPGA clock speed.
-
get_firmware_keys
()¶ Sets (and returns) the names of the firmwares available on this host
-
get_gains
()¶ Get the gains of the RF channels
- Returns
dict of gains[ADC][RF]
-
get_next_spectrum
()¶ Suggested by Jonathan:
acc_new = fpga.read(acc_cnt) if acc_new == acc_old do nothing else if acc_new == acc_old + 1 read_bram acc_old = acc_new else missed an accumulation, throw an error end
-
get_params
(key=None)¶ Look up the parameters for the design identified by the key
Note that is is firmware in dependent in that it just reports on the registers of whatever firmware, as long as the firmware is known.
:param key : name by which the firmware is known
-
get_spectrum
()¶ This is what read hardware would do:
spec = self.read_fpga_uscram(0)[0] for sp in [1, 3, 2]: spec = numpy.append(spec, self.read_fpga_uscram(sp)[0])
We simulate. We begin with one set of normalized data samples:
normalized = norm.rvs(size=self.bandwidth)
with a standard deviation of 1. The actual samples are integers in the range of -128 to 127, with some standard deviation related to the power:
samples = std * norm.rvs(size=self.bandwidth)
See
Channel.get_ADC_snap()
. The central value theorem says that we end up with a normal distrubtion about the mean:spectrum.mean = std * max_count * 2**24 / fft_shift spectrum.std = std * sqrt(max_count) * 2**24 / fft_shift
-
help
()¶
-
initialize_roach
(RF_gain=0, RFid=0, integr_time=1, timing_report=False)¶ Initialises the system to defaults.
For ROACH2 it will be necessary to loop over RF channels.
-
integr_time_get
()¶ Get the accumulation length.
-
integr_time_set
(integr_time=1)¶ Set the accumulation length in seconds
Each spectrum is taken from
num_chan
samples acquired at a rate ofbandwidth*1e6
samples per second. This timesintegr_time
is the number of raw spectra in one spectrum. This number is written toacc_len
. Once the spectrometer is started, it will collect spectra until this number is reached. Registeracc_cnt
is then incremented.
-
quit
()¶
-
read_register
(register)¶ To allow a client to read register
-
sync_start
()¶ Initiate the sync pulses
-