CAN Example for Indicator lights

i need a kickstart from someone experienced:

As in the Picutre attached i identified the row 00000140 being in charge of the cars lights. As soon as i engage my turn indicators, the third byte Changes from 01 to 06 (00000101).

Then when i engage the right indicators, it changes to 09 (00001001)

Can someone show me how the Frame of this would need to look like? I tried my best using a code snippet i found on the forum from a BMW, but it contained a parameter named “conversion” which i just don’t get yet.

Thank you all for your patience with me

anyone? i really just need to understand the values that i have to put in-

So you need to build the frame and values;
first find your targetID use the information found here: RealDash | Manuals | Target Identifiers

Then looking at your example; you will need something like

your frameID will be; frame id=“0x140”

Left Indicator;

offset="2"
length="1"
units="bit"
conversion="V & 6 >> 2"

Right Indicator

offset="2"
length="1"
units="bit"
conversion="V & 9 >> 3"

Basically offset to get the byte position starts at 0, length of 1 means single byte or 8 bits, then the conversion uses BITWISE AND to capture the bits required then shifts the bit you need to the LSB position.

Hope this helps

2 Likes

You really made my day, it worked the way you told me :slight_smile:
Just one more question: If i would like to assign the Value “10” (which is the high-beam), what changes would i need to do to offset and length?

Im am aware that i need to change the TargetID and Conversion value, i got that now, thank you so much for clearing the fog inside my decimal calculating brain :wink:


Talking about offset and length, i marked them yellow blue and orange.
Since you figured out that Value “01” is offset 2, i believe that value “10” would be offset 0, is that right?

or is it interpreted right from left and therefore “Length 1” is the orange, and Length 3 would be yellow for high beam?

one more thing:
The Indicator now shows in realdash, but id doesnt flash, its just constant on, Any easy way to make it flash?

in binary 10 would be 1010, if you BITWISE AND with 10 then shift by 1 position you should get the 2nd bit

Under look> look and feel > special > there is a blink value in ms

1 Like

I answered too quickly :slight_smile:

the byte order is B0, B1, B2, B3, B4, B5, B6, B7 therefore offset refers to the byte position, the lenght is how many bytes, but then it gets complicated as endianness then comes into play

2 Likes

Cant be grateful enough, you even mentioned the offset logic in your first response.
good, so now i know the offset refers to the byte position.

i have just found a bitwise calculator and try to understand why and if there needs to be a bit shifted.

Offset 0 is showing Decimal 16 (00010000) while high beam is off
high beam turned on shows Decimal 176 (10110000)

What would this conversion look like?

The reason for the BITSHIFT is, if the targetID is only expecting a single bit (yes/no) then you need to move the bit to the LSB for it to work.

if offset 0 shows 00010000 highbeam off and 10110000 for on then bit 5 and 7 are changing to high, so this could be two things turning on, if turning the high beams on always turns bit 5 and 7 high then you could use either bit to set your TargetID;

offset=“0”
Length=“1”
conversion=“V>>5”

this would then look like this 10110000 >> 5 = 00000101

2 Likes

Amazing explanation, THANK YOU so much!
You are very aware, i like that. Apparently, when turning on my high beam, the low beams are getting on as well, thats the reason why 5 and 7 change :slight_smile:

You really really helped me a lot, thank you so far, i hope one day i can revenge!

1 Like

@Cl_eav sorry for bothering you again.

I have found a tricky one. i managed to assign the handbrake and it works, but as soon as the car starts driving the handbrake sign pop up again :smiley:

Here is what i got:
Car standing still without handbrake: :00000001
Car standing still with handbrake on: 00000000
Car driving with handbrake off: 00000010

So the reason why the light goes on again is because the first bit changes back to 0 again once its riding, but how can i get this done right?

You can’t use offset and length, with startbit and bitcount, you use either method but not together

The handbrake should be easy assuming 00000001 is when the handbrake is on, as the bit you want is the first one so simply

Offset=“0”
Length=“1”
Units=“bit”

You might find this useful if you haven’t already read it?

1 Like

i tried this earlier. The thing is that this way, the light stays on while handbrake is off. and car is at stop. As soon as i ride, the light goes off.

So it’s reversed? 1=off and 0=on?

If that’s the case you could try and use the BITWISE NOT
Add

conversion=“~V”

I just tried, issue remains. Its not actually reversed. The Problem is that the value Changes from

00000000 - Brake engaged, car is on hold
00000001 - Brake not engaged, car is on hold
00000010 - Brake not engaged, car is rolling
000000011 - Gear is in reverse

i think i need to specify the value of two bits to sort this out.

Ok, try this; the first bit doesn’t really count as the car is on hold (brake applied)
the second bit the car is moving (Brake off), we then need to ignore gear in reverse

offset="0" length="1" units="bit" conversion="~V & 2 >> 1"

this will mask the value and only select when the value is 2, then bitshift 1 right to get the LSB

or you could use startbit and bitcount;

startbit="1" bitcount="1" units="bit"  conversion="~V"

this would just get the second bit and return its value.

This seemts to be almost right, however now its exactly reversed. i tried removing the ~, but it didnt help.

How about this approach?

startbit="1" bitcount="1" units="bit"  conversion="~V"

tried that as well, with and without the ~
It works less good, if i remember right the sign remained off even with the brake engaged, and then it popped on once the car was moving.

To flip 0 ↔ 1, this should also work:

startbit="1" bitcount="1" units="bit" conversion="1-V"
2 Likes

What BMW are you making this for? I have been working on my E9X so I have some built so far.