Help with Steering angle Gauge

I thought I would have ago at tracking steering wheel angle, and plotting it on a bar graph, however I only seem to be able to get positive values and wondered if it’s due to my Gauge Math

This is what I have in my XML;

	<frame id="0x010" endianess="big">
		<value name="RS: Steering Wheel Direction" startbit="39" bitcount="1" enum="0:-1,1:1"></value>
		<value targetId="229" offset="6" length="2" conversion="(V &amp; 0x7FFF)*0.04395"></value> <!-- Steering Wheel Angle -->
	</frame>
  • The driection is either a 1 or 0, where 1 is clockwise and 0 is counter-clockwise (I use the enum to get the -1 for the calculation)
  • The angle is always returned as a positve number 0 to 360 (after conversion)

my Idea was to swap the value using the enum, so 0 became -1 and 1 stayed as 1, then use this in the gauge math like this;

=V * ‘Steering Wheel Direction’
I have also tried;
=V * ‘RS: Steering Wheel Direction’

But I only seem to see the guage move in the positive direction;

I used an Indicator Bar Gauge with input values of MIN -360 MAX 360
looks like this;

All i can think of is that the enum is returned as a string and therefore doesn’t work in the calculation.

What else could I be doing wrong?

First thing to try is to add:

signed="true"

for both of your values. I do have to check the enum attribute if it even supports negative values.

Looking at the can data, the most significant bit isn’t changing when the wheel passes 0 into the negative/positive so I don’t think it’s a signed value, it looks like a 15bit number.

1- this is the can frame, so looking at offset 6 and 7, getting the 15bit value

The wheel is in the negative (CCW) and the can data shows 0x98 0x93 which calculates to 276.489 degrees

So I need a way to flip this to negative based on the SteeringAngleSign, which in my example above is my ‘Steering Wheel Direction’

Maybe something like this?

<frame id="0x010" endianess="big">
  <value name="RS: Steering Wheel Direction" units="bit" startbit="39" bitcount="1"></value>
  <value targetId="229" offset="6" length="2" conversion="V*0.04395*('RS: Steering Wheel Direction' * -1)'"></value> <!-- Steering Wheel Angle -->
</frame>

Unfortunately that wouldn’t work, as if the ‘Steering Direction’ is 0 multiplying 0 by -1 would still equal 0 and for the value of 1 it would reverse the value, but now showing the wrong direction.

I’m now trying some combinations using the XML, I think I have found a few bugs though :slightly_frowning_face:

  1. When importing the XML it doesn’t seem to fully update the custom values, you have to clear the value in units and values before importing the new XML file.

  2. Now I have a clean import, I removed the units and enum for a single bitcount when I add the “custom value” into the conversion, the debug windows stops showing the converted number, so for example a value in steering angle of 0 will show 32768

  3. Then this simple formula doesn’t work either;

Conversion=“(V & 0x7FFF) * 0.04395 * ’RS: Steering Wheel Direction’”

This returns 32768 for 0 then an increasing number in either direction, I would expect CCW to be multiplied by 0 at least???

So looks like a number of issues? What do you need from the to help resolve this?

The conversion I need would be;

Conversion=“(V & 0x7FFF) * 0.04395 * (’RS: Steering Wheel Direction’*2-1)”

Where V is masked for 15bit
Multiplied by the factor 0.04395
= positive degrees (d)
Then multiply d by (either 0 or 1 multiplied by 2 and then -1)

So; 200 degrees * (0 * 2 - 1) = -200

And; 200 degrees * (1 * 2 - 1) = 200

This is by design. Custom values are never removed automatically.

Hmm, I have a faint memory that we recently fixed something related to using custom values in conversion attribute. I’m not sure if that fix is yet on public version.

But they dont update fully either, for example when I removed the unit “bit” the value then only showed 1 and it didnt update when the data changed, after I removed it manually then re-imported the XML the value then showed as 1.0 and was showing the correct value

Ok, so i switched to a dummy target id, so I now have this

	<frame id="0x010" endianess="big">
		<value targetId="93" startbit="39" bitcount="1"></value> <!-- Dummy 01 value for conversion below -->
		<value targetId="229" offset="6" length="2" conversion="(V &amp; 0x7FFF)*0.04395*(ID93*2-1)"></value> <!-- Steering Wheel Angle -->
	</frame>

SOLVED: this now works perfectly!!!

I’ll bear in mind that until the fix for custom values is released i’ll use dummy target ID’s for calculations!!

1 Like

I verified that the fix is coming to 2.4.0.

1 Like

Also, I found that ‘units’ attribute is not re-imported if custom value already exists. This will be fixed in 2.4.0 too.

1 Like