2022年6月4日 星期六

ePy-Lite醫電感測器實作 – AD8232心電信號測量模組

 

醫電感測器實作 – AD8232心電信號測量模組

 電路圖

 

程式列表

Python - ePy-Lite_AD8232.py

"""

  ePy-Lite_AD8232.py

 

  ePy-Lite   AD8232

  -----------------

  GND ------- GND

  3V3 ------- 3.3V

  ADC(0)----- Output

      ------- L0-

      ------- L0+

      ------- ~SND

"""

 

from machine import Switch  #Get button KEY library

from machine import ADC, Timer, LED, Pin, I2C

import utime

 

alpha = 0.75

 

"""描述此函式...

"""

def tick3(timer):

  global TimerDone

  TimerDone = True

  return TimerDone

 

def key_int():

  global KeyDone

  KeyDone = True

 

# Start Function

if __name__ == '__main__':

  # On my board on = off, need to reverse.

  led = LED('ledy')

 

  KeyA = Switch('keya')    #Create button A

  KeyA.callback(key_int)

  KeyDone = False

 

  timer = Timer(3,freq=100)

  timer.callback(tick3)

  TimerDone = False

 

  sensor = ADC(Pin.epy.AIN0)

 

  oldValue = 0.0

 

  utime.sleep_ms(900)

  print("--- Start measurement ---")

 

  while True:

    if TimerDone == True:

      TimerDone = False

      sensor_value = sensor.read()

      value = alpha * oldValue + (1 - alpha) * sensor_value

      print(sensor_value,",",value)        #打印ADC

 

      oldValue = value

    if KeyDone == True:      #Press A Key

      break

 

  KeyA.callback(None)

  timer.deinit()

  print("Exit measurement.")

 Blockly



執行結果

使用SerialPlot - Realtime Plotting Software進行心電信號收集

Hasan Yavuz ÖZDERYA GitHub https://github.com/hyOzd/serialplot/

原始資料

 

沒有留言:

張貼留言