Jump to content

User defined CAN stream settings


HomebuiltRacing

Recommended Posts

Hi! 

Trying to figure out CAN bus settings to add some extra analog channels to logs. ECU in WRX V1-V2 plugin. I wrote simple sketch for Arduino that sends four values via CAN in two frames of one stream. One value (x) is constantly changing from 0 to 4000 and back and others are x/2, x/4, x/8.

Basically these (someday) will be replaces with suspension potentiometers values.

I'm new no CAN bus stuff and Arduino, last time I wrote code was about 15 years ago :) So, sorry.. please bear with me.

My CAN stream settings are below, frame 2 is the same but ID is 61

2020-04-28.png.ac00ece9ef92ad28726d88a34fcad2dd.png

So, my sketch also outputs via serial info that contains value (x) and 8 bytes of two CAN messages it sends, for example:

potentiometer Value = 2380
60-9-76-4-166-0-0-0
61-2-83-1-41-0-0-0

So, value 2380 should take bytes 1 and 2 in first frame and with 2380 = 94C in HEX, 9 and 76 (4C) look fine to me...

I managed to receive data in ECU which is itself a huge milestone for me :) but, values are not the same..

1522920804_2020-04-28(1).png.a32881cb7445eac45210ad54fd31ad1b.png

While sending 0...4000 I'm receiving -1000...-600.

I can see correlation here, but what am i missing? shouldn't I receive exactly the same value I sent with multiplier, divider and offset set as per screenshot above?

 

 

Link to comment
Share on other sites

Have a look at the test calculator, in G4+ the values received from CAN are put straight into the variables raw memory. because the displayed values often have to show negatives and decimal places the raw memory has an offset from the real displayed value and is stored in a higher resolution.

From looking at the test calculator the CAN AN runtimes displayed values have a multi of 0.1 and an offset of 1000 from the raw value. This means to get the correct value shown you will need a multi of 10 and an offset of 1000 on your CAN AN inputs.

 

In G4X this was changed to be the value received from the CAN is treated as the displayed value (not the stored value).

Link to comment
Share on other sites

Extending from Vaughan's info, the test calculate is your friend for working this out, often easier to do it by trial and error rather than trying to do the math in your head.

Here is your "2380" value with D=1, M=1, O=0, it will be logged/displayed as -762.0:

xkvhL3n.png

 

Now with M=10, O=10000 we have something that looks right:

k1wAxF1.png

 

To confirm works correctly over the full range, now we try "0" CAN data, if we get a matching 0 in PC link then we are good:

02XNBYr.png

 

Link to comment
Share on other sites

8 hours ago, Vaughan said:

Have a look at the test calculator, in G4+ the values received from CAN are put straight into the variables raw memory. because the displayed values often have to show negatives and decimal places the raw memory has an offset from the real displayed value and is stored in a higher resolution.

 

7 hours ago, Adamw said:

Extending from Vaughan's info, the test calculate is your friend for working this out, often easier to do it by trial and error rather than trying to do the math in your head.

So, everything works as intended, good news!

I just was so excited to get it to do something that that I completely missed part of the process and replaced it with my expectations of how it should work :D

Leaving my test sketch aside, considering that I will be using analogRead() in Arduino to get the potentiometers values it  it looks like like I will need M=10 and O=1023 to receive 0...1023 raw values. Or take some time and figure out correct values to translate straight to mm of shock travel.

Thank you!

Link to comment
Share on other sites

4 hours ago, HomebuiltRacing said:

Leaving my test sketch aside, considering that I will be using analogRead() in Arduino to get the potentiometers values it  it looks like like I will need M=10 and O=1023 to receive 0...1023 raw values.

Nope ) That was a bit stupid ))) 

For 1:1 values you still need M=10, D=1 and O=10000 )

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...