# COSMIIC Pulse Generator (PG4)

The PG4 is a four-channel implantable pulse generator for electrical stimulation of nerve and muscle tissue. It delivers programmable monopolar stimulation through four independent electrodes, using the device case as the common return path.

## How it works

The PG4 receives stimulation parameters over the CANopen network from the Power Module. Its **Atmel AT90CAN128** processor converts control signals into precise charge-balanced stimulus pulses according to pre-programmed patterns or real-time commands. The SYNC message from the PM controls pulse frequency.

Three independent failsafe mechanisms protect against overstimulation:
1. **Hardware limits** on total charge per pulse
2. **Software limits** on stimulation parameters
3. **Magnetic shutdown switches** in both PG4 and PM

## Hardware

| Parameter | Value |
|-----------|-------|
| Processor | Atmel AT90CAN128 (8-bit AVR) |
| Channels | 4 independent monopolar |
| Pulse Width | 1–255 microseconds |
| Pulse Amplitude | 0–20 mA |
| Inter-Phase Interval | 5–100 μs (default 50) |
| Frequency | 1–50 Hz (via SYNC period) |
| Network | CANopen, 4 ports (1 in + 3 out) |
| Power | Network-powered from PM |
| Case | Titanium with epoxy header |
| Placement | Extremities (upper arm, forearm) |

## Stimulation Modes

- **Direct PM parameter setting** — ~50 Hz update, up to 24 channels
- **SDO direct setting** — ~4 Hz for 12 channels, ~50 Hz single channel (recommended for testing)
- **Pattern-based lookup tables** — preloaded, up to 48 patterns per PG4 (recommended for permanent systems)

## MATLAB Control

```matlab
nnp.networkOn;
nnp.setSync(50);            % 50ms = 20 Hz
nnp.enterTestStim;
nnp.write(node, '3212', ch, [PW, PA*10]);  % pulse width, amplitude
nnp.write(node, '3212', ch, [0, 0]);       % stop
nnp.enterWaiting;
```

## Build

**Source:** [COSMIIC-Community/Implantables-PG4-Hardware](https://github.com/COSMIIC-Community/Implantables-PG4-Hardware) (Aug 2025)

**EDA:** Altium Designer (PcbDoc + SchDoc format)

**Firmware:** [COSMIIC-Community/Implantables-PG4-App](https://github.com/COSMIIC-Community/Implantables-PG4-App) (C, AVR toolchain)

## Source

All design files are open source under CERN-OHL-P-2.0 (hardware) and MIT (firmware).

## Files

| File | Description |
|------|-------------|
| `cosmiic-pg4-altium-project.zip` | Altium project — PcbDoc, PcbLib, 8-page schematic (SchDoc), PrjPCB |
| `cosmiic-pg4-gerbers.zip` | Gerber fabrication files |
| `cosmiic-pg4-schematic.pdf` | Full schematic PDF (8 pages) |
| `cosmiic-pg4-assembly.step` | Complete mechanical assembly STEP (titanium case, headers, capthroughs) |
| `cosmiic-pg4-bom.xlsx` | Bill of Materials (Excel) |

## Altium Project Structure

The Altium project (`PG4D`) contains:
- **PCB layout** (`PG4D.PcbDoc`) + component library (`PG4D.PcbLib`)
- **8-page schematic** covering stimulation DACs, current sources, CAN interface, AVR MCU, safety circuits, and electrode connectors

## NSF Relevance

The PG4 is a four-channel implantable stimulator module capable of delivering programmable monopolar stimulation through four independent electrodes using the device case as the return path. Powered and networked through a single cable, the PG4 incorporates an Atmel AT90CAN128 MCU for precise waveform generation and incorporates triple-layer failsafe protections, including hardware charge limits, software safety checks, and magnetic shutdown control.

## Science Drivers

implantable_healthcare

Created by: adonis
Version: v1
Category: stimulation
