ODDMOD Accelerator Statistics Gatherer
                            (CAMAC Module C205)

                         T. Johnson, B. Hendricks
                              October 3, 2001


The ODDMOD CAMAC module is a dedicated gatherer of accelerator operation
statistics.  It has 32 analog and 30 pulse train signals connected directly
to it which provide machine intensities and other important machine
parameters.  ODDMOD is also connected to TCLK and uses the occurrence
of specified events to sample and store away machine parameters.  Each
module contains 256 channels of information.  These channels can contain
sampled analog values, sampled pulse train values, clock event counts,
or above threshold counts for sampled analog or pulse train inputs.
There are three sets of these 256 channels.  The first of these is the
real-time dat array which contains the most recently sampled values.
The second is a temporary sum array which adds up sampled values until
some process (currently the ODDMOD OAC running on OPER) reads and
clears it.  The final array is the all time sum array which adds up
the sampled values until a user decides to clear the values.

The purpose of the 205 module is primarily to provide a system to increment
and store accelerator intensities and other performance parameters.  The
module supports a dedicated 12-bit ADC module with up to 32 analog inputs
in the range 0 to 10.235 volts.  Each ADC has a conversion time of <30
microseconds.  All channels always convert serially. The module also
supports a pulse train counter module with 6 AM9513's configured as pulse
train counters for a total of 30 channels.

Additional MADC modules and pulse train counter modules may be added if
needed.  The present code automatically supports up to two modules of each
type simply by modifying special RAM locations.

The module basically consists of a standard 190-A single board computer.
It contains all CAMAC function decoding, the CPU, RAM, EPROM, terminal
interface, clock decoder circuits, interrupt controllers and a counter/timer
circuit.

There are currently four of these modules in existence.  One is used to
gather statistics for the Linac and Booster.  The second one is used for
Main Injector and Antiproton Source data.  The third one is used for
Tevatron and Switchyard data.  The final one is used for testing.


CAMAC Function Summary:


F(0)*A(0)   - Read the element from the real time (most recent cycle)
	      array indicated by RLPNTR (0-255). This must be preceded by
	      an F(19)*A(6).

F(0)*A(1)   - Read the element from the all-time summary data array
	      indicated by ARPNTR (0-255). This must be preceded by a
	      F(19)*A(7).

F(0)*A(2)   - Read the element from the temporary summary data array
	      indicated by TMPNTR (0-255). This must be preceded by a
	      F(19)*A(8).

F(0)*A(3)   - Read ordinal value of a given element in a data list

F(0)*A(4)   - Read FOP status

F(0)*A(5)   - Read FOP data

F(0)*A(6)   - Read longword #0

F(0)*A(7)   - Read longword #1

F(0)*A(8)   - Read data list word #1 from the data list element
	      indicated by LISTID

F(0)*A(9)   - Read data list word #2 from the data list element
	      indicated by LISTID

F(0)*A(10)  - Read data list word #3 from the data list element
	      indicated by LISTID

F(0)*A(15)  - Return the list and element number for the
	      node containing the same data as that contained
	      in TMPWD1, TMPWD2, and TMPWD3

F(1)*A(0)   - Read Main Injector/Tevatron abort time (module specific)

F(1)*A(1)   - Read Main Injector/Tevatron cycle time (module specific)

F(1)*A(2)   - Read 10 msec timer (module specific) (temporary)

F(1)*A(12)  - Read the element from the threshold data array
	      indicated by TRPNTR (0-255). This must be preceded
	      by a F(17)*A(0).

F(1)*A(13)  - Read reset register #1

F(1)*A(14)  - Read reset register #2

F(1)*A(15)  - Read the abort register

F(4)*A(0)   - Read all integrated values from non-volatile RAM
	      This consists of 256 longword values. Whether the
	      all-time or the temporary sums are returned depends
	      on the value sent by the preceding F(19)*A(0).

F(6)*A(0)   - Read module number (205 decimal)

F(6)*A(1)   - Read firmware version number
	      (currently 2.16 for Linac/Booster, 2.18 for MI/Pbar,
	       and 2.17 for Tev/SY)

F(6)*A(2)   - Read last ADC channel value (for debugging)

F(6)*A(3)   - Read last pulse train channel value (for debugging)

F(6)*A(4)   - Read processor register indicated by REGNUM
	      (should be preceded by F(19)*A(9))

F(6)*A(5)   - Read a previously selected word from memory
	      (for debugging purposes only)

F(6)*A(6)   - Read a previously selected longword from memory
	      (for debugging purposes only)

F(6)*A(7)   - Read the status of the RAM lithium batteries

F(8)*A(0)   - LAM test ('all hardware' function)

F(9)*A(0)   - Reset module ('all hardware' function)

F(16)*A(0-6)- Simulate clock event interrupts

F(16)*A(7)  - Write clock event

F(16)*A(8)  - Enable/disable all data acquisition by the module

F(16)*A(9)  - Enable/disable all MADC inputs

F(16)*A(10) - Enable/disable all pulse train inputs

F(16)*A(11) - Enable/disable MADC calibration mode

F(16)*A(12) - Enable/disable pulse train calibration mode

F(16)*A(15) - Enable/disable clock input signal

F(17)*A(0)  - Select threshold number to change (0-255)
	      This must be preceded by a F(17)*A(0).

F(17)*A(1)  - Set previously selected threshold value

F(17)*A(8)  - Select new list id (low byte-list #)(hi byte-element #)

F(17)*A(9)  - Set flag word / preceding event word

F(17)*A(10) - Set operation word

F(17)*A(11) - Set answer offset word

F(17)*A(12) - Perform data list operations (add/change/delete)

F(19)*A(0)  - Set word pointer to low word and initialize pointer
	      for block transfer

F(19)*A(1)  - Alter clock decoder information

F(19)*A(2)  - Write FOP command

F(19)*A(3)  - Write FOP data

F(19)*A(4)  - Write data to a previously selected memory location

F(19)*A(5)  - Select a memory location for later reading
	      (for debugging purposes only)

F(19)*A(6)  - Set real time array pointer (0-255) (RLPNTR)

F(19)*A(7)  - Set all-time summary data array pointer (0-255) (ARPNTR)

F(19)*A(8)  - Set temporary summary array pointer (0-255) (TMPNTR)

F(19)*A(9)  - Select processor register for future diagnostic reads (0-15)

F(19)*A(10) - Set long word array pointer (LNPNTR)

F(19)*A(13) - Set all integrated values in non-volatile RAM to zero
	      (or non-zero data counts)

F(19)*A(15) - Clear temporary sums


Memory Map:


	   Z8002 Memory Space		   	 Z8002 I/O Space

       0+-----------------------+	       0+---------------+
	| EPROM           (8KB) |		|		|
    2000|-----------------------|       	|		|
	|                       |		|		|
    4000|-----------------------|		|		|
	| Clock Event RAM       |		|    unused	|
    4200|-----------------------|		|		|
	| I/O Page       	|         	|               |
    4300|-----------------------|		|		|
	|        unused       	|         	|		|
    6000|-----------------------|	        |               |
	| RAM on 'A' board (8KB)|		|		|
    8000|-----------------------|		|       	|
	| Off-board I/O page    |		|               |
    8100|-----------------------|		|		|
	|			|		|		|
	|			|		|		|
	|        unused		|		|		|
	|			|		|		|
	|			|		|		|
    E000|-----------------------|		|		|
	| List memory           |               |		|
    FFFF+-----------------------+           FFFF+---------------+

Addresses:

        Address Range	Purpose
        ------------- 	--------------------------
	   0 to 1FFF	EPROM (8 KB configured, expandable to 16 KB)
	4000 to 41FF	Clock event RAM (write only, word addr, bytes)
	4200 to 42FF	Memory mapped I/O for A board devices
	6000 to 7FFF	Nonvolatile RAM on A board
	77E4 to 7FFF	Nonzeroed RAM
	8000 to 8100	Memory mapped I/O for off-board devices
	8000 to 804E	9513 pulse train counters
	8050 to 807E	ADC control and readback
	8080 to 8100	Miscellaneous clock event registers
	E000 to FFFF	Memory on TCLK/RAM board for data lists


Register Conventions:


These conventions apply to the entire module.  Register conventions
within a particular task are shown with the task code.

R0   -	Reserved for 'background' must be preserved by interrupt code
R1   -	   "      "       "        "   "      "     "      "      "
R3   -	   "      "       "        "   "      "     "      "      "
R4   -	   "      "       "        "   "      "     "      "      "
R5   -	   "      "       "        "   "      "     "      "      "
R6   -	   "      "       "        "   "      "     "      "      "
R7   -	Reserved for CAMAC application code (List data low word)
R8   -	   "      "    "        "       "
R9   -	   "      "    "        "       "
R10  -	   "      "    "        "       "   (List data high word)
R11  -	   "      "    "        "       "
R12  -	   "      "    "        "       "
R13  -	   "	  "    "	"	"
R14  -  CAMAC interface read/write address 
R15  -	System stack pointer


Memory mapped I/O addresses on the CPU board:


Signetics 2651 programmable communications interface (PCI)

PCI data register (byte R/W)				0x4291
PCI status register (byte R/W)				0x4293
PCI mode register - internal mux (byte R/W)		0x4295
PCI command register (byte R/W)				0x4297

CPU's Am9513 timer, CTM

Timer data register (word R/W)				0x4280
Timer command and status register (word R/W)		0x4282

Interrupt controller A, ICA (AMD9519, U24 on schematic)

ICA data register (byte R/W)				0x42A1
ICA command and status reg (byte R/W)			0x42A3

Interrupt controller B, ICB (AMD9519, U25 on schematic)

ICB data register (byte R/W)				0x42B1
ICB command and status reg (byte R/W)			0x42B3

CAMAC interface addresses

Dataway R/W buffer address (16-bit word)		0x4200
LAM F/F (data =1 to set, =0 to clear)			0x4220
LAM enable (data =1 to set, =0 to clear)		0x4224

Module test points (data =1 to set, =0 to clear  -- write only)

Test point #1 (latched) front panel test point on
development modules, unconnected on production units	0x4228
Test point #2 (latched) connected to front panel LED	0x422C

ADC addresses

ADC #1 channel select and output registers		0x8050
ADC #2 channel select and output registers (optional)	0x8054

9513 pulse train counter addresses

Data output register for 9513 #1 (counters 1-5)		0x8000
Control register for 9513 #1 (counters 1-5)		0x8002
Data output register for 9513 #2 (counters 6-10)	0x8004
Control register for 9513 #2 (counters 6-10)		0x8006
Data output register for 9513 #3 (counters 11-15)	0x8008
Control register for 9513 #3 (counters 11-15)		0x800A
Data output register for 9513 #4 (counters 16-20)	0x800C
Control register for 9513 #4 (counters 16-20)		0x800E
Data output register for 9513 #5 (counters 21-25)	0x8010
Control register for 9513 #5 (counters 21-25)		0x8012
Data output register for 9513 #6 (counters 26-30)	0x8014
Control register for 9513 #6 (counters 26-30)		0x8016

Clock event register addresses

Accelerator reset clock event register			0x8080
Accelerator reset clock event register #2		0x8082
Abort clock event register				0x8084
General clock event register				0x808C
Clock input signal enable/disable register		0x808E


Data Array Assignments:


Linac/Booster Module:

Array value #1   ----> Linac intensity(13)
Array value #2   ----> Linac resets (13)
Array value #3   ----> Linac cycles with beam (13)
Array value #4   ----> Linac intensity(14)
Array value #5   ----> Linac resets (14)
Array value #6   ----> Linac cycles with beam (14)
Array value #7   ----> Linac intensity(15)
Array value #8   ----> Linac resets (15)
Array value #9   ----> Linac cycles with beam (15)
Array value #10  ----> Linac intensity(16)
Array value #11  ----> Linac resets (16)
Array value #12  ----> Linac cycles with beam (16)
Array value #13  ----> Linac intensity(17)
Array value #14  ----> Linac resets (17)
Array value #15  ----> Linac cycles with beam (17)
Array value #16  ----> Linac intensity(19)
Array value #17  ----> Linac resets (19)
Array value #18  ----> Linac cycles with beam (19)
Array value #19  ----> Linac intensity(1C)
Array value #20  ----> Linac resets (1C)
Array value #21  ----> Linac cycles with beam (1C)
Array value #22  ----> Booster intensity (13)
Array value #23  ----> Booster cycles with beam (13)
Array value #24  ----> Booster intensity (14)
Array value #25  ----> Booster cycles with beam (14)
Array value #26  ----> Booster intensity (15)
Array value #27  ----> Booster cycles with beam (15)
Array value #28  ----> Booster intensity (16)
Array value #29  ----> Booster cycles with beam (16)
Array value #30  ----> Booster intensity (17)
Array value #31  ----> Booster cycles with beam (17)
Array value #32  ----> Booster intensity (19)
Array value #33  ----> Booster cycles with beam (19)
Array value #34  ----> Booster intensity (1C)
Array value #35  ----> Booster cycles with beam (1C)
Array value #36  ----> NTF beam enable events (1A)

Main Injector/Pbar Module:

Array value #1   ----> Main Injector injection intensity(20)
Array value #2   ----> Main Injector flattop intensity (20)
Array value #3   ----> Main Injector aborted intensity (20)
Array value #4   ----> Main Injector ramp count (20)
Array value #5   ----> Main Injector abort count (20)
Array value #6   ----> Main Injector resets (20)
Array value #7   ----> Main Injector cycles with beam (20)
Array value #8   ----> Main Injector injection intensity(21)
Array value #9   ----> Main Injector flattop intensity (21)
Array value #10  ----> Main Injector aborted intensity (21)
Array value #11  ----> Main Injector ramp count (21)
Array value #12  ----> Main Injector abort count (21)
Array value #13  ----> Main Injector resets (21)
Array value #14  ----> Main Injector cycles with beam (21)
Array value #15  ----> Main Injector injection intensity(29)
Array value #16  ----> Main Injector flattop intensity (29)
Array value #17  ----> Main Injector aborted intensity (29)
Array value #18  ----> Main Injector ramp count (29)
Array value #19  ----> Main Injector abort count (29)
Array value #20  ----> Main Injector resets (29)
Array value #21  ----> Main Injector cycles with beam (29)
Array value #22  ----> Main Injector injection intensity(2A)
Array value #23  ----> Main Injector flattop intensity (2A)
Array value #24  ----> Main Injector aborted intensity (2A)
Array value #25  ----> Main Injector ramp count (2A)
Array value #26  ----> Main Injector abort count (2A)
Array value #27  ----> Main Injector resets (2A)
Array value #28  ----> Main Injector cycles with beam (2A)
Array value #29  ----> Main Injector injection intensity(2B)
Array value #30  ----> Main Injector flattop intensity (2B)
Array value #31  ----> Main Injector aborted intensity (2B)
Array value #32  ----> Main Injector ramp count (2B)
Array value #33  ----> Main Injector abort count (2B)
Array value #34  ----> Main Injector resets (20B)
Array value #35  ----> Main Injector cycles with beam (2B)
Array value #36  ----> Main Injector injection intensity(2D)
Array value #37  ----> Main Injector flattop intensity (2D)
Array value #38  ----> Main Injector aborted intensity (2D)
Array value #39  ----> Main Injector ramp count (2D)
Array value #40  ----> Main Injector abort count (2D)
Array value #41  ----> Main Injector resets (2D)
Array value #42  ----> Main Injector cycles with beam (2D)
Array value #43  ----> Main Injector injection intensity(2E)
Array value #44  ----> Main Injector flattop intensity (2E)
Array value #45  ----> Main Injector aborted intensity (2E)
Array value #46  ----> Main Injector ramp count (2E)
Array value #47  ----> Main Injector abort count (2E)
Array value #48  ----> Main Injector resets (2E)
Array value #49  ----> Main Injector cycles with beam (2E)
Array value #50  ----> Main Injector injection intensity(20) (low)
Array value #51  ----> Main Injector flattop intensity (20) (low)
Array value #52  ----> Main Injector cycles with beam (20) (low)
Array value #53  ----> Main Injector injection intensity(21) (low)
Array value #54  ----> Main Injector flattop intensity (21) (low)
Array value #55  ----> Main Injector cycles with beam (21) (low)
Array value #56  ----> Main Injector injection intensity(29) (low)
Array value #57  ----> Main Injector flattop intensity (29) (low)
Array value #58  ----> Main Injector cycles with beam (29) (low)
Array value #59  ----> Main Injector injection intensity(2A) (low)
Array value #60  ----> Main Injector flattop intensity (2A) (low)
Array value #61  ----> Main Injector cycles with beam (2A) (low)
Array value #62  ----> Main Injector injection intensity(2B) (low)
Array value #63  ----> Main Injector flattop intensity (2B) (low)
Array value #64  ----> Main Injector cycles with beam (2B) (low)
Array value #65  ----> Main Injector injection intensity(2D) (low)
Array value #66  ----> Main Injector flattop intensity (2D) (low)
Array value #67  ----> Main Injector cycles with beam (2D) (low)
Array value #68  ----> Main Injector injection intensity(2E) (low)
Array value #69  ----> Main Injector flattop intensity (2E) (low)
Array value #70  ----> Main Injector cycles with beam (2E) (low)
Array value #71  ----> Debuncher production cycles
Array value #72  ----> Accumulator unstack X bunch
Array value #73  ----> Accumulator unstack Y bunch
Array value #74  ----> Accumulator unstack Z bunch
Array value #75  ----> Accumulator to Main Injector transfers

Tevatron/Switchyard Module:

Array value #1   ----> Tevatron injection intensity (49)
Array value #2   ----> Tevatron flattop intensity (49)
Array value #3   ----> Tevatron aborted intensity (49)
Array value #4   ----> Tevatron ramp count (49)
Array value #5   ----> Tevatron abort count (49)
Array value #6   ----> Tevatron quench count (49)
Array value #7   ----> Tevatron resets (49)
Array value #8   ----> Tevatron cycles with beam (49)
Array value #9   ----> Tevatron injection intensity (C1)
Array value #10  ----> Tevatron flattop intensity (C1)
Array value #11  ----> Tevatron aborted intensity (C1)
Array value #12  ----> Tevatron ramp count (C1)
Array value #13  ----> Tevatron abort count (C1)
Array value #14  ----> Tevatron quench count (C1)
Array value #15  ----> Tevatron resets (C1)
Array value #16  ----> Tevatron cycles with beam (C1)
Array value #17  ----> Proton West intensity
Array value #18  ----> Proton West cycles with beam
Array value #19  ----> Proton Center intensity
Array value #20  ----> Proton Center cycles with beam
Array value #21  ----> Proton East Total intensity
Array value #22  ----> Proton East Total cycles with beam
Array value #23  ----> Meson West intensity
Array value #24  ----> Meson West cycles with beam
Array value #25  ----> Meson Center intensity
Array value #26  ----> Meson Center cycles with beam
Array value #27  ----> Meson East intensity
Array value #28  ----> Meson East cycles with beam
Array value #29  ----> Neutrino West intensity
Array value #30  ----> Neutrino West cycles with beam
Array value #31  ----> Neutrino Center intensity
Array value #32  ----> Neutrino Center cycles with beam
Array value #33  ----> Neutrino East Total intensity
Array value #34  ----> Neutrino East Total cycles with beam
Array value #35  ----> Muon intensity
Array value #36  ----> Muon cycles with beam
Array value #37  ----> Extraction TLM
Array value #38  ----> TLM cycles with beam
Array value #39  ----> Proton East intensity
Array value #40  ----> Proton East cycles with beam
Array value #41  ----> Broadband intensity
Array value #42  ----> Broadband cycles with beam
Array value #43  ----> Neutrino East intensity
Array value #44  ----> Neutrino East cycles with beam
Array value #45  ----> Neutrino Test intensity
Array value #46  ----> Neutrino Test cycles with beam
Array value #50  ----> Tevatron injection intensity (low intensity monitor) (49)
Array value #51  ----> Tevatron flattop intensity (low intensity monitor) (49)
Array value #52  ----> Tevatron cycles with beam (low intensity monitor) (49)
Array value #53  ----> Tevatron injection intensity (low intensity monitor) (C1)
Array value #54  ----> Tevatron flattop intensity (low intensity monitor) (C1)
Array value #55  ----> Tevatron cycles with beam (low intensity monitor) (C1)
Array value #56  ----> Store initial intensity
Array value #57  ----> Number of stores
Array value #58  ----> Stores with beam
Array value #59  ----> Store final intensity
Array value #60  ----> End of stores with beam
Array value #61  ----> CDF luminosity
Array value #62  ----> CDF losses

Security, Privacy, Legal