#include <CADC2530.h>
class CADC2530 {CADC2530(int crateNum = 0, long nBase = 0);
~CADC2530();
static bool checkCard(int nCrate, long nBase, unsigned short& devType, unsigned short& mfgId);
static unsigned short volt2lld(double volts);
static unsigned short volt2uld(double volts);
int readListEvents(void* buffer, int& nEvents);
int readHistogramChannel(void* buffer, int channel);
void clearHistogramMemory();
void resetCard();
void clearListAddress();
unsigned int getListAddress();
void arm();
void disarm();
bool isArmed();
void modeHistogram(bool individualGates);
void modeGate();
bool dataReady();
void enableGate();
void disableGate();
void enableZeroCnv();
void disableZeroCnv();
void dataReadyOnEvent();
void dataReadyOnFullness();
void setLLD(unsigned short register);
unsigned short getLLD();
void setULD(unsigned short register);
unsigned short getULD();
void clearFullnessFlags();
bool isChannelFull(unsigned short channel);
bool channelHasData(unsigned short channel);
bool isListFull();
bool isListHalfFull();
unsigned int getEventCounter();
void clearEventCounter();
}
The Hytec NADC 2530 is an 8 channel high resolution ADC. The area of application is intended to be high resolution gamma spectroscopy. This class provides support for this module. While the target for this support is the NSCLDAQ readout frameworks, support is general and does not assume it will be used within NSCLDAQ.
The NADC 2530 can produce either list mode (event by event) data
or it can be programmed to produce full resolution histograms.
The CADC2530
class supports both modes of operation.
CADC2530(int crateNum = 0, long nBase = 0);
Constructs an instance of a
CADC2530
class. The object created allows you to manipulate a single
module.
crateNum
is the VME crate in which the
module lives. For single crate systems, this is
0 for multi-crate systems, use the
cratelocator application to
determine which crate is which.
nBase
is the base address that has been assigned to the module via
it's addressing jumper block.
It is an error, which results in an
std::string
exception being thrown for the crate and base address to
not correspond to an NADC 2530 module.
~CADC2530();
Releases all mapping and memory resources associated with a
previously constructed
CADC2530
module.
static bool checkCard(int nCrate, long nBase, unsigned short& devType, unsigned short& mfgId);
Determines if the base address
nBase
in VME crate
nCrate
corresponds to an NADC 2530 module.
If it does, true
is returned, otherwise
false
The devType
and
mfgId
parameters are output parameters
that will be filled in with the module's device and manufacturer
id's respectively.
static unsigned short volt2lld(double volts);
The NADC 2530 module can constrain converted channels to lie between a lower and upper leve threshold. This threshold is common across all channels in the module. The relationship between voltage and the value of the register is a non-linear formula described in the NADC2530 manual.
This method converts floating point voltages into a value
that can be passed to the
setLLD
function of a specific
module object.
static unsigned short volt2uld(double volts);
The NADC 2530 module can constrain converted channels to lie between a lower and upper leve threshold. This threshold is common across all channels in the module. The relationship between voltage and the value of the register is a non-linear formula described in the NADC2530 manual.
This method converts floating point voltages into a value
that can be passed to the
setULD
function of a specific
module object.
int readListEvents(void* buffer, int& nEvents);
Reads at most nEvents
complete events
from the module's list memory to the memory pointed to by
buffer
.
The buffer
should be at least 40*nEvents bytes long
to be able to accomodate the worst case data needs.
On return,
nEvents
is modified to be the number of events actually read.
The function returns the number of bytes of data read.
For this to make sense, the module must be in
list mode rather than histogram mode. If the module is in
histogram mode, undefined, bad things will happen.
int readHistogramChannel(void* buffer, int channel);
Reads the channels of a histogram. The module must be in histogram mode.
The histogram is read into the storage pointed to by
buffer
.
channel
selects which channel,
1 through 8 is transferred.
buffer
must be at least 8192 uint32_t long. Each channel
of the histogram occupies one longword of buffer
.
void clearHistogramMemory();
Clears all the channels of all of the histograms in the module. The module should be in histogram mode.
void resetCard();
Resets the card to its factory default mode.
void clearListAddress();
In list mode, the module contains list memory. The list address is the offset to this memor in which the next event will be stored. invoking this member function resets that offset to zero.
unsigned int getListAddress();
Returns the current value of the list offset.
void arm();
Arms the module. Arming the module is what starts it taking data, or histogramming, depending on the mode.
void disarm();
Disarms the module. Disarming the module stops data taking or histogramming.
bool isArmed();
Returns true if the module is armed.
void modeHistogram(bool individualGates);
Sets the module in histogramming mode. If
individualGatse
is
true, adc channels
digitize when their associated gate input tells them to.
If false the adcs self trigger.
void modeGate();
This method is only useful in list mode. It informs the module to take data when the common gate is strobed.
bool dataReady();
Returns true if the module is in list mode and has at least one event ready to be read from list memory.
void enableGate();
Enables the front panel master gate.
void disableGate();
Disables the front panel master gate.
void enableZeroCnv();
Enables the inclusion of conversions below the low level discriminator in the list mode data.
void disableZeroCnv();
Disables the inclusion of conversions below the low level discriminator setting in list mode data (enables zero supression).
void dataReadyOnEvent();
Enables the setting of the data ready condition when the first event is stored.
void dataReadyOnFullness();
Enables the setting of data ready only when either a histogram channel overflows (histogram mode), or when the list mode memory is full.
void setLLD(unsigned short register);
Sets the value of the lower level discriminator for the ADC.
register
should be a value returned from
volt2lld
.
unsigned short getLLD();
Returns the low level discriminator value. This is the computed DAC value for the LLD, not the voltage. The DAC value is related to the voltage as follows: DAC = (((V/3.2764)/(0.25/4095)) <<2)&0x3ffc
void setULD(unsigned short register);
Sets the DAC of the upper level discriminator.
register
should be a value returned from
volt2uld
.
unsigned short getULD();
Returns the value of the upper level discriminator DAC register. This is related to the voltage as follows: DAC = ((((V/3.2764)-2)/(0.25/4095))<<2)&0x3FFC
void clearFullnessFlags();
Clears any fullness condition.
bool isChannelFull(unsigned short channel);
Returns
true
if the histogram for the specified
channel
has overflowed.
bool channelHasData(unsigned short channel);
Returns true if the histogram for the
specified channel
has at least one channel with 1/2 full scale counts.
bool isListFull();
Returns true if the list mode memory is full. Current firmware will actually set the state to full if the memory has insufficient room for the worst case event (40 bytes/10 32 bit longwords). This ensures that the list memory will only contain complete events.
bool isListHalfFull();
Returns true if the module is in listmode and the list memory is more than 1/2 full.
unsigned int getEventCounter();
Returns the number of events that have been acquired since the last clear.
void clearEventCounter();
Clears the event counter.