Mondeo reverse camera line adapter
Posted: 26 Apr 2019, 08:37
I have been reading the logic behind the code released for the reverse camera line adapter and trying to use it to learn CANBUS manipulation.
A couple of things have me a bit stumped though!
First - the reading of CANBUS data into arrays. because of the way the data is read in byte D0 is actually stored in array location 7 etc - which caused me confusion when i wrote the ignition sense code because D3 was stored in array location 5! is there a way to make it more logical or just adjust my thinking lol
Secondly - and more confusing - is the logic behind the wheel angles and storage in bytes D1 & D0
The description mentions that the angle is stored to one decimal place and the signing is stored in the MSB of D1 - understood. but it also says that the angle can be obtained by dividing the angle value by 10 - but this gives me unexpected results!
If we work on the conversion from HS > MS as a constant:
Clockwise full lock = 0xAC20 (Dec 44,064). subtract 0x8000 > 2C20 (Dec 11,296) > /10 = 112.96'
C/Clockwise full lock = 0xAC20 (Dec 44,064) > /10 = 440.64'
Clearly I am wrong somewhere here! Can anyone make sense of this for me? I think the problem is my lack of understanding of manipulation of the data bytes
finally, the way the steering angle is being determined - shifting the registers. is there a reason it is done like this instead of a simple if statement?
A couple of things have me a bit stumped though!
First - the reading of CANBUS data into arrays. because of the way the data is read in byte D0 is actually stored in array location 7 etc - which caused me confusion when i wrote the ignition sense code because D3 was stored in array location 5! is there a way to make it more logical or just adjust my thinking lol
Secondly - and more confusing - is the logic behind the wheel angles and storage in bytes D1 & D0
The description mentions that the angle is stored to one decimal place and the signing is stored in the MSB of D1 - understood. but it also says that the angle can be obtained by dividing the angle value by 10 - but this gives me unexpected results!
If we work on the conversion from HS > MS as a constant:
Clockwise full lock = 0xAC20 (Dec 44,064). subtract 0x8000 > 2C20 (Dec 11,296) > /10 = 112.96'
C/Clockwise full lock = 0xAC20 (Dec 44,064) > /10 = 440.64'
Clearly I am wrong somewhere here! Can anyone make sense of this for me? I think the problem is my lack of understanding of manipulation of the data bytes
finally, the way the steering angle is being determined - shifting the registers. is there a reason it is done like this instead of a simple if statement?