Shop OBEX P1 Docs P2 Docs Learn Events
INA219 Object — Parallax Forums

INA219 Object

JonnyMacJonnyMac Posts: 9,105
edited 2014-05-29 17:13 in Propeller 1
While helping a fellow Propeller user I found that the code provided for the INA219 current sensor is not a proper object; it is in fact a port of an Arduino (yack!) program. (Okay, I'm kidding about the yack, don't get your panties in a bunch. <grin>)

I decided to make a proper object (my definition of one, anyway) and re-create the LED current measurement demo. It seems to work just fine on my Propeller BoE but I would love to have others give it a spin (so to speak) to see if I missed anything. I'll move to ObEx later.

Comments

  • TonyWaiteTonyWaite Posts: 219
    edited 2014-04-10 12:31
    Thanks for posting this Jon!

    I'll get the board from Adafruit and give it a whirl ...

    T o n y
  • John KauffmanJohn Kauffman Posts: 653
    edited 2014-05-25 08:17
    You can get here with next P'lax order so no extra shipping. I just got 2 units w/ memorial day discount so less than ADA
    http://www.parallax.com/product/29130
  • John KauffmanJohn Kauffman Posts: 653
    edited 2014-05-27 17:08
    Jon:
    I'll look for my notes, but in meantime when I used this board right after it was released I got very weird numbers when measuring a toy DC motor. Weird like voltage was 19 v when board and motor were powered by 5v.
    Turns out that the code from Ada did a calibration on start and when the motor started it drew enough to cause a re-set. I worked with them and they fixed it in the Arduino library. If you are writing an object to handle inductive loads it might be worth a check on that.
  • JonnyMacJonnyMac Posts: 9,105
    edited 2014-05-27 17:45
    Thanks, John, I'll have a look at that. I wrote the initial object as a favor to someone else; my first step was to get the basics working.

    Again, thanks for the feedback.

    [ Update ] I looked through their code -- which I had previously used as a reference -- and nothing jumps out as auto calibration. In fact, in reading the data sheet for the part it seems clear than the engineer is expected to setup registers for the anticipated input, then test and adjust using empirical data. What is probably out of whack is that I setup calibration values for a low-current LED. You will probably have to use different values for your application.

    The steps in determining initial calibration values are spelled out in their code:
    -- https://github.com/adafruit/Adafruit_INA219/blob/master/Adafruit_INA219.cpp
  • Bill HenningBill Henning Posts: 6,445
    edited 2014-05-27 17:48
    Nice work Jon - I just found this thread.

    I'll have to pick up a couple of the boards, and I will undoubtedly use your driver :)

    Hmm... RoboPi has an MCP3208 ADC on it... as do some of the PIC chips I have at hand.

    I do have some 16 bit ADC's, but those are smt and fiddly.
    JonnyMac wrote: »
    While helping a fellow Propeller user I found that the code provided for the INA219 current sensor is not a proper object; it is in fact a port of an Arduino (yack!) program. (Okay, I'm kidding about the yack, don't get your panties in a bunch. <grin>)

    I decided to make a proper object (my definition of one, anyway) and re-create the LED current measurement demo. It seems to work just fine on my Propeller BoE but I would love to have others give it a spin (so to speak) to see if I missed anything. I'll move to ObEx later.
  • GeorgeAlfataGeorgeAlfata Posts: 3
    edited 2014-05-28 11:25
    Hi Jon,
    I'm a high school student in Riverside, California, and I working with the INA 219 on a project for our engineering program. I am very unfamiliar with SimpleIDE, and i found your code. How would I input the code on to the program?
  • PublisonPublison Posts: 12,366
    edited 2014-05-28 11:46
    Hi Jon,
    I'm a high school student in Riverside, California, and I working with the INA 219 on a project for our engineering program. I am very unfamiliar with SimpleIDE, and i found your code. How would I input the code on to the program?

    Welcome to the forums GeorgeAlfata!

    I do not speak for Jon, but I thought I would add some info here. Jon's code was written in Spin. The Propeller's native language.

    You can download the Propeller Tool, (for free!) here:

    http://www.parallax.com/downloads/propeller-tool-software

    and take a look at the code in Post #1
  • JonnyMacJonnyMac Posts: 9,105
    edited 2014-05-28 13:41
    The archive includes a simple demo and the object. Unzip to a convenient folder and open the main object code (jm_ina219b_demo.spin) with PropellerIDE or with the Propeller Tool. SimpleIDE is best suited for C projects -- my code is written in Spin.

    Be sure to download and study the documents for the device so that you can correctly set the calibration values for it.

    BTW: I used to live in Riverside when I worked for The Toro Company.

    Hi Jon,
    I'm a high school student in Riverside, California, and I working with the INA 219 on a project for our engineering program. I am very unfamiliar with SimpleIDE, and i found your code. How would I input the code on to the program?
  • GeorgeAlfataGeorgeAlfata Posts: 3
    edited 2014-05-29 11:09
    Thank you, I will look into it more.
  • GeorgeAlfataGeorgeAlfata Posts: 3
    edited 2014-05-29 11:48
    So I downloaded the program. Will this program allow us to measure the current, voltage, or resistance of a circuit by using it as a Digital Multimeter??

    If so how would we use your program to measure them.


    George Alfata
  • JonnyMacJonnyMac Posts: 9,105
    edited 2014-05-29 17:13
    Have you read the data sheet for the INA219B?
Sign In or Register to comment.