{"_id":"@agilatech/ctin","_rev":"1-c80e0f1426d951f94082f322f9bd72b8","name":"@agilatech/ctin","dist-tags":{"latest":"0.6.0"},"versions":{"0.6.0":{"name":"@agilatech/ctin","version":"0.6.0","description":"Device driver for CT signal analog input","main":"ctin.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/AgilatechSystems/ctin.git"},"keywords":["CT","amperage","amps","AC","current","Current Transformer"],"author":{"name":"scotty","email":"scott@agilatech.com","url":"http://agilatech.com"},"license":"MIT","bugs":{"url":"https://github.com/AgilatechSystems/ctin/issues"},"homepage":"https://github.com/AgilatechSystems/ctin#readme","gitHead":"e6fc04b0164320167091463e8368f446cf510500","_id":"@agilatech/ctin@0.6.0","_npmVersion":"6.4.1","_nodeVersion":"10.8.0","_npmUser":{"name":"scotty","email":"scott@agilatech.com"},"dist":{"integrity":"sha512-FY2f2fg1vY32CWiy2unifstEANowmq6zByhdExjAXEvlS2VFUKrfWRNWiZAd0CBkk+cyK3oNwziGezjFK06MmQ==","shasum":"0c808f87d46643b9b6389cf2a9c7ea9d24cc2c92","tarball":"https://registry.npmjs.org/@agilatech/ctin/-/ctin-0.6.0.tgz","fileCount":4,"unpackedSize":10613,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb9ZUDCRA9TVsSAnZWagAA9AQP/1pVT6YPqviWOouIjtWG\nAH39Mn6InhGQmKPylQBt+506T2NSb2cjLWiRsfv6KU4iky3hvr1EpsqTHHMd\n+AdJE2OcJXUk77Pjt5lZeiU2BVvO+90awSKJiNA9QHNPFWg+ewrUjU5KIPU3\nmRuepeA3eB8QftC7zSk0BEmmNkJ9RY4R/EeSdYxVPAPWLfcXmGf5Pe7ItqHf\nVukltz+7PPkF+L/UzbDh78jNKwlFReW7V0PnzS679ALI9oJgMCfD2P3OjPKa\nnQONEWLfMuk3kUZJdl1EgK4EufGKRkYJHyGnCgMrKI7pBojf4K34e6bPWhpo\n5UR5s3Hvxwtt7vPNicMp/3CRb7qG1bccCV8bWpzOuuHFwoxjUtwVy112j0dW\nLiN9XFL8tTBq/c1UIk7LThi8gE+FELcg+n7NTOCs6J+3O/q6uZlkU7rsH5DV\n2heuYBAXiHJFsX3ezuYUtzxEB6TtTP/kTPEpDaOoH3dlJwHwVPIvi+6kCXQl\nHaL8ahUA2kEMv4/1U3WFfwlj0Rap+Kjy8wIvyGb1sMqQjKlc1uhmhKnbgwWY\np3wSOGKlmKwLJMfJlkpp+wx0lLwDwV9+OpXvl30ceMNIe8Ny0g1ySg4gwInp\npbjRDcntC8kmXze16HmcY8AvPvak7BtE+97jS9l9yErP3P6B9ARZ/w5JgZZw\nBDiI\r\n=q5Ef\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGVZxY9LKElCr3mQnXnoAU+WfcMQhEEuGaqMDUFbLalIAiA5V4l0wSPilgsM3D/Rsgrzwxql7axFOltfaPQOsaCtvQ=="}]},"maintainers":[{"name":"scotty","email":"scott@agilatech.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ctin_0.6.0_1542821122983_0.7031129294015439"},"_hasShrinkwrap":false}},"time":{"created":"2018-11-21T17:25:22.876Z","0.6.0":"2018-11-21T17:25:23.103Z","modified":"2022-04-04T11:57:11.666Z"},"maintainers":[{"name":"scotty","email":"scott@agilatech.com"}],"description":"Device driver for CT signal analog input","homepage":"https://github.com/AgilatechSystems/ctin#readme","keywords":["CT","amperage","amps","AC","current","Current Transformer"],"repository":{"type":"git","url":"git+https://github.com/AgilatechSystems/ctin.git"},"author":{"name":"scotty","email":"scott@agilatech.com","url":"http://agilatech.com"},"bugs":{"url":"https://github.com/AgilatechSystems/ctin/issues"},"license":"MIT","readme":"## Driver for CtIn sensor\n\n##### This driver has been thoroughly tested on BBB but no other platforms\n\n### Install\n```\nnpm install @agilatech/ctin\n```\n\n### Usage\n##### Load the module and create an instance\n```\nconst Ctin = require('@agilatech/ctin');\nconst ctin = new Ctin();\n// creates an driver with all default options, including analog input 0. \n\nif (ctin.isActive()) {\n    ctin.valueAtIndex(0, (err, val) => {\n        if (!err) {\n            const current = val;\n        }\n    });\n}\n```\n\n**Options**\n```\nCtin([options])\n```\nThe constructor can be supplied with options to specify certain driver characteristics. The options object allows the following parameters:\n* name : The name given to this particular driver instance. Defaults to 'CtIn'.\n* type : The type given to this particular driver instance. Defaults to 'sensor'.\n* sampleHz : The sample rate for the input signal ranging from 1 to 1000. Defaults to 1000.\n* path : The absolute path to the raw input files. Defaults to sys/bus/iio/devices/iio:device0/\n* fileTemplate : Template for the raw input files. '<N> is replaced by the input number.  Defaults to in_voltage<N>_raw\n* inputNumber : The number of the input from 0-6. Defaults to 0.\n* maxCurrent : The maximum current in Amps the electronics are sized to handle. Defaults to 100\n* calibration : A calibration correction percentage to be applied to the measurement. Defaults to 0\n  \n\n\nMost options are fairly self-explanitory, but these require further explanation:\n\n##### maxCurrent\nThe mximum expected current is defined by the hardware, specifically the pickup coil and the burden resistor.  The formula is ((0.9 / &lt;burden resistor ohms&gt;) * &lt;pickup coil turns&gt;) / 1.414. For example, if using a pickup with 2000 turns with a 15 ohm burden resistor, the max current would be 84.9A = (( 0.9 / 15) * 2000 ) / 1.414.\n\n##### calibration\nA calibration factor is necessary to correct for tolerance in resistor values, pickup variations, and A-to-D sample errors. The calibration is simply a percentage which is applied to the raw sample before other calculations are performed. The actual correction in amps is dependent on the maxCurrent. As an illustration, if the maxCurrent is 100, and the uncorrected raw value would indicate a 50A reading, then a calibration of 2 would result in a corrected output value of 51A.\n\n\n\n### Get basice device info\n```\nconst name = ctin.deviceName();  // returns string with name of device\nconst type = ctin.deviceType();  // returns string with type of device\nconst version = ctin.deviceVersion(); // returns this driver software version\nconst active = ctin.deviceActive(); // true if initialized and acgtive, false if inactive\nconst numVals =  ctin.deviceNumValues(); // returns the number of paramters sensed\n```\n\n### Take measurement and load results in device object\n```\nCtin.pollAnalogInput(callback)\n```\nAsyncronously polls the device, stores the results in the device parameters object, and then calls the callback. The given callback function conforms to the standard (err, val) pattern.  Upon completion, the device object may also be examined for new values.\n\n\n#### device object\nThe Ctin.device object contains basic information about the device itself, and also the 'parameters' array. The 'parameters' array contains the name, data type, and current value of each parameter for the device.\n```\nCtin.device.parameters[0] = {\n    name: 'current',\n    type: 'float',\n    value: <current in amp>\n    }\n```\n\n\n### Get individual parameter values by index\nAsynchronously:\n```\nctin.valueAtIndex(index, (err, value) => {\n    if (!err) {\n        val = value;\n    }\n});\n```\n\n\n### Operation Notes\nThis driver is specific to the Beaglebone Black and its variants, and has not been tested on other devices and platforms.  It will likely require some modifications to work with analog input boards for RPi and others. \n\nThe Beaglebone Black was chosen because it includes 7 analog inputs standard without the need for add-on boards or electronics. The BBB analog input voltage range is 1.8V total, which is how the 0.9 comes from in determining the maxCurrent (the signal centered at 0.9, ranging from a low of 0 to a high of 1.8).\n\nAlso, the deafult path and filenames of the raw analog input files are specific to the BBB.\n\n\n### Improvements Roadmap\nIn the future we plan to allow this driver to be used on other platforms by just modifying some configuration.\n\n\n\n### Copyright\nCopyright © 2018 Agilatech. All Rights Reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n\nsampleHz from 1 - 1000\ncalibration = \n\n0.9v / 10 ohm * 2000 = 180 P2P\n180 / 1.414 = 127.3 RMS\nMax current then is ^\n\na 12 ohm resistor would give max current of 106A, too close\nan 11 ohm resistor would give max current of 115A, probably okay, but special order\n","readmeFilename":"README.md"}