This is a simulated pacemaker built to visually and functionally represent the various functions of modern pacemakers today. The following project is based on Boston Scientific's pacemaker specifications.
Through model-based code generation and a Python GUI, we created the following features:
- 10 unique pacemaker modes (AOO, VOO, AAI, VVI, AOOR, VOOR, AAIR, VVIR, DDD, DDDR)
- Real-time electrocardiogram display from the ventricle and atrium readings
- Locally encrypted data storage
Python | Matlab Simulink | Customtkinter | NXP FRDM K64F Board | J-Link
Pacemaker.mp4
Mode and Parameter Stateflow in Simulink
Serial Communication Stateflow in Simulink
Central to modelling our pacemaker's functionality was the use of MATLAB Simulink, which allowed us to generate code iteratively and quickly flash our code into our board.
Through user-set parameters, our Simulink code allow for the pacing of both the atrium and ventricle alongside rate adaptive pacing with an in-built accelerometer.
All important user-set data and electrocardiogram data were framed. The resulting packet was sent through a micro USB to the device controller monitor.
Through Python's tkinter, we created a secure interface that allows for the modification of the pacemaker. Our GUI allows for:
- Real-time display of the simulated heartbeat
- Patient data to be saved and modified
- Encryption of patient data
- Serial communication to the K64F board
To test and validate our pacemaker mode function, we employed Heartview, a McMaster-created cardiac simulation tool that was pre-flashed onto our board.
- Python 3.18 or later
- MATLAB Simulink 2023 or later
pip install customtkinter matplotlib serial numpy- Embedded Coder, Fixed-Point Designer, MATLAB Coder, Simulink Check, Simulink Coder, Simulink Coverage, Simulink Design Verifier, Simulink Desktop Real-Time, Simulink Test, and Stateflow
- Simulink Coder Support Package for NXP FRDM-K64F Board
- Kinetis SDK 1.2.0 mainline release
- V6.20a of the J-Link Software
In MATLAB, write the following in to the terminal:
open([codertarget.freedomk64f.internal.getSpPkgRootDir,
'/src/mw_sdk_interface.c']);Upon opening the device change the following line:
{ GPIO_MAKE_PIN(GPIOA_IDX, 0), MW_NOT_USED},// PTA0, D8into the following:
{ GPIO_MAKE_PIN(GPIOC_IDX, 12), MW_NOT_USED},// PTC12, D8




