{
  "metadata": {
    "id": "sparkfun-rob-28633",
    "name": "SparkFun N20 Motor With Encoder",
    "type": "motor",
    "description": "N20 micro gearmotor with quadrature Hall encoder and pre-soldered 100 mm JST-SH 6-pin cable. 31.5:1 ratio, 882 CPR at output shaft, 6–12 V operation.",
    "manufacturer": "SparkFun",
    "part_number": "ROB-28633",
    "datasheet_url": "https://cdn.sparkfun.com/assets/a/3/9/9/9/28633_datasheet_N20_Motor_With_Encoder_and_Cable_pair.pdf",
    "tags": [
      "N20",
      "gearmotor",
      "quadrature",
      "hall",
      "JST-SH",
      "31.5:1",
      "882-CPR",
      "XRP"
    ],
    "schema_version": "1.4.0",
    "version": "1.2.0",
    "taxonomy": [
      "actuator.motor.dc_motor",
      "sensor.encoder",
      "robotics.educational"
    ]
  },
  "domains": [
    {
      "domain": "electrical",
      "power_domains": [
        {
          "id": "motor_supply",
          "name": "Motor Supply",
          "nominal_voltage_V": 6,
          "voltage_range_V": [
            3.7,
            12
          ],
          "isolation_type": "non_isolated",
          "ground_reference": "floating",
          "description": "Brushed DC motor terminals. Current depends on load; stall ~0.45 A at 6 V per SparkFun."
        },
        {
          "id": "encoder_logic",
          "name": "Encoder Logic Rail",
          "nominal_voltage_V": 3.3,
          "voltage_range_V": [
            3.3,
            5
          ],
          "isolation_type": "non_isolated",
          "ground_reference": "system_ground",
          "description": "Powers dual Hall sensors and internal conditioning."
        }
      ],
      "resources": [
        {
          "id": "pin1_blue_gnd",
          "name": "Pin 1: GND (Blue)",
          "functions": [
            {
              "name": "GROUND",
              "direction": "sink",
              "signal_class": "power"
            }
          ],
          "power_domain_id": "encoder_logic",
          "connector_type": "JST-SH-6"
        },
        {
          "id": "pin2_green_enc_a",
          "name": "Pin 2: ENC_A (Green)",
          "functions": [
            {
              "name": "QUAD_A",
              "direction": "output",
              "signal_class": "digital"
            }
          ],
          "power_domain_id": "encoder_logic",
          "connector_type": "JST-SH-6"
        },
        {
          "id": "pin3_white_enc_b",
          "name": "Pin 3: ENC_B (White)",
          "functions": [
            {
              "name": "QUAD_B",
              "direction": "output",
              "signal_class": "digital"
            }
          ],
          "power_domain_id": "encoder_logic",
          "connector_type": "JST-SH-6"
        },
        {
          "id": "pin4_yellow_vcc",
          "name": "Pin 4: VCC 3.3–5 V (Yellow)",
          "functions": [
            {
              "name": "POWER_IN",
              "direction": "sink",
              "signal_class": "power"
            }
          ],
          "power_domain_id": "encoder_logic",
          "connector_type": "JST-SH-6"
        },
        {
          "id": "pin5_black_motor_minus",
          "name": "Pin 5: Motor − (Black)",
          "functions": [
            {
              "name": "MOTOR_NEG",
              "direction": "sink",
              "signal_class": "power"
            }
          ],
          "power_domain_id": "motor_supply",
          "connector_type": "JST-SH-6"
        },
        {
          "id": "pin6_red_motor_plus",
          "name": "Pin 6: Motor + (Red)",
          "functions": [
            {
              "name": "MOTOR_POS",
              "direction": "sink",
              "signal_class": "power"
            }
          ],
          "power_domain_id": "motor_supply",
          "connector_type": "JST-SH-6"
        }
      ],
      "interfaces": [
        {
          "id": "brushed_dc_motor",
          "name": "Brushed DC motor terminals",
          "protocol": {
            "type": "dc_motor",
            "role": "actuator"
          },
          "requires": [
            {
              "function": "MOTOR_POS",
              "count": 1
            },
            {
              "function": "MOTOR_NEG",
              "count": 1
            }
          ],
          "description": "Drive with an H-bridge or half-bridge. Reverse polarity to reverse direction."
        },
        {
          "id": "quadrature_encoder",
          "name": "Quadrature encoder A/B",
          "protocol": {
            "type": "quadrature",
            "role": "device"
          },
          "requires": [
            {
              "function": "POWER_IN",
              "count": 1
            },
            {
              "function": "GROUND",
              "count": 1
            },
            {
              "function": "QUAD_A",
              "count": 1
            },
            {
              "function": "QUAD_B",
              "count": 1
            }
          ],
          "constraints": {
            "counts_per_rev_output_4x": 882,
            "ppr_motor_per_channel": 7,
            "sensors": "dual Hall",
            "channels": 2
          },
          "description": "14-pole magnetic disk with two Hall sensors. 7 cycles/rev at motor; 31.5:1 gearbox → 882 counts/rev at output (4× decoding)."
        }
      ],
      "supply_voltage_V": [
        3.7,
        12
      ],
      "power_consumption_mW": 180,
      "pin_count": 6,
      "metadata": {
        "package_type": "Pre-cabled JST-SH 6-pin"
      }
    },
    {
      "domain": "mechanical",
      "resources": [
        {
          "id": "output_shaft",
          "name": "Output shaft",
          "functions": [
            {
              "name": "SHAFT_OUTPUT",
              "direction": "source",
              "signal_class": "mechanical_drive",
              "description": "3 mm D-shaft, 10 mm length"
            }
          ],
          "connector_type": "shaft",
          "description": "Use 3 mm D-bore coupler or wheel."
        }
      ],
      "interfaces": [
        {
          "id": "shaft_interface",
          "name": "Shaft output",
          "protocol": {
            "type": "mechanical_connection",
            "role": "shaft"
          },
          "requires": [
            {
              "function": "SHAFT_OUTPUT",
              "count": 1
            }
          ],
          "max_instances": 1,
          "description": "Limit radial/axial loads; use proper support."
        }
      ],
      "package_type": "N20 micro gearmotor",
      "dimensions_mm": {
        "length": 41.5,
        "width": 12,
        "height": 10
      },
      "weight_g": 15,
      "metadata": {
        "gear_ratio": "31.5:1",
        "cable": "JST-SH 6-pin, 100 mm"
      }
    }
  ],
  "design_rules": [
    "Power motor from 3.7–12 V via H-bridge; budget ≥0.45 A per motor at 6 V stall.",
    "Power encoder at 3.3–5 V; share ground with controller.",
    "Decode quadrature at 4× to obtain 882 counts per output-shaft revolution.",
    "Debounce or filter as needed at high RPM."
  ],
  "validation_requirements": [
    "Measure no-load current ≈30 mA at 6 V and speed ≈500 RPM.",
    "Verify encoder CPR: rotate shaft one revolution and count ≈882 edges (4×).",
    "Confirm pinout with continuity before connecting to driver/controller."
  ],
  "usage_notes": "Cable pinout: 1-Blue GND, 2-Green A, 3-White B, 4-Yellow VCC (3.3–5 V), 5-Black M−, 6-Red M+. Encoder and motor share a 6-pin JST-SH plug.",
  "application_examples": [
    "Small mobile robots",
    "Encoder-closed-loop drive",
    "Mini actuators"
  ],
  "compatibility_notes": "JST-SH 6-pin mates with XRP Controller encoder port; adapter may be required for other systems.",
  "warnings": [
    "Do not exceed 12 V on motor terminals.",
    "Stall currents can heat the motor quickly.",
    "Verify wiring; miswiring VCC and motor pins can damage the encoder."
  ]
}