Using a Teensy 3.2 with a PMBus-Compatible IC?

Status
Not open for further replies.

swap

Member
Hello,

I am trying to use the full functionality of the INA233 power monitoring IC (datasheet), and I am looking for advice on the best way to do that with a Teensy 3.2.
The INA233 is a bit more special than a regular I2C chip because it implements a PMBus interface, which requires a library of standard PMBus commands, and the ability to read words from INA233-internal registers.

I found an Arduino library for the INA233 that seems perfect for modification: it has all the registers and commands mapped out, and it looks well done. Check it out here.

Unfortunately, I noticed that three of the critical functions, “wireReadBlock”, “wireReadWord”, and “wireReadByte” all use a version of the Wire library's "requestFrom" function that takes in 5 arguments. The equivalent function in the teensy libraries only has three arguments. The critical difference between these functions seems to be that the Arduino Wire "requestFrom" function handles access to remote chip internal registers.
Here is a link to the Arduino requestFrom definition in the Arduino Github.
And here's a link to the requestFrom definition in the teensy Wire library.

I realize that someone else on this forum has already been working on a PMBus library, but it looks too specific to be worth trying to port, especially since the major issue with the INA233 Arduino library seems to be confined to three functions.

However, I am an amateur, and I've come to this forum for to ask for help deciding on a path forward. I get the sense that modifying the underlying Wire libraries is not a good idea.

My question now is: If it were up to you to communicate with this INA233 with a Teensy 3.2, and you knew about the Arduino library, and its conflicts with the Teensy Wire library, what would you do?
 
Wow, this is the first I've heard of Arduino's Wire library getting a new requestFrom() function. So far, this 5 parameter version is completely undocumented on Arduino's reference documentation:

https://www.arduino.cc/en/Reference/WireRequestFrom

Looks like they've also only implemented it on AVR and SAM (Arduino Due), but not their newer SAMD and megaAVR bords. I've opened on issue, requesting documentation:

https://github.com/arduino/Arduino/issues/8966

Looking at their code for AVR, it seems fairly simple. I'll try to make an implementation for Teensy soon. Still, would be nice to see real documentation about what this 5 parameter function is really meant to do, rather than trying to just copy its functionality from their code without any docs.
 
Can confirm, I can compile an example sketch from the infinityPV_INA233 library with the new teensy Wire library on a teensy 3.2!

Thank you for your quick work on this. I haven't gotten a valid message out of the INA233 yet but I should be able to test that out later today or tomorrow.


Ok, I've updated Teensy's Wire lib on github with the 5 param Wire.requestFrom() function.

https://github.com/PaulStoffregen/Wire/commit/760fcb71975a00240d1ca748012bdce18b066a7d

I checked this infinityPV_INA233 library now compiles on all Teensy boards. But I don't have the hardware for actual testing. Hoping you can confirm?
 
Status
Not open for further replies.
Back
Top