function a2d,V,Vmin,Vmax,nbit ;------------------------------------------------------------------------------------- ; ; Routine performs an analog to digital converter (ADC) simulation for a matrix ; of pixels within a focal plane array. ; ; Input: ; V..........voltages to digitize, scalar or array ; Vmin.......minimun voltage of ADC ; Vmin.......minimun voltage of ADC ; nbit.......number of bits in ADC ; ; Output: ; counts....voltage converted to counts ; ; Source: Mark Hervig, GATS Inc. ; ;------------------------------------------------------------------------------------- ;- setup c_max = 2.^float(nbit) ; max response in counts c_min = 0 ; min response in counts cpv = (2.^float(nbit)) / (Vmax - Vmin) ; counts per volt ;- digitize V counts = round( V * cpv) ; volts to counts ;- check limits k = where(counts gt c_max,n) if (n gt 0) then counts(k) = c_max k = where(counts lt c_min,n) if (n gt 0) then counts(k) = c_min ;- done return,counts end