CALCulate:COMPare:MASK
CALCulate:COMPare:MASK
Syntax
CALCulate:COMPare:MASK <mask>[,(@<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 when a specific digital pattern is detected.
Used With:
- 34907A Multifunction Module (digital input channels only)
Parameters
Name Type Range of Values Default Value <mask> Numeric An 8-bit mask pattern for comparison, specified as an integer from 0 to 255. Active bits are specified as 1's, and "don't care" bits are specified as 0's. This is a required parameter. <ch_list> Channel List One or more channels, as shown:
(@301) - channel 01 on the module in slot 300.
(@301:302) - channels 1 and 2 on the module in slot 300.
(@101,201:202,302) - channel 1 on the module in slot 100, channels 01 and 02 on the module in slot 200, and channel 02 on the module in slot 300.
If you omit the optional <ch_list> parameter, this command applies to the currently defined scan list.
Remarks
- Note that the specified channels do not have to be part of the scan list to generate an alarm. Alarms are evaluated continuously as soon as you enable them. Alarms are evaluated constantly on the multifunction module, but alarm data is stored in reading memory only during a scan.
- 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).
- After specifying the desired digital pattern, use the CALCulate:COMPare:STATe command to enable pattern comparisons on the specified channels.
- 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 returns the mask as a decimal value (binary and hexadecimal values are converted to their decimal equivalents). Multiple responses are separated by commas.
Examples
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 module in slot 300.
CALC:COMP:MASK? (@301) !Always returns decimal equivalent
Typical Response: 240
The following program segment sets the digital pattern for the 34907A multifunction module in slot 100, 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,(@101) !Set comparison pattern (1111 0110 1111 0110)
CALC:COMP:MASK #H00FF,(@101) !Set mask pattern (0000 0000 1111 1111)
CALC:COMP:TYPE EQUAL,(@101) !Generate alarm on pattern match
OUTP:ALARM2:SOUR (@101) !Enable alarms
CALC:COMP:STAT ON,(@101) !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 channel 01 of the 34907A multifunction module in slot 100.
CALC:COMP:MASK? (@101) !Always returns decimal equivalent
Typical Response: + 255
See Also
CALCulate Subsystem Introduction