CCAENV830 -- Support driver for the CAEN V820/V830 latching scaler module.


#include <CCAENV830.h>
 class CCAENV830 {

  CCAENV830(int slot, int crate = 0, bool geo = true, unsigned long base = 0)
          throws std::string;

  void Enable(int nChannel)
          throws std::string;
  void Disable(int nChannel)
          throws std::string;
  void SetEnableMask(int nMask);
  void SetDwellTime(int n400ns);
  void SetTriggerMode(TriggerMode mode)
          throws std::string;
  void SetWide();
  void SetNarrow();
  void EnableHeader();
  void DisableHeader();
  void FPClearsMEB(bool state);
  void EnableAutoReset();
  void DisableAutoReset();
  bool isDataReady();
  bool isAlmostFull();
  bool isFull();
  bool isGlobalDready();
  bool isGlobalBusy();
  void Reset();
  void Clear();
  void Trigger();
  void SetTriggerCounter(int n);
  void SetAlmostFullLevel(int n);
  int GetMEBEventCount();
  int ReadEvent(void* pBuffer);
  int ReadEvent(DAQWordBufferPtr& rBufferPtr);
  int ReadEvent(DAQWordBuffer& rBuffer, int nOffset);
  int ReadCounter(int nChannel);


The CAEN V830 scaler is a 32 channel latching VME scaler. The scaler can be externally latched, unlatched or latched periodically using an internal timer. Once latched scaler data can either be read from a multi-event buffer. The V820, also supported by this software is identical to the V830 except that it does not have a multievent buffer. The raw (unlatched) counters can also be read.

Modules can be geographically addresssed or relative to a module base address.

Public member functions

CCAENV830(int slot, int crate, bool geo, unsigned long base);

Constructs a CCAENV830 object that can be used to manipulate an actual scaler module. slot is used to geographically address the module if the geo parameter is false, or to assign a virtual slot number to a module if geo is true. crate is used to select the VME crate. If omitted it defaults to 0 which is suitable for systems with single crates.

If geo is falsed, the modules is addressed relative to the base parameter, which must match the base address set in the module's rotary switches.

void Enable(int nChannel);

Enables channel nChannel. A std::string exception will be thrown if the nChannel parameter is not a legal channel number (0 through 31).

void Disable(int nChannel);

Disables channel nChannel from counting. If nChannel is not a legal channel number (0 through 31), a std::string exception will be thrown.

void SetEnableMask (int nMask);

Sets the mask of channel enables. Each bit in the 32 bit nMask represents a channel. Channel 0 is the least significant bit, and channel 31 the most. Channels with bits set are enabled.

void SetDwellTime(int n4ppns);

In periodic trigger mode, this sets the number of 400ns clock ticks between periodic triggers.

void SetTriggerMode (TriggerMode mode);

Selct the module trigger mode. See "Types and public data" for more information about the set of trigger types supported, and how to specify them.

void SetWide (void);

Sets the scaler mode to wide in this mode, channel data is 32 bits wide and no channel number information is supplied. See also SetNarrow

void SetNarrow (void);

Sets the scaler readout mode to narrow. In narrow mode, each channel provides only 26bits of count information, The data are labelled with the channel numbers in bits 27-31 as well.

void EnableHeader (void);

Enables header data from the scaler. This causes data from the multi event buffer to return a header prior to the actual scaler data that describes the trigger condition, the trigger number, the module geographical addres, and the number of channels that follow.

void DisableHeader (void);

Turns off header data insertion. See EnableHeader above for more information.

void FClearsMEB (bool state);

If state is true then a front panel clear also clears the multi-event buffer. Otherwise, only the counters are cleared.

void EnableAutoReset (void);

If called, latches also cause the counters to clear.

void DisableAutoReset (void);

If called, latches do not cause counters to clear.

bool isDataReady (void);

Returns true if the multi event memory has at least one event stored in it.

bool isAlmostFull (void);

Returns true if the multievent buffer contains at least the number of words programmed into the almost full register via SetAlmostFullLevel.

bool isFull (void);

Returns true if the multi-event buffer is completely full of data. The V830 has 32Kwords of multi-event buffer. What this means in terms of event depth depends on how the scaler has been set up.

bool isGlobalDReady (void);

Returns true if the global data ready line on the control bus is full. This differential ECL input is the wire tied OR of all the module data readys on the bus. It therefore indicates that some module on that control bus has data, but not necessarily this module.

bool isGlobalBusy(void);

Returns true if the control bus global busy line is true. This line is the wire tied or of all of the module busys on the control bus. This indicates that some module is busy, but not necessarily this module.

void Reset (void);

Peforms a software reset on the module, returning it to the default condition.

void Clear (void);

Resets the event counters, the multi event buffer, the trigger counter, and the event number register.

void Trigger (void);

Triggers a latch and store on the module, if the module is in random trigger mode. The scaler values are latched and transferred into multi event memory.

void SetTriggerCounter (int n);

Sets the value of the trigger counter. The trigger counter is returned as a field of the header word if enabled.

void SetAlmostFullLevel (int n);

Sets the number of words in the multi-event buffer that define the almost full condition. See also isAlmostFull

int GetMEBEventCount (void);

Returns the number of events in the multi-event buffer.

int ReadEvent (void* pBuffer);

Reads an event from the MEB of the scaler into the buffer pointed to by pBuffer. The number of 16 bit words read is returned (e.g. 2 for each longword). It is possible to have 0 returned if the MEB has no events. Note that no range checking is or can be done on the buffer, the user must provide a buffer large enough to hold the data.

int ReadEvent (DAQWordBufferPtr& rBufferPtr);

Reads an event directly into a spectrodaq managed buffer via a DAQWordBufferPtr pointer like object. The value of rBufferPtr is modified so that on return it 'points' past the data that has been read in. The return value is the number of 16 bit words read from the module.

int ReadEvent (DAQWordBuffer& rBuffer, int nOffset);

Reads an event into a spectrodaq managed buffer (rBuffer), starting nOffset words from the start of that buffer. The return value is the number of 16 bit words read from the scaler.

int ReadCounter (int nChannel);

Reads the raw counter value for channel nChannel. Note that this is not a latched value and therefore can be changing as it is read.

Types and public data

The trigger mode of the modules is specified using the TrigggerMode data type. This is an enumerated type with the following possible values:


Triggers are disabled.


Random triggers. Triggers are accepted from the front panel and programmatically.


Periodic triggers. Triggers happen at a rate determined by the dwell time programmed via SetDwellTime


Various parameter range errors are signalled by throwing a std::string exception.