CAN Communication Settings

Post Reply
fransoa
Posts: 22
Joined: Thu Oct 03, 2019 5:41 pm
Location: Entrepierres, France
Contact:

CAN Communication Settings

Post by fransoa »

I tried a lot to understand how the "gain" setting works in setting the exchanges on the CAN bus.
TX messages don't pose too many difficulties but I can't understand the explanation in the WIKI: "Note the 1024x gain that shifts the bit into the correct position (5 fractions plus 5th data bit)" and why "The last parameter, 32, tells the CAN module to apply the internal fixed point scaling"...

My need is simple: change settings to inverter from a device on CAN bus. I have some problems with negative values. I test with a gain of -1 : the value becomes negative but modified. If I send on the bus CAN a negative value (for exemple a WORD of 2 byte : FFF6 for decimal value -10).

I think there is a logic that escapes me. If anyone can clearly document this setting for the CAN RX command.
Thanks in advance
User avatar
johu
Site Admin
Posts: 5769
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1010 times
Contact:

Re: CAN Communication Settings

Post by johu »

So all the parameters you see are internally scaled with 32. Say you set fslipmin to 1 then it will be "32" in memory. Or if you set to 1.5 it is "48" in memory.
Now admittedly I haven't tested negative values yet.
Please try the following example: setting brkmax via CAN
- Map to some message with a gain of -32
- if you want to set brkmax to -50 just send +50
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
fransoa
Posts: 22
Joined: Thu Oct 03, 2019 5:41 pm
Location: Entrepierres, France
Contact:

Re: CAN Communication Settings

Post by fransoa »

Thank you. That's right. The negative value works well with -32.
This works for values written in the inverter (CAN RX). For the values read (CAN TX) I used a gain of 1 to get the value or 10 the value x10...
I have not tried with a gain of 32
damian.lo
Posts: 123
Joined: Sat Dec 22, 2018 12:46 pm
Location: Poland

Re: CAN Communication Settings

Post by damian.lo »

Hello all,

I have some doubt about canio setting. I want how much is possible to read parameters from BMW E87 via CAN. I was trying to read brake status, but until now without success. In my case according to http://www.loopybunny.co.uk/CarPC/can/0A8.html
I have:

So in my car is:
Byte 7 = Brake:- 0,1,2 or 3 = Brake released, 32,67,98 or 99 = Brake pressed.
For sensing brake pedal usage simply detect <20 = off and >20 on.

And now what I saw on wiki should I write:
can rx canio 168 7 * *
What should be under "*"? How should I take this value <20 = off and >20 and say to Bit 2: brake inverter "this is released or pressed?
Attachments
E87 0A8_1.jpg
User avatar
johu
Site Admin
Posts: 5769
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1010 times
Contact:

Re: CAN Communication Settings

Post by johu »

Uh I'm afraid the generic method won't allow this, also since brake pedal most likely isn't the only signal you're trying to read? If you have multiple mappings on canio they'll overwrite each other.

There seems to be no common bit that is always set on brake, only bit 6 is mostly set:
00 = 0000000
01 = 0000001
02 = 0000010
03 = 0000010
32 = 0100000
67 = 1000011
98 = 1100010
99 = 1100011

In that case you could do "can rx canio 168 62 1 128" So map the 62th bit (bit 6 of byte 7 = 54+6) to the 2nd bit (32*2*2) of canio . You'd miss the 32 case though.
So either install a VCU with some custom code to translate CAN messages or compile your own custom inverter code.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
damian.lo
Posts: 123
Joined: Sat Dec 22, 2018 12:46 pm
Location: Poland

Re: CAN Communication Settings

Post by damian.lo »

For now happily it's only one canio, which I want to map, so no problem if other will be overwritten :)
Give me an hour and I will check this, I hope it will be enough to try on my street. Without brake signal better I will not go to local road. On blocks I've already did trial - wheels are spinning forward and reverse - thanks all of You for a big help.
One strange thing - my PRE i DCSW relays are connected to 12V from car and to outputs from inverter. If now I take off main fuse 12v I hear that relays clicks - strange?
damian.lo
Posts: 123
Joined: Sat Dec 22, 2018 12:46 pm
Location: Poland

