HomebuiltRacing Posted April 28, 2020 Report Share Posted April 28, 2020 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 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.. 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? Quote Link to comment Share on other sites More sharing options...
Vaughan Posted April 28, 2020 Report Share Posted April 28, 2020 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). Quote Link to comment Share on other sites More sharing options...
Adamw Posted April 28, 2020 Report Share Posted April 28, 2020 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: Now with M=10, O=10000 we have something that looks right: 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: Vaughan 1 Quote Link to comment Share on other sites More sharing options...
HomebuiltRacing Posted April 29, 2020 Author Report Share Posted April 29, 2020 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 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! Quote Link to comment Share on other sites More sharing options...
HomebuiltRacing Posted April 29, 2020 Author Report Share Posted April 29, 2020 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 ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.