Questions on sending CANBUS messages through the OI boards  [SOLVED]

Introduction and miscellaneous that we haven't created categories for, yet
Post Reply
LRBen
Posts: 474
Joined: Thu Jul 04, 2019 6:35 pm
Location: Somerset, UK
Has thanked: 43 times
Been thanked: 107 times

Questions on sending CANBUS messages through the OI boards

Post by LRBen »

So this week I have been looking at sending data from the OI control board(specifically the prius gen 2 board) onto the CANBUS, then receiving it onto a teensy. I have started to update the CANBUS wiki page with the small amount of information I have learnt.

So far I have managed to successfully map some data points from the control board and receive them on the teensy.

I have mapped tmpm first and then and uaux for this experiment. tmpm was controlled via a potentiometer onto the the motor temperature sensor pins so I could change the data.

I had some issues getting the data to make sense initially. In the end I found that gain controls the scaling of the data. I am still not sure entirely how yet. But a gain of 1 for tmpm gave me a good result on the teensy side.

I then moved onto mapping uaux onto another canbus ID. Again this needed a gain of 1.

So that was two messages on two different canbus IDs. Starting at position 0 for each one. Now I wanted to get a bit more complicated and move onto putting both messages into one ID, since each one was only taking up 8 bits this should all fit. Ideally similar to the CAN standard page on the wiki.
I eventually figured out that position means the bit position on the message, not the byte position I assume it to be. So I have now managed to successfully map two data points onto one CANBUS message.
unknown.png
unknown.png (2.1 KiB) Viewed 803 times
However as you can see, I had to start the second message on bit 16, which means I am on the 3rd byte. Starting on bit 8 the data would not show.

So from this I have three questions.
  • How exactly does the gain scaling thing work? I couldn't figure out how it scales.
  • The data I get is whole numbers, which is fine for some things. But for others like the uaux it would be helpful to get some float numbers. I get a feeling the the gain is used for this sort of purpose?
  • Is there an obvious reason why I am not able to get data onto the 2nd byte? tmpm was mapped to position 0 and was 8 bits long. So I would assume that starting at bit 8 for the uaux message should have worked.
User avatar
johu
Site Admin
Posts: 5791
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1025 times
Contact:

Re: Questions on sending CANBUS messages through the OI boards

Post by johu »

Not sure why starting at bit 8 doesn't work. Post the output of "can print" here.
Gain is gain :) Internally numbers are represented with 5 bits behind the decimal point. So the highest meaningful gain is 32. In case of uaux it would give you 1/32 V accuracy.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
LRBen
Posts: 474
Joined: Thu Jul 04, 2019 6:35 pm
Location: Somerset, UK
Has thanked: 43 times
Been thanked: 107 times

Re: Questions on sending CANBUS messages through the OI boards  [SOLVED]

Post by LRBen »

Ok figured out why I wasn't getting anything from byte 2. Because I'm an idiot and deleted a ] so it just wasn't calling byte 2 in my teensy code.
Working fine now!

Also got my head around gain now, and in the process of confirming that also how to send data across more than one byte.

To send data across more than 1 byte. Assign more than 8 bits to a map. Data sent here is little endian. So for example uaux(with a value of 12.56v) with a 32 gain sent across 2 bytes will give data on the CANbus of 10010011 , 1. The 1 needs to move to the left side of 10010011. Making 110010011. Convert this to decimal and divide by the gain to get 12.5625. This is uaux with a higher degree of accuracy.

Thanks for the help!
Post Reply