Re: CAN Communication Settings

Post by damian.lo »

Well done!
It works perfectly, so thank You Johannes very much. Bottle of something good is almost full, so I have to send it directly to You :)
Until virus will gone, we can't drink it together.
Regards,
D.lo
User avatar
johu
Site Admin
Posts: 5769
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1010 times
Contact:

Re: CAN Communication Settings

Post by johu »

You're welcome to drop by once restrictions are loosened :) still have 10l of Rosé from arbers friend. If I could survive on drinks alone I'd already be making a living of this.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
damian.lo
Posts: 123
Joined: Sat Dec 22, 2018 12:46 pm
Location: Poland

Re: CAN Communication Settings

Post by damian.lo »

Hi,

I have another question according to CAN settings.
Now I have in E87 116i:
POT -> can rx pot 170 24 8 32
what is similar to loopybunny at
E87 0AA POT RPM_2.jpg
In my car only byte 3 changes value from 0 to 254 according to throttle pedal position - this works fine.

And now - at the same adress is motor RPM at byte 4 and 5. Is it possible to read and write values from the same adress at the same time?
for writing RPM should I write:
can tx rpm 170 32 16 XX where scaling (what value - I don't know)
This should work?
damian.lo
Posts: 123
Joined: Sat Dec 22, 2018 12:46 pm
Location: Poland

Re: CAN Communication Settings

Post by damian.lo »

Hi,
Now I did small trial and is possible to read value
POT -> can rx pot 170 24 8 32
and transmit
SPEED -> can tx speed 170 32 16 10000
In this case however BMW rpm needle go immediately to max 7krpm. Smaller values don't moving needle at all. Idle speed 500rpm also doesn't move needle.
Is it possible to move it without external arduino for CAN translation?
User avatar
johu
Site Admin
Posts: 5769
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1010 times
Contact:

Re: CAN Communication Settings

Post by johu »

Why gain of 10000?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
damian.lo
Posts: 123
Joined: Sat Dec 22, 2018 12:46 pm
Location: Poland

Re: CAN Communication Settings

Post by damian.lo »

I had no idea what gain should be, so I tried to put any value from 1000-10000 with step 1000 and with this one needle moves :)
Probably if motor speed is from 0-10000 rpm
and
expected by instrument cluster value is 0 to 28000 (7krpm *4) but coded like:
Hex 0D34 = 3380
3380/ 4 = 845 RPM
So right, gain should be 2 to 4, but it doesn't move the needle.

Byte[4] = 34 hex = 52 dec
Byte[5] = 0D hex = 13 dec

Arduino Forlmula = ((Byte[5] * 256) + Byte[4] ) / 4
Example Above = (( 13*256 ) + 52 ) / 4 = 845 RPM

EDIT: now it works!
Not perfect, because from time to time needle goes to 0 and then after some time goes back. Gain = 4
Reason, why previously wasn't good? canperiod should be 10ms for BMW E87 instrument cluster

Johannes, how did You solve, when on idle You have 800rpm, and then if motor increases speed needle goes up? You are using another arduino?
And another: Johannes You should be a teacher! Your one question "why gain 10000" puts my brain into deep searching mode :) Thank You.
User avatar
johu
Site Admin
Posts: 5769
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1010 times
Contact:

Re: CAN Communication Settings

Post by johu »

Nice!

I indeed have a separate VCU generate the speed message and that just never drops below 800rpm while inverter is in run mode.
Some older firmwares had wrong CAN configuration, it did not resend lost messages. Recent 4.76 certainly has that fixed. That used to be the reason why I got a droppy needle.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
damian.lo
Posts: 123
Joined: Sat Dec 22, 2018 12:46 pm
Location: Poland

Re: CAN Communication Settings

Post by damian.lo »

I have the newest firmware 4.76.R, so it should be fixed? So maybe something wrong will be in mine setup, You think?
I found on Your repo, that You used stm32 to talk with VW? Have You some small schematic, informations, anything about this except data in github?
Regards,
D.lo
User avatar
johu
Site Admin
Posts: 5769
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1010 times
Contact:

