Shop OBEX P1 Docs P2 Docs Learn Events
BS2 code request: INA 219 Current Sensor - Page 2 — Parallax Forums

BS2 code request: INA 219 Current Sensor

2»

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2015-05-18 13:17
    Disregard...I rechecked all my connections and was getting some weird ground loop issue with the supply and the USB cable. Back to testing...

    attachment.php?attachmentid=114233&d=1431981086
    883 x 604 - 254K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2015-05-18 13:37
    JonnyMac wrote: »
    Since my name was bandied about (grin) I've attached my Spin code for the INA219 (which I have tested and deployed in client projects) -- might be a useful reference. I2C on a standard BS2 is possible with SHIFTOUT and SHIFTIN and a little extra work. Most of us have done it. Not saying that porting the INA219 code to the BS2 will be easy, but it should be possible.

    Jon,

    Quick question on your code just for calrity...was this by design/intentional? The constant and comment seem to be backward? It's probably just me over-thinking it. =)
    BRNG_32   =     1 << 13                                        '  16V bus range
      BRNG_16   =     0                                              '  32V
    
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2015-05-18 15:57
    Hey everyone, your code submissions were checked/tested by myself and added to the Downloads & Documentation section of the INA219 product page by Courtney Jacobs. https://www.parallax.com/product/29130

    Thanks for your contributions to the source code bit-bucket! =)
  • stamptrolstamptrol Posts: 1,731
    edited 2015-05-19 08:54
    Ken, Chris and all,

    Well, between USPS and Canada Post, I just received my current sensor and seemed to have missed most of the fun!

    Will hook it up and see if I can find an interesting angle to exploit. Will report as required!

    Cheers,

    Tom SIsk
  • stamptrolstamptrol Posts: 1,731
    edited 2015-05-25 16:47
    Ken and all,

    Despite being behind in developing a code sample for this project ( really, it was the post office!), I am appreciative of Ken sending along a current sensor module for development.

    So, by way of contributing, I spent a bit of time expanding the ability of the current sensor to measure much larger AC currents.

    I was able to use the code developed in this thread, changing only the pins used by the Stamp and changing the displayed "mA" to "Amps".

    I've attached the schematic and a few pics. Start with the schematic. Thanks iPhone, they will be upside down!

    Fair warning: this circuit and measuring technique assumes you have good understanding of the risks of working around high voltage and current.

    Basically, I used a standard industrial current transformer to safely sense the current in the high voltage AC circuit. Normally, a current transformer ( CT ) is meant to feed its secondary into a low impedance AC circuit like an ammeter or other transducer. However, over the years I've successfully taken the secondary circuit and rectified and filtered the signal to give a reasonable DC voltage signal suitable for feeding a microprocessor. In keeping with the need to NEVER let the secondary of a CT to become an open circuit while current is flowing in the primary, you will see two zener diodes across the CT secondary. They limit the possible output voltage to around 19 volts which is safe for the ina219.

    With the ina219, the CT's rectified signal drives a current through the calibrating resistor ( about 3.6 K ohms, in my case ) which takes into account the turns ratio of the CT primary to Secondary and the fact that we want the display in Amps, not mA. You could also make the calibrating resistor smaller and let the Stamp provide a suitable scaling factor.
    640 x 480 - 144K
    640 x 480 - 153K
    640 x 480 - 112K
    640 x 480 - 135K
  • UnsoundcodeUnsoundcode Posts: 1,530
    edited 2015-05-25 18:39
    Tom, a nice adaptation and good work from everyone. Current measurement can be tricky but if you can control an output based on a current level you can design some very sophisticated devices, overload detection or viscosity measurement are just two that come to mind. Thanks for sharing.

    Jeff.
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2015-05-25 18:52
    Thank you very much to all who have contributed (and even those who tried, but had to wait for USPS). You saved us a lot of development work and made it a lot easier for Chris - while he can write this code I've got his schedule fully booked with a number of projects! Thanks Chris for harvesting and sorting through the code, getting the final versions to our web site.

    Now that this is done, what kinds of code examples do we need for other products?

    Ken Gracey
  • GenetixGenetix Posts: 1,742
    edited 2015-05-26 16:48
    Ken,

    What happened to the Microcontroller KickStarts on Learn?
    The simplicity and no nonsense of the KickStarts make it a great resource for teachers and students.
    Some of the more complex devices such as the INA219 would be easier to use in classroom environment in a KickStart-like format.
    For example, INA219 low voltage measurements using batteries and stripped-down code.

    The Microcontroller KickStarts are also a great way of testing hardware to make sure it's working properly.
  • PublisonPublison Posts: 12,366
    edited 2015-05-28 08:27
    Genetix wrote: »
    Ken,

    What happened to the Microcontroller KickStarts on Learn?
    The simplicity and no nonsense of the KickStarts make it a great resource for teachers and students.
    Some of the more complex devices such as the INA219 would be easier to use in classroom environment in a KickStart-like format.
    For example, INA219 low voltage measurements using batteries and stripped-down code.

    The Microcontroller KickStarts are also a great way of testing hardware to make sure it's working properly.

    They are still on learn.parallax.com:

    http://learn.parallax.com/KickStart?utm_content=bufferf6083&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2015-05-28 13:41
    Publison wrote: »

    We're happy to accept new ideas or submissions for the KickStarts, too. If there's anything you'd like to see that we're not providing just let us know.

    Ken Gracey
Sign In or Register to comment.