INA219 Object
JonnyMac
Posts: 9,105
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.
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
I'll get the board from Adafruit and give it a whirl ...
T o n y
http://www.parallax.com/product/29130
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.
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
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.
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
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.
If so how would we use your program to measure them.
George Alfata