CALCulate:COMPare:MASK[:<width>]

34980A

CALCulate:COMPare:MASK[:<width>]

Syntax

CALCulate:COMPare:MASK[:<width>] <data>, (@<ch_list>)

CALCulate:COMPare:MASK? (@<ch_list>)

Description

This command is used in conjunction with the CALCulate:COMPare:DATA command to set the digital mask data for pattern comparisons on the specified digital input channels. You can use the pattern comparison feature to generate an alarm or hardware interrupt condition (34950A only) when a specific digital pattern is detected. Pattern comparisons always start on the lowest-numbered channel in the bank and extend to all channels involved in the channel width (see CONFigure:DIGital:WIDTh command).

Used With:

  • 34950A Digital I/O Module (digital input channels only)

  • 34952A Multifunction Module (digital input channels only)

Parameters

Name

Type

Range of Values

Default Value

<width>

Discrete

{BYTE|1|WORD|2|LWORd|4}

BYTE (or "1" byte):  8 bits
WORD (or "2" bytes):  16 bits
LWORd (or "4" bytes):  32 bits

BYTE (8 bits)

<data>

Numeric

Specify the bit pattern as a decimal, binary, or hexadecimal value. Specify 1's for active bits or 0's for "don't care" bits.

For binary, "#B" must be added as a prefix (e.g., #B11001100).
For hex, "#H" must be added as a prefix (e.g., #HCC).

This is a required parameter

<ch_list>

Numeric

One or more digital input channels in the form (@sccc).

34950A: s101 through s104, s201 through s204
34952A: s001 through s004

This is a required parameter

Remarks

  • Depending on the width specified, the channel numbering is modified as shown below. For example, if you specify the width as a 16-bit WORD on the 34950A, channels 101 and 102 are combined and addressed collectively as channel 101.  

    34950A

    Bank 2

    Bank 1

    BYTE (8 Bits):

    Ch 204

    Ch 203

    Ch 202

    Ch 201

    Ch 104

    Ch 103

    Ch 102

    Ch 101

    WORD (16 Bits):

    Ch 203

    Ch 201

    Ch 103

    Ch 101

    LWORd (32 Bits):

    Ch 201

    Ch 101

     

     

     

    34952A

    Bank 1

     

    BYTE (8 Bits):

    Ch 4

    Ch 3

    Ch 2

    Ch1

     

    WORD (16 Bits):

    Ch 3

    Ch 1

     

    LWORd (32 Bits):

    Ch 1

     

  • The channel width takes precedence over the specified digital pattern. If the specified pattern is greater than the channel width, additional bits will be ignored. For example, if you set the channel width to "BYTE" and then specify a pattern of "256" (1 0000 0000), the pattern will be truncated to "0000 0000" (the leading "1" will be ignored).

  • Pattern comparisons are performed on a per-bank basis (i.e., the entire bank is reserved for the pattern comparison). For example, if you are using channels 101 and 102 for pattern comparison (assumes 34950A) and then perform a static read of channel 103, the module will perform a pattern comparison on channels 101 and 102.

  • After specifying the desired digital pattern and mask, use the CALCulate:COMPare:STATe command to enable pattern comparisons on the specified channels.

  • For the 34950A only, pattern comparisons can be performed with or without handshaking (see CONFigure:DIGital:HANDshake command). If you are using handshaking, the specified digital pattern is evaluated with each handshaking operation. If you are not using handshaking, the specified digital pattern is evaluated continuously as soon as you enable the pattern comparison mode.

  • For the 34950A only, hardware interrupts are reported on the INTR line (one line is available per bank). See the [SENSe:]DIGital:INTerrupt[:ENABle] command to enable interrupts to be reported.

  • A Factory Reset (*RST command) clears the mask and turns off the pattern comparison mode. An Instrument Preset (SYSTem:PRESet command) or Card Reset (SYSTem:CPON command) does not clear the mask and does not turn off the pattern comparison mode.

Return Format

The query command returns the mask as a decimal value (binary and hexadecimal values are converted to their decimal equivalents). Multiple responses are separated by commas.  

Examples

The following program segment sets the digital pattern for the 34950A in slot 3, applies a mask to the upper four bits, and then enables the pattern comparison mode. When the data read from the upper four bits is equal to the comparison pattern, a hardware interrupt will be generated. In this example, handshaking is not used.

CALC:COMP:DATA:BYTE 140,(@3101)  !Set comparison pattern (1000 1100)
CALC:COMP:MASK 240,(@3101)
 !Set mask pattern (1111 0000)
DIG:INT:MODE COMPARE,(@3101)  !Interrupt on pattern match
DIG:INT:ENAB ON,(@3101)  !Enables interrupts on channel 101
CALC:COMP:STAT ON,(@3101)  !Enable pattern comparison mode

To illustrate how the calculations are performed, see the example below which assumes that a decimal 146 was read from the channel. Since the calculations produce a non-zero result (decimal 16), an interrupt is not generated.

MSB         LSB

 

  1001 0010

Data read from port (decimal 146)

  1000 1100

CALC:COMP:DATA command (decimal 140)

  0001 1110

X-OR result

  1111 0000

CALC:COMP:MASK command (decimal 240)

  0001 0000

AND result (decimal 16, no interrupt generated)

 

The following query returns the comparison pattern selected for the 34950A in slot 3.

CALC:COMP:MASK? (@3101)  !Always returns decimal equivalent

Typical Response:  240

The following program segment sets the digital pattern for the 34952A in slot 5, applies a mask to the lower byte, and then enables the pattern comparison mode. When the data read from the lower byte is equal to the comparison pattern, an alarm will be generated on Alarm 2.

CALC:COMP:DATA:WORD #HF6F6,(@5001)  !Set comparison pattern (1111 0110 1111 0110)
CALC:COMP:MASK #H00FF,(@5001)
 !Set mask pattern (0000 0000 1111 1111)
CALC:COMP:TYPE EQUAL,(@5001)  !Generate alarm on pattern match
OUTP:ALARM2:SOUR (@5001)  !Enable alarms
CALC:COMP:STAT ON,(@5001)  !Enable pattern comparison mode

To illustrate how the calculations are performed, see the example below which assumes that a decimal 37595 was read from the channel. Since the calculations produce a non-zero result (decimal 13), an alarm is not generated.

MSB                           LSB

 

  1001 0010 1101 1011

Data read from port (decimal 37595)

  1111 0110 1111 0110

CALC:COMP:DATA command (decimal 63222)

  0110 0100 0010 1101

X-OR result

  0000 0000 1111 1111

CALC:COMP:MASK command (decimal 255)

  0000 0000 0000 1101

AND result (decimal 13, no alarm generated)

 

The following query returns the comparison pattern selected for the 34952A in slot 5.

CALC:COMP:MASK? (@5001)  !Always returns decimal equivalent

Typical Response:  255

See Also

CALCulate:COMPare:DATA

CALCulate:COMPare:STATe

CALCulate:COMPare:TYPE

CONFigure:DIGital:HANDshake

OUTPut:ALARm<n>:SOURce

[SENSe:]DIGital:INTerrupt[:ENABle]