Page 1 of 1

CAN adress bit masking

PostPosted: Sat Aug 01, 2020 1:36 am
by steven.casaer
Hi,

I am setting up some extra sensors over a CAN bus unit. These come with dedicated CAN adresses. Some of them are not 8 or 16 bit though, so not using a full byte. So I use the BIT mask function.

Now, when I have a 12bit channel that is transmitted on e.g. BYTE0 and BYTE1 (full byte 0, half of byte1) , then I use offset 0, length 2, and mask FFF0 but that doesn't work.

For the following 12bit channel (so using second half of BYTE1 and all of BYTE2) I use offset 1, length 2 and mask 0FFF and that works perfectly.

Any suggestions on what I might be doing wrong there?

Re: CAN adress bit masking

PostPosted: Sat Aug 01, 2020 3:54 am
by David Ferguson
What does "doesn't work" mean? What exactly is being sent (show us the bytes of the CAN packet), and what value is being received? What are the Multiplier / Divisor and Adder values?

Here is my guess: Did you divide by 16 to shift the data into the correct bit position?

Re: CAN adress bit masking

PostPosted: Sat Aug 01, 2020 7:31 pm
by steven.casaer
good guess.

found that as well last night in a 2016 post here

viewtopic.php?f=70&t=3455

now all good. Thanks