Jump to content
mikegt4dude

Thunder CAN - Expressing negative numbers in binary

Recommended Posts

Hi

I'm trying to get Longitudinal acceleration from CAN, wondering if negative numbers are expressed with a trailing bit or something? The values I'm getting have an extra 30 on them, does this have anything to do with expressing negative?

Share this post


Link to post
Share on other sites

Usually there is good info in the "test calculator" to show how the parameter is scaled/stored but it looks like the detail for those parameters is missing.  Usually we use unsigned integers with an offset to allow for negative values, so this is probably what you are seeing.  I suspect it will be something like a 3G offset, so the accel can read from -3G to +3G.  I will see if I can get some more detail for you tomorrow.  

Share this post


Link to post
Share on other sites

Thanks Adam, To be honest I had not checked Test calculator but now that I look at it, I see why I needed * 0.001 - 30. Over CAN I'm only getting a positive number out and I can't tell whether it's forward or backward. On the ECU, Forward acceleration shows as negative and braking force shows as positive I'm not sure if this is correct but I've done a leveling calibration before and no change to that.

 

Stored in ECU with:
ECU Resolution      = 0.001 G
ECU Width (bits)    = 16
Display Offset    = 30 G
Minimum           = -10 G
Maximum           = 10 G

Share this post


Link to post
Share on other sites
13 minutes ago, mikegt4dude said:

n the ECU, Forward acceleration shows as negative and braking force shows as positive I'm not sure if this is correct but I've done a leveling calibration before and no change to that.

That is opposite to how most would want it.  You should be able to correct that with the "orientation correction" setting.

I just relised why my test calculator didnt work - I wasnt using a thunder...

The test calculator is actually very handy to see the effects of scaling/offsets etc.  Have a play with that calculator bit at the bottom.

2 minutes ago, mikegt4dude said:

Just thought on it a bit further, the reason it's -30 is so if it wanted to display -30 it would send 0, Now I just need to know which direction is which

Correct, -30G would be sent over CAN as "0".  +30G would be "60000".

fCFybo6.png

 

Share this post


Link to post
Share on other sites

Riiiiiiight, Orientation correction is what I'm missing all along, the CAN value should be fine once I sort this. So it says if the pin header is facing the front of the car it should be zero, I have it above the tunnel mounted flat just behind the ABS sensor (fluked a good choice) but the pin header is 90 deg CCW of the front of the car, Not sure what value that should equate to but it takes 180 max

 

Okay, I just realised it takes -180 as well, so ECU pin header facing passenger side, the front of the car should be 90deg CW in relation to the ECU so I'm guessing that's what I should put

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×