Volhout Guru
 Joined: 05/03/2018 Location: NetherlandsPosts: 5975 |
| Posted: 11:53am 04 Feb 2022 |
|
|
|
Hi Amnesie,
Standard practise is to keep the interrupt routine as short as possible (short time). Doing math (the digital filtering) on the pico is relatively fast, but would also better be done outside the interrupt routine. But the killer is the LCD drawing. Although the pico potentially could run at 250MHz, the speed for LCD drawing is limitted to the SPI bus speed. So your "block erase" and line draw may cause the delays in the interrupt routine.
One question to answer for your project is: do you need immediate visibility of the EKG (ECG) build up or would you be happy with drawing LCD only when you can draw a full screen ?
In later case, you could use the ADC to sample 100Hz in the background to a memory array, and once full, restart sampling in the background. In your basic program you would do the digital filtering and display based on data in the memory array. The digital filtering could be done on an array of data using the MATH commands for arrays. (I do this exact same thing for a mains network analyzer showing waveform, fft, based on mains voltage sampled with 4kHz speed in the background).
Again, you would loose the live view of the heartbeat this way, so your patient (or yourself) could have died before you see the ECG ;)
Volhout |