basic-electronics
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Basic Electronics

This library aims to provide a simple interface to do some calculations with electronic circuits and componants.

Example

import { Resistor, VoltageSource, CurrentSource, SeriesCircuit, ParallelCircuit  } from "basic-electronics";
// const { Resistor, VoltageSource, CurrentSource, SeriesCircuit, ParallelCircuit  } = require("basic-electronics");

const r1 = new Resistor("R1", 2000);
const r2 = new Resistor("R2", 2000);
const r3 = new Resistor("R3", 3000);
const r4 = new Resistor("R4", 6000);
const v_source = new VoltageSource("Voltage Source", 5);
const i_source = new CurrentSource("Current Source", -0.002);

// construct left side
const left = new SeriesCircuit("Left");
const leftParallel = new ParallelCircuit("LeftParallel");
leftParallel.add([r2, i_source]);
left.add([r1, leftParallel]);

// construct right side
const right = new SeriesCircuit("Right");
const rightParallel = new ParallelCircuit("RightParallel");
rightParallel.add([r3, v_source]);
right.add([rightParallel, r4]);

const circuit = new ParallelCircuit("Circuit");
circuit.add([left, right]);

circuit.children.forEach((component) => console.log(component.name, component.resistance));
console.log("---");
console.log(circuit.name, circuit.resistance);

Works To Do

  • [ ] Build a stable and extensible electronic component system
    • [x] Basic Component
    • [ ] Linear Resistor
      • [x] resistance
      • [ ] voltage
      • [ ] current
    • [ ] Voltage Source
      • [x] resistance
      • [x] voltage
      • [ ] current
    • [ ] Current Source
      • [x] resistance
      • [ ] voltage
      • [x] current
    • [ ] Series Circuit
      • [x] resistance
      • [ ] voltage
      • [ ] current
    • [ ] Parallel Circuit
      • [x] resistance
      • [ ] voltage
      • [ ] current
    • [ ] Non-linear Resistor
      • [ ] resistance
      • [ ] voltage
      • [ ] current
  • [ ] Thevenin Equivalent Circuit
  • [ ] Norton Equivalent Circuit

Package Sidebar

Install

npm i basic-electronics

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

12.5 kB

Total Files

9

Last publish

Collaborators

  • jacoblincool