Re: CAN Communication Settings

Post by johu »

Yes then it's another issue.
I use a Rev2 main board that is partly populated as VCU.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
damian.lo
Posts: 123
Joined: Sat Dec 22, 2018 12:46 pm
Location: Poland

Re: CAN Communication Settings

Post by damian.lo »

Since, that I don't have free Rev2 board, can I use STM32 bluepill + MCP2515 to only emulate CAN signals and use Your code?
I need also Olimex Wifi board to configure rest of CAN messages?
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: CAN Communication Settings

Post by jon volk »

This thread seems relevant so Ill include my inquiry here.
I've been successfully sending inverter CAN messages to my VCU to control gauges and some other things but I'm struggling a bit to fully understand the CAN IO.

What I am trying to achieve is a CAN message that well set brake on and start on. What I am looking to do is in the event of an overcurrent shut down...that my VCU can detect via the status message and then send a CAN IO message to auto-restart...since it only ever seems to do such things with traffic around in an intersection for example haha.

What should that CAN IO parameter look like along with the resulting message.
Formerly 92 E30 BMW Cabrio with Tesla power
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: CAN Communication Settings

Post by jon volk »

jon volk wrote: Thu Jul 30, 2020 7:49 pm This thread seems relevant so Ill include my inquiry here.
I've been successfully sending inverter CAN messages to my VCU to control gauges and some other things but I'm struggling a bit to fully understand the CAN IO.

What I am trying to achieve is a CAN message that well set brake on and start on. What I am looking to do is in the event of an overcurrent shut down...that my VCU can detect via the status message and then send a CAN IO message to auto-restart...since it only ever seems to do such things with traffic around in an intersection for example haha.

What should that CAN IO parameter look like along with the resulting message.
Please correct me if Im off base here.
So in the above example of looking to set brake and start on, would the following be correct?
can rx canio 300 0 5 12 (12 being == 01100)
then can message (I'm using flexcan on a teensy)
msg.id = 0x12C;
msg.len = 1;
msg.buf[0] = 0xC;
Formerly 92 E30 BMW Cabrio with Tesla power
User avatar
johu
Site Admin
Posts: 5769
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1010 times
Contact:

Re: CAN Communication Settings

Post by johu »

Too many 12s :) So

Code: Select all

can rx canio 300 0 5 32
32 will move it past the decimal point. The rest should work as you wrote
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: CAN Communication Settings

Post by jon volk »

Great! Now I know enough to be dangerous. As usual.
Formerly 92 E30 BMW Cabrio with Tesla power
m.art.y
Posts: 556
Joined: Sat Jun 06, 2020 6:54 pm
Location: UK
Has thanked: 24 times
Been thanked: 16 times

Re: CAN Communication Settings

Post by m.art.y »

Hello. I have read over and over the CAN message mapping description but still can't achieve a thing.

There is this command: can rx canio 300 0 5 32 where I understand 300 is ID and 32 is scaling whatever it does. What is 0 and what is 5? What this command does? Where is the actual CAN message that I can set the inverter to look for?

I want to map start, forward, reverse and brake to CAN. If need be I can mangle all of that info to one message. I just don't understand how to program the inverter to look for that message?

To test the above commands I have message in hex: ID 0x480, Data 0x04 0xFB * * * * * *. How do I map first byte 0x04 to start the inverter, and 2nd data byte 0xFB to put the inverter in forward direction?
User avatar
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: CAN Communication Settings

Post by Bigpie »

Did you get anywhere with the CAN settings? I'm struggling with canio also.
Screenshot 2021-04-29 at 9.42.46 am.png
Screenshot 2021-04-29 at 9.46.10 am.png
Sending ID: 0x01 Data: 0x00 0x20 0x00 0x00 0x00 0x00 0x00 0x00

I have the same canio setup for stm32-car but tx instead and that's what is producing the above, it's not moving out of WAITSTART

EDIT, sorted. I needed a gain of 32 and not 1 on the inverter.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
Post Reply