Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure the Standard Mask/Comparator ?

Hello,
i sorry to ask this question but I tried to do it using NI Help but no success,
can anyone tell me how i should configure the CAN Interface (Mask and comparator)in NI CAN 2.2, so that only Message with ID for example  ID  102 and 112 are received? I don't want to use the Obj VIs. All extended IDs should be blocked. Please Help!
0 Kudos
Message 1 of 3
(4,191 Views)
Hello talker001,

The filter is just a bit mask, so you can create a pattern to let only one particular ID through, but as soon as you need multiple IDs you would need to be less restrictive with that bit mask to let both IDs through which in turn means you'll potentially get IDs that you don't want.
Let's say both IDs (102 and 112) are decimal. As the filer is a bit mask, a binary representation of the numbers is easier to understand. So you would need a mask that lets
1100110 (decimal 102) and
1110000 (decimal 112)
through. Obviously, a single mask cannot work, but both IDs have to following common bits: 11x0xx0. Thus, you can create a filter for all IDs that match the 000011x0xx0 pattern. For the bits that can be either or, the mask needs to be '0', so the mask looks like this:
11111101001 (decimal 2025)
The comparator needs to be 00001100000 (decimal 96). The bit positions with the x don't matter as the mask is set to ignore those bits and are set to '0'.

So the above filter configuration lets IDs pass that match the 000011x0xx0 pattern. That means that the filter will block all IDs but the follwoing ones:
00001100000 (decimal 96)
00001100010 (decimal 98)
00001100100 (decimal 100)
00001100110 (decimal 102)
00001110000 (decimal 112)
00001110010 (decimal 114)
00001110100 (decimal 116)
00001110110 (decimal 118)

Please note that if you are using Series 2 CAN hardware, you should use the 'Series 2 Filter' attributes to set the filter bit masks rather than the regular mask/comparator attributes (which are provided for compatibility with Series 1 CAN hardware). The needed values for the Series 2 filters are similar to the above ones; however you need to add 21 zeros at the end:
Series 2 Mask: 11111101001000000000000000000000
Series 2 Comparator: 00001100000000000000000000000000
Set the 'Series 2 Filter Mode' to 0 (Single Standard).

-B2k
Message 2 of 3
(4,183 Views)
One correction: As the interpretation of the Series 2 Mask attribute is the opposite of the legacy Standard/Extended Mask attributes, the value for the Series 2 Mask would be: 00000010110000000000000000000000

-B2k
0 Kudos
Message 3 of 3
(4,178 Views)