One clock for every second
Elvrek is the controller inside a chest compression robot. It runs the piston, times each breath, charges the defibrillator and decides the one moment the arm steps back for a shock.
What it is
A research controller for mechanical CPR, written in C and running on the QNX 8.0 real-time operating system.
- One safety process owns the piston, the ventilation timing, the charger and the shock line.
- A rhythm classifier runs beside it but may only propose. It cannot move anything.
- Every rule is checked on every 1 ms tick by an independent monitor. A broken rule lifts the piston and holds.
- Today the piston and chest are a physics model behind the same interface a real actuator will use.
The compression cycle
- 110 compressions a minute by default, within the 100 to 120 guideline range.
- A smooth raised cosine stroke: half the cycle pressing, half releasing, with full recoil at the top.
- Target depth 5.3 cm, never more than 6 cm. The setpoint is clamped in code and checked again by the monitor.
- A force ceiling of 600 N. The controller estimates chest stiffness as it presses and caps the stroke early enough for the actuator to stop.
- If a stiff chest will not reach 5 cm under that ceiling, the run reports the miss. Depth is never bought with more force.
- Breaths start only on the upstroke, never while the piston is going down. In 30:2 mode the gap is long enough for two breaths and no longer.
Charge while compressing. Park only to shock.
The older sequence stops for analysis, then stops again to charge. Elvrek keeps compressing until the energy is ready.
1. Charge on the move
About seven seconds before the two minute rhythm check, the charger starts filling while the piston keeps working.
2. Park and confirm
At the next full recoil the arm parks. A trusted check reads 0.8 seconds of clean ECG with no compression artifact in it.
3. Shock and resume
If the rhythm is shockable and the crew has pressed, the shock line closes for 10 ms and compressions restart on the next tick.
Machine time and human time, kept apart
The device is scored only on what it controls. In the recorded run the machine needed 0.80 s to park, confirm and discharge. The crew's reaction is shown on its own line.
- Pre-authorised shock: the crew can press while the charger fills. The shock then fires the moment the check confirms, with no human step inside the window.
- A late or missing press: the window still closes at 3 s, compressions resume, and the charge is offered again up to three times before it is dumped.
- No shockable rhythm: the energy is dumped inside the machine and compressions resume.
| Total hands-off limit | 3.0 s, enforced |
|---|---|
| Rhythm confirm | 0.8 s of clean ECG |
| Machine time, recorded run | 0.80 s |
| Shock line closed | 10 ms, only while parked and charged |
| Rhythm check honesty | Below AHA goals on real ECG today. See results |
Holding depth on the road
In a moving vehicle the patient's chest shifts against the straps. A frame sensor feeds a small model of that motion, and the controller moves the piston setpoint to keep the true chest depth where it should be.
- Depth in the 5 to 6 cm band on 100% of strokes with compensation, 71% without it, in the modelled road profile.
- Still 100% when the strap model is wrong by 15%.
- Compensation is limited to 1.5 cm and never lifts the force ceiling.
- This is a physics model of a vehicle, not a road test.
What it will never do
Shock outside the window
The line closes only when parked, confirmed, charged and pressed. The monitor checks each condition on every tick.
Push past 650 N
Pushing stops at 600 N. Above 650 N the system treats it as a fault and lifts the piston.
Stop on the AI's word
Only a pulse input or a sharp rise in end-tidal CO2 can stop compressions. A model's opinion cannot.
Ignore real circulation
When those trusted signs appear, the piston parks within one compression and breaths continue.
Freeze at the bottom
Every fault retracts to full recoil at a controlled speed and holds there.
Wait on a slow process
The control loop never blocks on the advisor, the display or the network. Their requests run at their own lower priority.
The numbers in the code
All limits live in one header file so they can be reviewed in one place.
| Rate | 100 to 120 per minute, default 110 |
|---|---|
| Depth | 5.0 to 6.0 cm, target 5.3 cm |
| Duty cycle | 50% |
| Recoil | Cup within 2 mm of the top on every stroke |
| Force | Stop pushing at 600 N, fault above 650 N |
| Fault retract speed | 0.25 m/s |
| Control tick | 1 ms timer pulse, SCHED_FIFO priority 60 |
|---|---|
| Rhythm check cycle | Every 2 minutes |
| Ventilation | 10 breaths a minute, or 30:2 |
| Sensor watchdog | Fault if hardware is silent for 5 ms |
| Hardware watchdog | Driver retracts if the controller is silent for 20 ms |
| Advisor timeout | Ignored after 2 s of silence |
From model to metal
The safety code only talks to one small hardware interface. The physics model implements it today; a real driver implements it next, without touching the safety code.
- Raspberry Pi 5 running QNX 8.0
- Industrial linear actuator in the 300 to 600 N class
- Load cell on the cup, limit switch at full recoil, mechanical stop behind the software limit
- A relay that lights a lamp in place of a shock
- Tested on a training manikin only, never a person
Not a medical device
Elvrek is research software. It has no clearance or certification and must never be used on a person.
Read the safety notice