Page 1 of 1

Keypad Comms

PostPosted: Sun Apr 22, 2018 7:31 pm
by NBR
Hi Guys,
I'm just about to attempt direct keypad integration into the M1 using build, however I'm new to the whole CAN side of things though.

So far i have the following:

Code: Select all
local channel1 = true;
local h = CanComms.RxOpenStandard(0, 0x506, 0x01, true);

local received = CanComms.RxMessage(h);

if (received)
{
   local id = CanComms.GetID(h);
   Buttons.Button 1.Channel = id;
   
   if (id eq 0x506)
   {
      channel1 = CanComms.GetBit(h, 1);
   }
}


I dont believe its right though, and i was hoping someone would be able to assist..
I have the list from the racegrade manual in relation to the can specs:
e.g.
Channel, Offset, Length, Bit Mask, Divisor
Button 1, 0, 1, 0x01, 1
Button 2, 0, 1, 0x02, 2

And i also know the can baseID's:
NODE ID = 0A
BUTTON ADDRESS = 0506
LED ADDRESS = 0507
BRIGHTNESS ADDRESS = 0508

I have watched the webinars online, but im confused with the bitmasking side of things.
I was hoping someone that's done it before can point me in the right direction with the CAN stuff.

Re: Keypad Comms

PostPosted: Mon Apr 23, 2018 1:22 pm
by NBR
Further to the above, i should mention that i'm aware i need to also send an initialisation message according to the CANOpen standards.
I'm just trying to understand a bit better how the keypad can comms work and how i can get the data from it.

Re: Keypad Comms

PostPosted: Mon Apr 23, 2018 5:55 pm
by adrian
The bit masking specified in that document is the way that you would configure one of our Display units to read the keypad buttons directly. The reason for this is because the CAN templates in our displays are byte based, so you need a mask and divisor to pull out single bit information.

The M1 doesn't require that as you can select only the specific bits you need.

In Motorola format the M1 numbers bits from most significant bit of byte 0 to least significant bit of byte 7 as 0 - 63. This means your button 1 will be bit 7, button 2 will be bit 6 and so on. If you have a 15 button keypad button 9 will be bit 15, button 10 bit 14 and so on.

Re: Keypad Comms

PostPosted: Tue Apr 24, 2018 2:58 pm
by NBR
Thanks for that Adrian, makes perfect sense.