Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Using a Teensy 3.2 with a PMBus-Compatible IC?

  1. #1
    Junior Member
    Join Date
    Jun 2019
    Posts
    2

    Using a Teensy 3.2 with a PMBus-Compatible IC?

    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?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    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.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Ok, I've updated Teensy's Wire lib on github with the 5 param Wire.requestFrom() function.

    https://github.com/PaulStoffregen/Wi...2bdce18b066a7d

    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?

  4. #4
    Junior Member
    Join Date
    Jun 2019
    Posts
    2
    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.


    Quote Originally Posted by PaulStoffregen View Post
    Ok, I've updated Teensy's Wire lib on github with the 5 param Wire.requestFrom() function.

    https://github.com/PaulStoffregen/Wi...2bdce18b066a7d

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •