Real Time Controller Functional Requirements Don Gavel & Marc Reinig UCO Lick, laboratory for Adaptive Optics. Keck NGAO Team Meeting December 13, 2007 Videoconference Outline • Status • Issues • Plans NGAO Real Time Controller FRD 2 Status • We have an architecture that meets the performance requirements – – – – – – – 9 LGS/WFS (64x64) 2 Tip/Tilt WFS 1 T/T-focus-astigmatism WFS 1 Truth WFS 5 DM’s (with T/T) (64x64) 1 Woofer <500µSec from receipt of image to commands received at the DM • Scalable to larger problems • We have validated the software in the lab and through simulation NGAO Real Time Controller FRD 3 Architecture – Hardware and Software – NGAO Real Time Controller FRD 4 NGAO System Context Block Diagram (DRAFT) Version 5, 10/31/07 Erik Johansson Observing Sequencer Instrument Sequencer Atmospheric Tools Telescope Interface Data Server Laser Sequencer LTCS Config Laser Telem Telem Data Tel Status Offload AO Sequencer Status Status Telem RT Diags Telem Cmd Cmd Status Status Status Cmd Telem RT Diags PSF Monitoring Cameras Motion Control Device Control Pixel Data dNIRI OptoMech Control Relay DM/TT Control Motion Corrector Control Commands Device Control Motion Control Device Control PSF Cams X? MEM s DMs x6 Acquisitio n Control LO WFS Control Device Motion Motion ControlControl Control Pixel Sensor Corrector Data Control Commands Corrector Commands Pixel Data DM/ TT Status Cmd Telem RT Diags Acq Cam LO WFS DMs x3 LO WFS x3 NGS HOWFS Control RTC Pixel Data Pixel Data Motion Control Sensor Control 9 LGS HOWFS Control TWFS Control Optics Bench Control Motion Control Pixel Sensor Data Control Motion Control Sensor Control Motion Control Device Control Pixel Data LGS WFS x9 NGS WFS Uplink TT Legend: TWF S Laser Launch Facility Laser Safety System Status Motion Control Device Control Diag Optic s Benc h Devs Laser LF OptoMech Motion Control Device Control Status Diag Laser OptoMech Laser Servi ce Encl Boresight Cam Spott er Statu s ESto p Non-Real-Time Commands and Data Real-Time Commands and Data Real-Time Diagnostic Data NGAO Real Time Controller FRD 5 NGAO System Context Block Diagram (DRAFT) cont. Version 5, 10/31/07 Erik Johansson Observing Sequencer Instrument Sequencer Atmospheric Tools Telescope Interface Data Server Laser Sequencer LTCS Config Laser Telem Telem Data Tel Status Offload AO Sequencer Status Status Telem RT Diags Telem Cmd Cmd Status Status Status Cmd Telem RT Diags PSF Monitoring Cameras Motion Control Device Control Pixel Data PSF Cams X? dNIRI OptoMech Control Relay DM/TT Control Motion Corrector Control Commands Device Control Motion Control Device Control MEM s DMs x6 Acquisitio n Control LO WFS Control Device Motion Motion ControlControl Control Pixel Corrector Sensor Data Control Commands Corrector Commands Pixel Data DM/ TT Status Cmd Telem RT Diags Acq Cam LO WFS DMs x3 LO WFS x3 NGS HOWFS Control RTC Pixel Data Pixel Data Motion Control Sensor Control 9 LGS HOWFS Control Motion Control Pixel Sensor Data Control Motion Control Sensor Control Pixel Data LGS WFS x9 NGS WFS Uplink TT Legend: TWFS Control TWF S Optics Bench Control Motion Control Device Control Laser Launch Facility Laser Safety System Status Motion Control Device Control Diag Optic s Benc h Devs Laser LF OptoMech Motion Control Device Control Status Diag Laser OptoMech Laser Servi ce Encl Boresight Cam Spott er Statu s ESto p Non-Real-Time Commands and Data Real-Time Commands and Data Real-Time Diagnostic Data NGAO Real Time Controller FRD 6 Interface to SRT System • SRT controls all aspects of RTC - Ethernet – There will be a non-RT Linux PC controlling the RTC – Interface to the SRT will be Ethernet between the SRT and the RTC control PC – Load and read the RTC code for all operations – Load and read the RTC HW configuration • Telemetry streams to monitoring, PSF, etc - Ethernet • Interface between the RTC and the high-speed disk arrays for diagnostic data - Fiber Link or equivalent NGAO Real Time Controller FRD 7 NGAO RTC System Context Block Diagram (DRAFT) Observing Sequencer Data Server Telescope Interface AO Sequencer Telem RT Diags Offload High Speed Data Server Version 2, Nov 11, 2007 Marc Reinig Telem Config Data High Speed Diagnostic Data Cmd Status Status Cmd Telem RT Diags LO WFS Control Device Control Motion Control Corrector Commands Corrector Commands RTC Uplink TT Corrector Commands DM/TT Legend: LO WFS DMs x3 LO WFS x3 9 LGS HOWFS Control TWFS Control Motion Control Sensor Control Motion Control Sensor Control Motion Control Sensor Control Pixel Data Pixel Data Pixel Data MEMs DMs x6 Pixel Data NGS HOWFS Control LF OptoMech NGS WFS Pixel Data LGS WFS x9 TWFS Non-Real-Time Commands and Data Real-Time Commands and Data Real-Time Diagnostic Data NGAO Real Time Controller FRD 8 Tomography Is Part of a Larger System – With characteristics that lend themselves to a similar solution – Kolmogorov filter Guide star Layer heights height Wavefront Wavefront Sensors Wavefront Sensors Wavefront Sensors Sensors Image Image Processors Image Processors Image Processors Processors Tomography Unit Centroid algorithm r0, guidstar brightness, Guidestar position Precondition Cn2 profile FT-1 FT X Wavefront Wavefront Sensors Wavefront Sensors DM Sensors Projection DM conjugate altitude Backpropagate Independent parallel streams of parallelizable processes + FT X FT-1 Aperture Image Image Processors Image Processors Deformable Processors Mirrors Actuator influence function Postcondition Volumetric dOPD estimates Aperture WFS data Image Image Processors Image Processors DM Processors Fit Forwardpropagate More independent parallel streams! NGAO Real Time Controller FRD 9 A Systolic Array Voxel Boundary Chip Boundary Board Boundary NGAO Real Time Controller FRD 10 Data Rate and Location Nasmyth analog cable length constraints WFS Cam Local frame grab .. . Hartmann sensor optics digital cable (prefer DMA transfer) HV cable length constraints Woofer Deformable Mirror Tweeter Deformable Mirror .. . Nasmyth Computer Room Local dedicated centroider Fiber Link or equivalent Telemetry Data (>160MB/Sec each) Tomography Engine High Voltage D/A converter Woofer fits High Voltage D/A converter Tweeter fits Diagnostic Data (To Disk) (>1 GB/Sec) Nasmyth NGAO Real Time Controller FRD 11 Telemetry and Diagnostics Streams Telemetry (Low bandwidth, on-line monitoring) (>1Hz) • Set and read the telemetry rate for each data stream • Set and read the data streams that are enabled for telemetry – – – – Centroids Residual tomography error DM commands, including uplink Tip/Tilt commands Diagnostics (High bandwidth, stored to disk) (full frame rate) (Could be > 1GB/Sec) • Set and read the diagnostic rate for each data stream • Set and read the data streams that are enabled for diagnostics – – – – – – Centroids Residual tomography error Raw layer information DM commands, including uplink Collapsed layer information Tip/Tilt commands NGAO Real Time Controller FRD 12 RTC Software Flow ATM + + Tomography + - Woofer + Woofer Fit Woofer + Woofer go-to error Tweeter Collapse Average Tweeter .. . Tweeter Fit + .. . NGAO Real Time Controller FRD 13 Tomography Basic Loop Fourier Domain Guide Star = 1 (G = 1) Spatial Domain Dynamic data Start Static Data Forward Prop(G) current estimated values for voxels passed through layers IDFT(FP) forward propagated values passed by rows (east/west) then columns (north/south) IDFT coefficients apply aperture Spatial fwd prop value 1 or 0 depending on location measure error Spatial adj fwd prop value Measured value multiplied by shift(layer,guide star) Calculate New Estimate G=G+1 error values passed by rows (east/west) then columns (north/south) DFT(error) The error vectors for this guide star are stored for back propagation Store Error(G) Sum of Squares and Store(G) no DFT coefficients Back Propagate An error magnitude for this guide star: |E| = (real)2 + (imag)2 is summed across all columns and rows. This value is stored for global error. G == Total # Guide Stars? Error > Limit yes Calculate Error Sum the Sum of Squares error values across all guide stars Global Error Error < Cutoff? Forward Propagate yes Done no Measured Value From WFS G=1 Back propagation G=G+1 no Accumulate error values for each guide star in each voxel in each layer Error <= Limit CN2 value(Layer) G == Total # Guide Stars? yes Kolmogorov Filter Coeff error K_filter value Error Old estimate Done Error Limit New Estimate NGAO Real Time Controller FRD 14 Forward Propagation New Voxel Estimate, Layer(0) Adjust for Shift for Layer(0) New Voxel Estimate, Layer(N) Adjust for Shift for Layer(N) Start Calculate New Estimate Back Propagate Forward Propagate Error > Limit Calculate Error Measured Value From WFS Error Limit Sum All Adjusted Values in the Ray Path Error <= Limit For each sub aperture, sum all the estimated Voxel values, along the path of a ray to each Guide Star. In the Fourier domain, you must account for the spatial shift that occurs in the spatial domain. This will be the complex conjugate of the shift value used in the back propagation. Done Calculate Error Guide Star (N) Measured Value From WFS(0) NGAO Real Time Controller FRD 15 Start Calculate Error Calculate New Estimate Back Propagate Forward Propagate Back Propagate Error > Limit Forward Propagate Calculate Error For each sub aperture, for each ray from a Guide Star, calculate the error between the forward propagated value and the measured value from the WFS for that Guide Star. Error <= Limit Measured Value From WFS Error > Limit Error Limit Done Compare Error to Limit Subtract Forward Propagated Value from Measured Value for each WFS If you have reached the limit stop, else continue with another loop Error <= Limit Done Error Limit Measured Value From WFS(0) NGAO Real Time Controller FRD 16 Back Propagate Calculate New Estimate for this Voxel Start Calculate New Estimate Back Propagate Adjust Error(0) for Shift for this Layer (Multiply) Forward Propagate Error > Limit Calculate Error Measured Value From WFS Error Limit Adjust Error(N) for Shift (Multiply) For each guide star, for each sub aperture, back propagate the error for a guide star to all the Voxels along the ray back to the Guide Star (These should be the same Voxels used in calculating the Forward Propagated value.) Adjust Error(N) For Gain and Cn2 (Multiply) Adjust the error for each Voxel for the Cn2 value for its layer Error <= Limit Adjust Error(0) For Gain and Cn2 (Multiply) Done In the Fourier domain, you must account for the spatial shift that occurs in the spatial domain. This will be the complex conjugate of the shift value used in the Forward propagation. Calculate Error Guide Star (N) Calculate Error Guide Star (0) Forward Propagate Guide Star (N) Forward Propagate Guide Star (0) Measured Value From WFS(0) Measured Value From WFS(N) Error Limit NGAO Real Time Controller FRD 17 Calculate New Estimate Start Calculate New Estimate Forward Propagate Back Propagate Error > Limit Average Adjusted Errors Calculate Error Measured Value From WFS Error Limit Error <= Limit Add to Current Estimated Value For each Voxel, calculate the average of the adjusted errors that were back propagated along the rays to various Guide Stars and add this to the estimated value for the Voxel to get a new estimated value. Done Back Propagate d GS Error(0) Back Propagate d GS Error(N) Forward Propagate GS(0) Forward Propagate GS(N) NGAO Real Time Controller FRD 18 WFS Control Commands Camera • Set and read the camera frame rate • Set and read the camera pixel rate • Set and read the camera gain Centroiding • Load the dark pattern • Load pixel gain pattern • Set and read the threshold level • Set and read the centroiding algorithm • Load and read the centroid weights • Load and read the reference centroids • Load and read the centroid offsets • Set and read pixel offsets for the camera image • Set and read the guidestar mode (NGS or LGS) for any WFS • Load and read centroid non linearity tables NGAO Real Time Controller FRD 19 Tomography Control Commands • Load and read the cone-effect scaling array for any guide star or target • Load and read the sky position for any guidestar or target • Load and read the Kolmogorov filter array • Load and read the pre-conditioning arrays • Load and read the tomography loop gain arrays • Load and read the tomography bailout value • Load and read the Cn2 values for all layers • Load and read the wind array for all layers NGAO Real Time Controller FRD 20 DM and Tip/Tilt Control Commands • Load and read the layer-to-DM collapse arrays • Load and read the DM command matrixes and non linearity lookup tables for open and closed loop control • Set and read DM open/closed loop mode • Set and read the Tip/Tilt command matrixes NGAO Real Time Controller FRD 21 Calibration Capabilities • • • • • • • • • Create a system matrix for any DM Set the number of frames to use when creating the system matrix Clear the DM of any manually set values Calibrate science target DMs in MOAO Woofer Tweeter Force an arbitrary camera image for any WFS Force an arbitrary centroid output for any tomography WFS input Force an arbitrary layer pattern to be used by the DM command module • Send an arbitrary pattern to any DM • Save the current centroid positions as an reference centroid file (averaged over a settable number of frames) NGAO Real Time Controller FRD 22 System Diagnostics Capabilities • • • • Read all chip temperatures Read system temperatures at various predetermined locations Monitor chip and system fan operation Set and read temperature alarm trip levels NGAO Real Time Controller FRD 23 Reliability and Reparability • • • • Graceful degradation Spares requirement MTBF Self Healing (SEU) NGAO Real Time Controller FRD 24 Physical Characteristics • Size – <20 m3 • Weight – TBD • Location – WFS and DM Drive are on the Nasmyth – RTC and High Speed Disk array are in the computer room • Power – <20KW NGAO Real Time Controller FRD 25 Issues Remaining • Determine Single Event Upset (SEU) rate from Gamma/Cosmic rays • Verify detection and recovery scheme NGAO Real Time Controller FRD 26 Plans • Complete FRD • Finish writing report • Validate SEU issues NGAO Real Time Controller FRD 27 Backups NGAO Real Time Controller FRD 28 Data Rate Work Sheet Sub apertures across primary Sub aperature at altitued Number of WFSs Number of Pixels per WFS Camera Camera transfer time to WFS (µSec) Number of Layers Number of MCAO DM's Number of observing DMs (only relevant for MOAO) Word size (Bytes) Portion of a frame used for transfer time (% frame) (Transfers of WFS data-in and DM data-out are overlapped) Frame time (µSec) Input and output control data rates (MB/Sec) Per Camera Total Camera Per WFS Total WFS Per DM Total DM Diagnostic data rates (MB/Sec) Per Camera Total Camera Per WFS Total WFS Per Layer Total Layer Per DM Total DM Diagnostic Storage Rate w/o layer info (GB/Sec) Maximum diagnostic Storage Rate (GB/Sec) Giga Bytes of Mass Storage per minute Radial MCAO MOAO Voxels 64 64 64 3 3 3 10 10 10 32,000 32,000 32,000 400 400 400 7 7 7 2 2 2 6 5 5 2 2 2 10% 500 10% 500 10% 500 160 1,600 164 1,638 164 328 160 1,600 164 1,638 164 983 160 1,600 164 1,638 164 983 128 1,280 16 164 1,475 10,322 16 33 1.5 12 708 128 1,280 16 164 1,475 10,322 16 98 1.5 12 712 128 1,280 16 164 164 1,147 16 98 1.5 3 161 NGAO Real Time Controller FRD 29 Sample Code to Configure the Hardware – Simple ALU – module alu4 ( input_a, input_b, output_c, ctrl_0, ctrl_1, ctrl_2,ctrl_3, clr, clk ); input ctrl_0, ctrl_1, ctrl_2, ctrl_3; input [15:0] input_a, input_b; output [31:0] output_c; input clr, clk; wire [3:0] ctrl; reg [31:0] output_c; assign ctrl = parameter ADD parameter MUL parameter NOP {ctrl_3, ctrl_2, ctrl_1, ctrl_0}; = 4'b1001; = 4'b0001; = 4'b1000; always @(posedge clk or posedge clr) begin if (clr) output_c <= 0; else case (ctrl) ADD: output_c <= input_a + input_b; MUL: output_c <= input_a * input_b; default:; endcase end endmodule NGAO Real Time Controller FRD 30 Processor Array Illustration Global System State Information Forward Propagation Path GS1 ... Back Propagation Path GS1 GSn Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. ... Global System State Information Forward Propagation Path GSn GS1 ... GS1 Error GS2 Error GS1 GSn Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. Voxel Local Registers Back Propagation Path Cn2 Cumulative Value GSn ... GS1 GSn GS1 ... GS1 ... GSn GS1 ... GSn GSn GS1 ... GS1 Error GS2 Error GS1 GS1 GS1 ... GSn Path Back Propagation Path GS1 GSn Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. ... Back Propagation Path Forward Propagation Path ... ... GS2 Error GSn GS1 ... Global System State Information Control Logic Forward Propagation Path GS1 ... GSn GS1 ... Back Propagation Path Global System State Information GSn ... An Array of Voxel Processors GSn GSN Error Current Estimated Value Cn2 GS1 GS1 ... ... Control Logic GSn ALU (Word Size + NGS) wide Path Back Propagation Path GS1 GSn ... GSn Voxel Local Registers GS1 Error GS2 Error GS3 Error ... GSN Error Control Logic Cumulative Value GSn ALU (Word Size + NGS) wide ... GSn Back Propagation Path GS1 Global System State Information GS1 Cumulative Value GSn Cumulative Value GS1 GS1 Cumulative Value GSn Cumulative Value GS1 Cn2 ... GSn Forward Propagation Path GS1 ... ... GSn GSn Back Propagation Path Global System State Information • ... ... GSn Back Propagation Path Forward Propagation Path Current Estimated Value ALU (Word Size + NGS) wide Forward Propagation Path GS1 GS1 Error GS2 Error Cumulative Value GSn ... Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. Cn2 GSn Voxel Local Registers Cn2 Forward Propagation Global System State Information Global System State Information GSN Error ... GSn GSN Error GS1 GSn GS2 Error GS1 ... ALU (Word Size + NGS) wide GSn GS1 Error Cumulative Value GS1 GS1 GS3 Error GS1 Error ... Cumulative Value GSn GSn GSn GS2 Error GS3 Error ALU (Word Size + NGS) wide GSn ... Voxel Local Registers Current Estimated Value Cn2 ... GS1 GSn Cumulative Value GS1 Back Propagation GSn ... ... Path Back Propagation Path ... GSN Error GS1 GS1 GS3 Error GS1 Path Forward Propagation Path ... Back Propagation Path Back Propagation Path Voxel Local Registers Control Logic Forward Propagation Global System State Information Global System State Information Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. GS1 Error Cumulative Value GS1 ... Current Estimated Value Cumulative Value GSn GS3 Error Control Logic GS1 Cn2 GS1 GSn Voxel Local Registers Current Estimated Value GSn Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. GSN Error Cumulative Value GS1 GS1 Forward Propagation Global System State Information Global System State Information GSn ALU (Word Size + NGS) wide Control Logic Cumulative Value GSn GSn ... GS1 Forward Propagation Path Forward Propagation Path Global System State Information Global System State Information ... ALU (Word Size + NGS) wide ... ... GS1 Error Current Estimated Value Cn2 GS1 Cumulative Value GSn GS3 Error GSN Error Cumulative Value GS1 Cn2 ALU (Word Size + NGS) wide GSn GS2 Error ... Control Logic ... Voxel Local Registers GS3 Error Current Estimated Value GS1 Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. GSN Error Cumulative Value GS1 Back Propagation Path Back Propagation Path GSn Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. Voxel Local Registers Back Propagation Path GSn GS1 Error GS2 Error ... Cumulative Value GSn ... GS1 Forward Propagation Path Voxel Local Registers Control Logic Forward Propagation Path Forward Propagation Path Global System State Information Global System State Information ... Global System State Information GS3 Error Cn2 Cumulative Value GS1 Back Propagation Path Back Propagation Path GSn Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. GS1 GSn Current Estimated Value ALU (Word Size + NGS) wide Control Logic Forward Propagation Path Forward Propagation Path Back Propagation Path ... GSN Error Current Estimated Value ALU (Word Size + NGS) wide Global System State Information Global System State Information ... GS3 Error GSN Error Cumulative Value GS1 GS1 Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. GS1 Error GS2 Error ... Control Logic Forward Propagation Path GSn Voxel Local Registers GS3 Error Current Estimated Value ... Global System State Information • Forward Propagation Path Back Propagation Path A Single Voxel Processor NGAO Real Time Controller FRD 31 The Tomography Engine - A scalable, programmable, configurable processor • • • Scalable: System can be easily put together (by replication) to work for any sized problem Programmable: Changes in the algorithm can be loaded at run time Configurable: Parameters are easily changed (sub aps, guide stars, layers, Cn2; mixes and positions of natural and laser guidestars; etc. … scales to this This … Multiple Voxels in each FPGA (One column for each sub ap.) Multiple Chips on a Board(s) NGAO Real Time Controller FRD 32 A Single FPGA Can Hold Hundreds of Voxels A Circuit Board Can Hold A Dozen FPGA’s NGAO Real Time Controller FRD 33 Basing Our Architecture on Our Knowledge of Structure We divide the atmosphere into regions called “voxels” And use that model for our structure for the iterative solution NGAO Real Time Controller FRD 34 Using Our Knowledge of Structure • For a single Voxel • • • Examining the problem, we find: All calculations for all voxels are identical Most operations on voxels are independent of other voxels Operations are simple Memory requirements are modest This is an “Embarrassingly” parallel problem So … • • • • We give each voxel its own simple processor Global System State Information Forward Propagation Path GS1 ... Back Propagation Path GSn Note: Because the Forward propagation and Back Progagation paths are parallel, but are used at different times, they will actually be a single bus in the physical implementation. GS1 ... GSn GS1 ... GSn Voxel Local Registers GS1 Error GS2 Error GS3 Error ... GSN Error Current Estimated Value Control Logic Cn2 ALU (Word Size + NGS) wide Cumulative Value GSn Cumulative Value GS1 These Voxel processors are interconnected, modeled after the structure of our problem GS1 Global System State Information ... GSn Forward Propagation Path Back Propagation Path This … … scales to this Each column of voxels is a complete sub aperture containing all layers in our model of the atmosphere. Multiple sub apertures are arrayed in each FPGA chip Multiple Chips on a Board, and multiple boards to satisfy the size of the problem NGAO Real Time Controller FRD 35