The madc command provides scripted support for the Mesytec 32 channel peak sensing adc module. For scaler support for this module's dead time counters, see the madcscaler command.
As with all VM-USB module support commands, madc is a command ensemble with subcommands that create and configure modules as well as cget which introspects a module configuration.
create creates an object with the specified
name
. Additional options are treated like
configuration options. config configures
an existing module, and cget returns a list of
configuration name/value pairs that describe the configuration of
the module.
It is important to note that the module configuration does not actually get loaded until the run is initialized. The order in which configuration parameter are supplied is therefore unimportant. Think of the configuration options as being accumulated and then applied as the run starts. Only modules that are in stack are configured.
-base
address
address
must be the module base
address as configured in its rotary switches.
This base address is used to access the module's register
and event memory.
Each module must be programmed and hardware configured with a different base address. The address used will be an A32 VME address.
-id
vsn
vsn
will be used as the module's
identifier or virtual slot number.
The vsn
will be encoded into the
event data that is returned by the module. This, in turn
is normally used by event decoders to determine which parameters
the channels of the module should be unpacked into.
Each module should be given a unique vsn
.
-ipl
irqlevel
If the module will be used to trigger an interrupt driven
stack, the irqlevel
parameter must
be programmed to a valid non zero interrupt priority level
(1 through 7).
This must match the interrupt priority level used to trigger
the stack.
The default value of 0 disables module interrupts.
-vector
statusId
If the module will be used to trigger an interrupt driven
stack, the statusId
must be programmed
to a non zero 8 bit status id, or vector
(between 1 and 255
The value used must match the value of the
-vector
configuration parameter used to
trigger the stack.
The default value for this parameter is 0
Note that the VMUSB uses a 16 bit status/ID cycle to
read the interrupt vector from the module, while the
actual status id is 8 bits wide. The VME standard
is ambiguous about how the top bits of this 16 bit value
are set. The MADC32 sets those top bits to 0xff. Therefore
a -vector
0x80 produces
a vector, as seen by the VMUSB of 0xff80.
-timestamp
onoff
This option controls whether or not the
module tags each event with a trigger number or with a
timestamp (see also the
-timingsource
and
-timingdivisor
options).
The onoff is a boolean value. If true, the module tags events with a timestamp. If false, with a trigger number.
The default value for this parameter is false
-gatemode
modeThe MADC32 has a pair of gate inputs. The inputs may be used either as separate gates, where each gate controlls 16 of the 32 channels, or as common where either input will gate all 32 channels.
The value mode
should be either
separate or common.
Note that if you use separate, you will get data from the modules as if there were two independent 16 channel adc modules with the same virtual slot number. You may get zero, one or two packets of data from this module for each VMUSB Stack trigger. One packet will contain any converting channels for channels 0-15, the other for channels 16-31.
The default value of this parameter is common
-gategenerator
onoffThe module can either use the gates as provided or can insert a gate and delay generator between the gate inputs and the actual gates seen by the ADCs. Since in most cases, gate must be stretched and timed to match the ADC inputs, this feature can reduce the external electronics needed to properly gate the adc.
The onoff
is a boolean that if
true enables this gate generator, if false, disables it.
See also the -holddelays
and
-holdwidths
configuration parameters
that control the gate and delay parameters for each of these
resources.
By default, the value of this parameters is false.
Beginning with 11.2-006, a new set of values has been added, in addition to the valid booleans. The full list of values and behaviors is as follows:
If -gatemode
is common,
gate generator 0 only is enabled, otherwise, both
gate generators are enabled. Note in this and
the following discussions, gate generator 1 can only be
enabled if -gatemode
is
separate. This is stated in the
MADC32 manual.
Neither gate generator is enabled, regardless of
-gatemode
Regardless of -gatemode
, gate generator 0
is enabled. Gate generator 1 is not enabled.
If -gatemode
is separate, gate generator
1 is enabled. If -gatemode
is
common, an error is thrown when you
try to start the run.
The error is thrown then because there's no other time that drivers can perform validations across more than one option.
-holddelays
delayList
If the gate generators are enabled (see
-gategenerator
above), the
delayList
is a Tcl list consisting of
the two delay parameters, one for each of the gate and
delay generators. See the MADC32 manual for a description of
the meaning of these values, which are just the values
programmed into the module registers.
By default, the value of this parameter is a list of two 15 values.
-holdwidths
widthList
If the gate generators are enabled (see
-gategenerator
above), the
widthList
is a Tcl l ilst
consisting of the two gate and delay generator width
parameters. See the MADC32 manual for a description
of the meaning of these values, which are just the
values programmed into the module registers.
By default the value of this parameter is a list of two 20 values.
-inputrange
rangeSelector
Programs the input range for the module.
The rangeSelector
must
4v, 8v,
or 10v. Where the selector
represents the input range in volts.
The default value of this parameter is 4v.
-ecltermination
onoffThis parameter when true enables the ECL input termination. If disabled (Tcl false), the termination is off. If you are bussing the ECL inputs, only the final module in the bus should have terminatinon enabled, all other modules, should have termination turned off.
The default for this parameter is true
-ecltiming
onoffThis parameter, when true enables the gate1 ECL input to to be a clock source for the timestamp if true. If false, The ECL G1 input is an ECL gate1.
By default this is false.
-nimtiming
onoffIf true, enables the NIM Gate1 input to be a clock source for the timestamp. If not, the NIM Gate1 input is an adc gate.
By default, -nimtiming
is
false.
-timingsource
sourceNameSpecifies the source of the clock for timestamps. If external, whichever of the NIM or ECL GATE1 inputs are enabled is the clock source. If vme the VME 16Mhz backplane clock is the clock.
By default -timingsource
is
vme.
-timingdivisor
log2
Specifies a scale-down value for the timestamp clock.
At the time I'm typing this, this value is log base
2 of the scale down, that is
the final scale down is 1 << log2
.
By the time we get installed, I am supposed to have
some firwmare that will allow this to be a 16 bit
direct scaledown (e.g. the scaledown would be between 1 and
65535).
The default for this is 15.
-thresholds
valueList
Supplies the per channel thresholds for the adc.
Channels which convert below their threshold are suppressed
from the data stream reducing both data volume and
dead-time. The valueList
is a
32 element Tcl list of the integer thresholds.
Note that at the time I'm typing this, channel thresholds have not yet been implemented in the firmware. The firmware I bring with me at installation time will hopefully implement this feature.
By default this is a 32 element list containing all 0.
-nimbusy
busyselecstThis option selects which signal is presented at the NIM busy output connector. Note that this can interact with the mxdcrcbus driver. See more below.
Legal values for this parameter are:
The default. The output reflects the module busy. Busy is asserted when the module is converting as a result of a gate or when the module's buffer is full.
For single event mode, full means that the event most recently converted has not yet been read out. For multi event mode, this means that there is not sufficient buffer space for a maximally sized next event.
The Gate0 signal. Note that if the internal gate and delay generator is in use, this will reflect the output of that gate generator. This allows you to see if the delay and width parameters of the gate generator is properly set.
The Gate1 signal. Again if the gate generator is enabled, you can use this to monitor the gate signal after it has been modified by the gate and delay generator.
The Busy output is used as a CBus master. See the IMPORTANT NOTE below.
![]() | IMPORTANT NOTE: |
---|---|
If this module is being used as the master for the CBus in a mxdcrcbus slow control module, this must be set to cbus. Otherwise once the first run starts, you will no longer be able to perform control operations over Cbus connected moduls |
-multievent
booleanAllows the module to be used in multi-event mode. This is normally done in conjunction with the madcchain configuration command. It also usually requires a custom SpecTcl version to handle the data from this device.
the default value for this parameter is false which runs the module in single event mode.
This is false by default.
-irqthreshold
integerSets the interrupt threshold. When a number of complete events have put at least this number of longwords in the fifo, if interupts are enabled, the module will interrupt.
This is 0 by default.
-resolution
2k|4k|4khires|8k|8khiresSets the resolution of the module. This has an impact on the conversion time.
This defaults to 8k
Example 1. Sample use of madc command
set madcTimeDivisor 14 madc create adc -base 0x40000000 -id 5 -ipl 0madc config adc -gatemode common -gategenerator disabled madc config adc -inputrange 8v madc config adc -timestamp on -timingsource vme -timingdivisor $madcTimeDivisor
for {set i 0} {$i < 32} {incr i} { lappend thresholds 0
} madc config adc -thresholds $thresholds
![]()
thresholds
that
contains a list of 32 zeroes. This list will be used
to program the adc thresholds.
Normally these values will neither be zero nor uniform
from channel to channel. It may be best to read them from
some external file.
thresholds
variable
and programs the channel thresholds of the ADC.