Appendix G: Masking
Streszczenie: Maskowanie bitów rejestrów (np. rejestru statusu zdarzeń): wybór bitów, obliczanie dziesiętnej wartości maski oraz przykłady konfiguracji wyjść OUT1 i OUT4 śledzących wybrane stany napędu.
EN: Masking: selecting register bits, mask values and output configuration examples.
Dotyczy: Copley Motion Objects (CMO, biblioteka COM CMLCOMLib) – sterowanie serwonapędami Copley CANopen z PC (Windows; VB 6.0, VB .NET, LabVIEW)
Źródło: dokumentacja producenta (Copley Motion Objects Programmer’s Guide); tabele przepisane z obrazów na tekst – opracowanie Multiprojekt
G.1:1 Masking
G.1.1:1 Selecting Bits in a Register
A register mask describes a selection of bits in a register. Copley Motion Objects uses masks to:
1 Configure methods to monitor the states of selected register bits.
2 Directly read or write the states of register bits.
A register mask describes a set of bits. The mask is typically represented by a binary number. For convenience, the register descriptions in this manual provide the decimal mask values for each bit. The decimal equivalent can be calculated as 2 n, where n = the bit number For instance, here is a partial description of the amplifier’s event status register:
Event status register – first bits and mask values
| Bit | Definition | Decimal Equivalent of Mask Value |
|---|---|---|
| 0 | Amplifier short circuit. | 1 (=2⁰) |
| 1 | Amplifier over temperature. | 2 (=2¹) |
| 2 | Amplifier over voltage. | 4 (=2²) |
| 3 | Amplifier under voltage. | 8 (=2³) |
| For a full description, see B.11.2: Amplifier Event Status Register Values. | ||
A mask is defined by setting (to value 1) the mask bits that correspond to selected register bits. A simple way to do this is add the decimal equivalents of the mask values of the selected bits. Here are three sample masks for the event status register:
Register bits (bit 3 = Under Voltage, decimal 8; bit 2 = Over Voltage, 4; bit 1 = Over Temperature, 2; bit 0 = Short Circuit, 1) – example masks. Note: add the decimal equivalents of the selected bits to determine the mask's decimal value.
| Example Mask | Bit 3 (Under Voltage) | Bit 2 (Over Voltage) | Bit 1 (Over Temperature) | Bit 0 (Short Circuit) | Decimal Equivalent |
|---|---|---|---|---|---|
| Short Circuit Only | 0 | 0 | 0 | 1 | 1 |
| Over Temperature Only | 0 | 0 | 1 | 0 | 2 |
| Over Voltage Only | 0 | 1 | 0 | 0 | 4 |
| Under Voltage Only | 1 | 0 | 0 | 0 | 8 |
| Under or Over Voltage | 1 | 1 | 0 | 0 | 12 (=8+4) |
Continue to G.1.2: Mask Usage Examples.
G.1.2:2 Mask Usage Examples
For instance, the method WriteOutputConfigExt (p. 37) can configure an output to track one or more bits in the amplifier’s event status word.
Example 1: Configure OUT1 to Track Short Circuit Conditions
The general format of WriteOutputConfigExt is:
WriteOutputConfigExt(pin As Integer, config As CML_OUTPUT_PIN_CONFIG, param1 As Integer, Param2 As Integer)
To configure OUT1 to track short circuit conditions, call the method as follows:
WriteOutputConfig 0, OUTPUT_CONFIGURATION_EVENT_STATUS_HIGH, 1, 0
The parameter values are described below.
| Parameter | Value | Meaning |
|---|---|---|
| pin | 0 | Assign the configuration to OUT1. |
| config | OUTPUT_CONFIGURATION_EVENT_STATUS_HIGH | The output pin follows the mask of the amplifier's event status register and is active high. |
| param1 | 1 | Track register Bit 0, Amplifier short circuit. |
| param2 | 0 | This parameter is ignored for this configuration. |
Example 2: Configure OUT4 to Track Over Temperature and Over Voltage Conditions
In this example, the mask is a sum of two values:
WriteOutputConfigExt 3,OUTPUT_CONFIGURATION_EVENT_STATUS_HIGH, 12, 0
The parameter values are described below.
| Parameter | Value | Meaning |
|---|---|---|
| pin | 3 | Assign the configuration to OUT4. |
| config | OUTPUT_CONFIGURATION_EVENT_STATUS_HIGH | The output pin follows the mask of the amplifier's event status register and is active high. |
| param1 | 12 | Track register bits 3, Amplifier under voltage, and 2, Amplifier over voltage. Note that the selection is a bitwise "Or." OUT4 will go active if an under or over voltage condition occurs. |
| param2 | 0 | This parameter is ignored for this configuration. |
Słowa kluczowe
maska, masking, rejestr statusu zdarzeń, wartość dziesiętna maski, WriteOutputConfigExt, OUTPUT_CONFIGURATION_EVENT_STATUS_HIGH, OUT1, OUT4, bitwise OR



