1. Trang chủ
  2. » Tất cả

(Đồ án hcmute) design and fabricate emg anlysis system

104 11 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH ĐỒ ÁN TỐT NGHIỆP DEPARTMENT OF MECHATRONICS TECHNOLOGY DESIGN AND FABRICATE EMG ANALYSIS SYSTEM GVHD: Dr BUI HA DUC SVTH : TRAN HUU TRONG MSSV: 14146292 SVTH : NGUYEN MANH CUONG MSSV: 14146026 SVTH : NGUYEN HONG PHUC MSSV: 14146271 SKL 0 Tp Hồ Chí Minh, tháng 07/2018 an HCMC UNIVERSITY OF TECHNOLOGY AND EDUCATION FACULTY OF QUALITY TRAINING DEPARTMENT OF MECHATRONICS TECHNOLOGY GRADUATION THESIS DESIGN AND FABRICATE EMG ANALYSIS SYSTEM INSTRUCTOR: Dr BUI HA DUC STUDENT’S NAME: TRAN HUU TRONG 14146292 NGUYEN MANH CUONG 14146026 NGUYEN HONG PHUC MAJOR: 14146271 MECHATRONICS Ho Chi Minh City, July 2018 an ABSTRACT EMG is a bioelectrical signal produced by muscle activity EMG has a lot of advantages for applying in control field Nowadays, there are many research using the EMG signal to control the robot arm and peripheral devices However, acquisition of EMG signal have some challenges… In this research, our group focus on designing and fabricating the EMG acquisition system in real time EMG acquisition system circuit including ADS1293 communicate with Raspberry via SPI protocol This circuit using electrodes for collecting signal from surface skin The collected signal is processed, analyzed on acquisition system circuit and displayed on the computer During the research, our group successfully fabricate the EMG acquisition system with low cost and compact size The signal is collected accurately which represent the full characteristic of muscle activity, the results of this research show the EMG acquisition system could be response particularly the acquisition, processing and analysis This project opens opportunity to the development and application of EMG signals in the technical control field It can become one of the most widely used scientific fields in the future an ACKNOWLEDGEMENT We sincerely thank the lecturers of the department of mechatronics of high quality training who have continuously encouraged us and also provided precious knowledge Without it, we could not complete our project We would like to express my special thanks to Dr.Bui Ha Duc who supported us a lot for doing this study and we explored so many new things The group is looking forward to receiving feedback, instructions of lecturers to revise and improve the project better My group sincerely thanks! Ho Chi Minh City, July 2018 Group of students: Tran Huu Trong Nguyen Manh Cuong Nguyen Hong Phuc an Contents List of figures List of Tables List of Abbreviations 10 Chapter I: INTRODUCTION 11 1.1 Motivation 11 1.2 Project objectives 11 1.3 Scope of research 12 1.4 Thesis organization 12 Chapter II: LITARETURE REVIEW 13 1.5 Theory of EMG 13 1.5.1 Definition 13 1.5.2 Medical uses 14 1.5.3 Typical benefits 15 1.5.4 EMG signal 15 1.5.5 EMG Amplification 19 1.6 Surface EMG electrodes placement 21 1.6.1 Surface electrode 21 1.6.2 Muscle map frontal 22 1.6.3 Forearm electrode placement 22 1.7 EMG signal analysis 28 1.7.1 Amplitude and frequency of EMG Signal 28 1.7.2 Pre-processing 29 1.7.3 Data analysis 29 1.8 Theory of Neural Networks 30 1.9 Overview of previous research 31 Chapter III: DESIGN AND FABRICATE EMG ACQUISITION SYSTEM 35 3.1 Method 1: Using OPAMP 35 3.1.1 Amplifiers and filters 35 an 3.1.2 Amplification and filtering circuitry 40 3.1.3 Final design 45 3.1.4 Simulation results 49 3.1.5 Collect EMG signal experiment in practical 54 3.2 Method 2: Using ADS1293 and Raspberry Pi 55 3.2.1 Data acquisition with ADS1293 55 The EMG signal is collected using surface EMG electrodes These signals are processed by a circuit including ADS1293 and Raspberry Pi 3, data from processing via SPI protocol is transferred to computer via wireless network for program and control 55 3.2.2 Design acquisition system circuit 64 3.2.3 The EMG acquisition system circuit 69 Chapter IV: DESIGN PROTOCOL EXPIREMENT 70 4.1 Interface between ADS1293 with Raspberry Pi 70 4.1.1 SPI 70 4.1.2 SPI communication between the ADS1293 with RPi3 73 4.2 Raspberry Pi interface to WEB 78 4.2.1 WEB – Server 78 4.2.2 Using Node.js to transmit data to Pusher 80 4.2.3 Using canvas.js to draw plot of dataPoint on browser 82 Chapter VI: RESULT AND ANALYSIS 83 6.1 Ambient noise 83 6.2 Sinwave/squarewave 83 6.3 ECG 89 6.4 EMG 90 Chapter VII: CONCLUSION 92 REFERENCES 93 ADDENDUM 94 an List of figures Figure EMG Signal 13 Figure 2.Surface EMG 14 Figure Medical benefits of EMG 15 Figure EMG Signal 16 Figure Motor unit 17 Figure Schematic illustration of depolarization/repolarization 18 Figure 7.The action potential 18 Figure The "Raw" EMG Signal 19 Figure Electrode leads with cable built-in preamplifiers 20 Figure 10 The effect of A/D sampling frequency 21 Figure 11 Diagram of detecting EMG signal into MUAPTs 21 Figure 12 Muscle Map Frontal 22 Figure 13 Superficial Muscles 23 Figure 14 Flexor muscle of anterior forearm 26 Figure 15 Extensor muscle of posterior forearm 26 Figure 16 Electrode orientation for EMG recording 27 Figure 17 Electrode Placement for wrist movement 28 Figure 18 Block Diagram of EMG analysis system 30 Figure 19 a) Biological neural networks b) Brain 31 Figure 20 Layers of Neural networks 31 Figure 21 Myo gesture control armband 32 Figure 22 e-Health Sensor Platform 33 Figure 23 EMG Sensor 34 Figure 24 Schematic and block diagram of an ideal amplifier with gain of G 35 Figure 25 An amplifier with different input configuration 36 Figure 26 A differential amplifier configured as an inverting and noninverting amplifier 36 Figure 27 INA114 Circuit 37 Figure 28 Idealized Filter Responses 38 Figure 29 Key Filter Parameters 39 Figure 30 Block diagram of amplification 40 Figure 31 INA114 41 Figure 32 Structure of INA114 42 an Figure 33 Structure of OP07CP 42 Figure 34 The 1st Amplifier circuit 43 Figure 35 Low-pass filter circuit 44 Figure 36 High-pass filter circuit 45 Figure 37: The Second Amplifier circuit 45 Figure 38 The 2nd Amplifier circuit 45 Figure 39 Table of components on Altium Designer 47 Figure 40 Printed circuit board 47 Figure 41 Image 3D of PCB 48 Figure 42 Top face of the EMG acquisition system circuit 49 Figure 43 Simulate the low-pass filter circuit 49 Figure 44 Low-pass filter signal at 400Hz 50 Figure 45 Low-pass filter signal at 1000Hz 50 Figure 46 Simulate the high-pass filter circuit 51 Figure 47 High-pass filter signal at 400Hz 51 Figure 48 High-pass filter signal at 4Hz 52 Figure 49 Simulate the 2nd amplification circuit 52 Figure 50 Signal at 400Hz 53 Figure 51 Signal at 1000Hz 53 Figure 52 Block diagram of EMG Acquisition System 55 Figure 53 EMG Acquisition system 55 Figure 54 Medical cable snap electrode lead wire and electrode of 3M RedDot 56 Figure 55 Electrode placement on the forearm 56 Figure 56 Image of ADS1293 58 Figure 57 ADS1293 Connection 59 Figure 58 Function Block Diagram 59 Figure 59 The Flexible Routing Switch for single channel 60 Figure 60 Top View 28-Pin of ADS1293 62 Figure 61 PIN Functions 62 Figure 62 Raspberry Pi 63 Figure 63 Functional Block of Raspberry Pi 64 Figure 64 Jack 3.5mm female 64 Figure 65 Crystal 64 Figure 66 ADS 1293 communicate with RPI3 via SPI protocol 65 Figure 67 PCB layout 67 Figure 68 3D PCB 68 Figure 69 Top side 69 an Figure 70 The acquisition system using ADS1293 and RPi3 69 Figure 71 SPI four-wire serial bus 70 Figure 72 Synchronize clock line and data line 71 Figure 73 SPI bus: Single master and single slave 71 Figure 74 An bit shift register is contain for each SPI device 72 Figure 75 SCK is defined by CPOL 72 Figure 76 Data on the MOSI and MISO is defined by CPHA 73 Figure 77 SPI Protocol on ADS1293 74 Figure 78 Define of Transfer function 75 Figure 79 Functions Read Register and Write Register 76 Figure 80 Function to stream data from ADS1293 to Rapberry Pi 77 Figure 81 Syntax to open file result.csv to write data out 77 Figure 82 Syntax to write adc_data received into file opened below 77 Figure 83 Function of Notch filter 50Hz in file m of MATLAB 78 Figure 84 The Webserver 78 Figure 85 HTTP Protocol 79 Figure 86 HTTP Messages 80 Figure 87 Pusher 81 Figure 88 Node.js 81 Figure 89 Image of baseline in Oscilloscope 83 Figure 90 Image of baseline with ODR = 833Hz was plotted in MATLAB 83 Figure 91 Image of Sinwave in Oscilloscope 84 Figure 92 Image of Sinwave was plotted in MATLAB with ODR = 833Hz 84 Figure 93 Image of Sinwave was plotted in MATLAB with ODR = 1580Hz 85 Figure 94 Image of Sinwave in Oscilloscope 85 Figure 95 Image of Sinwave was plotted in MATLAB with ODR = 1580Hz 86 Figure 96 Image of Sinwave was plotted in MATLAB with ODR = 833Hz86 Figure 97 Image of Squarewave in Oscilloscope 87 Figure 98 Image of Squarewave was plotted in MATLAB with 833Hz 87 Figure 99 Image of Squarewave was plotted in MATLAB with 1580Hz 88 Figure 100 Image of Squarewave in Oscilloscope 88 Figure 101.Image of Squarewave was plotted in MATLAB with 1580Hz 88 Figure 102 Image of Squarewave was plotted in MATLAB with 833Hz 88 Figure 103 Normal electrocardiograms 89 Figure 104 Image of ECG was plotted in MATLAB 90 an Figure 105 Image of EMG signal was plotted in MATLAB at 1st and 2nd sec 90 Figure 106 Image of EMG signal was plotted in MATLAB at 7th sec 91 List of Tables TABLE OF REVELANT MUSCLE, ACTION AND NERVE SUPPLY 24 TABLE SPI FOUR DIFFERENT MODES 73 an Generally, collected signal in ODR = 1580Hz is less affected than ODR = 833Hz by ambient noise Because supplier is a application on smartphone, error still occurs In addition, a cause of this error is using a connection of Jack 3.5mm female and male Exactly, it is tangent of these parts 6.3 ECG This is a segment of ECG signal Pulse of heart is average 69 time/minute Compareing signal of raw with signal after Notch filter 50Hz, we used a filter process to reduce ambient noise So, we can see graph of Notch filter 50Hz is smoother and clearly Therefore, reducing affection of ambient noise to signal is really necessary and exemely important Figure 103 Normal electrocardiograms Where:  P−wave — atrial depolarization (upward deflection, beginning of atrial contraction)  Q−wave — depolarization of the ventricular septum (small downward deflection)  R−wave — activation of most of the ventricle (large upward deflection)  S−wave — last stage of ventricular depolarization (downward deflection)  T−wave — ventricular repolarization (upward deflection, beginning of ventricular relaxation) 89 an The collected signal have fully phases of a signal ECG They are P wave, QRS (complex) and T wave This is displayed in below figure Figure 104 Image of ECG was plotted in MATLAB 6.4 EMG Figure 105 Image of EMG signal was plotted in MATLAB at 1st and 2nd sec 90 an Figure 106 Image of EMG signal was plotted in MATLAB at 7th sec In these above figures, it is not difficultly to recognize that there is a movement at 1st, 2nd and 7th sec This filter is designed in MATLAB to reduce affection of ambient noise 91 an Chapter VII: CONCLUSION  Research results: The results are archived from this research, understand the principle of operation EMG sensor and design successful low pass filter and high pass filter amplifier applications to read signals from the EMG sensor But this method has some problems about the ambient noise effected to EMG signal so our group move on to another method is design the EMG acquisition system using ADS1293 The ADS1293 circuit is archived the requirements of hardware connection with electrode and Raspberry Pi Then our group successful communicate between ADS1293 and Raspberry Pi via SPI protocol The EMG acquisition system can process and analyze the EMG signal  Research direction: From the research results, our group can develope the research in new direction such as using the EMG signal to design the EMG acquisition system bracelet, robot arm, And this development direction can apply in technical control  Experience Summary: After finishes the research, our group had a lot of experience in processing of designing the EMG acquisition system circuit Devices and components in the research need to be high stable and less errors That is necessary to attend for filter noise and power, effectively arrange components In implement experiment, avoid affection of ambient noise to consequence of collected signal Position of electrode placement effect to processing of acquisition signal 92 an REFERENCES [1] P Konrad, "The ABC of EMG", Version 1.4, 2006 [2] J Keating, RELATING FOREARM MUSCLE ELECTRICAL ACTIVITY TO FINGER FORCES, New York: Electrical and Computer Engineering, 2014 [3] L T J E B Jingpeng Wang, Surface EMG Signal Amplification and Filtering, New Zealand: School of Engineering and Massey, 2013 [4] S A A M H M A J G A P H C HESSAM JAHANI FARIMAN, SIMPLE AND COMPUTATIONALLY EFFICIENT MOVEMENT CLASSIFICATION APPROACH FOR EMG-CONTROLLED PROSTHETIC, Selangor, Malaysia: Department of Electrical & Electronic Engineering, Faculty of Engineering, University Putra Malaysia, 2015 [5] Unknow, Basic Analog Electronics: Operational Amplifiers, 2014 [6] U (2017), "Analog Filter" [7] T Instrument, INSTRUMENTATION AMPLIFIER INA114, Dallas, Texas: Texas Instruments Incorporated, 2015 [8] T Instruments, OP07C, OP07D, OP07Y PRECISION OPERATIONAL AMPLIFIERS, Dallas, Texas: Texas Instruments Incorporated, 1998 [9] T Instruments, ADS1293 Low-Power, 3-Channel, 24-Bit Analog FrontEnd for Biopotential Measurements, Dallas, Texas: Texas Instruments Incorporated, 2016 [10] D Molloy, Exploring Raspberry Pi, Indianapolis, Indiana: John Wiley & Sons, Inc, 2016 [11] T Instrument, “ADS1293 EVM's User Guide,” 2013 93 an ADDENDUM TI_ADS1293.H #ifndef HEADER_FILE_TI_ADS1293_H #define HEADER_FILE_TI_ADS1293_H /************************************************************ * TI ADS1293 REGISTER SET ADDRESSES ************************************************************/ #define TI_ADS1293_CONFIG_REG (0x00) /* Main Configuration */ #define #define #define #define #define TI_ADS1293_FLEX_CH1_CN_REG TI_ADS1293_FLEX_CH2_CN_REG TI_ADS1293_FLEX_CH3_CN_REG TI_ADS1293_FLEX_PACE_CN_REG TI_ADS1293_FLEX_VBAT_CN_REG (0x01) (0x02) (0x03) (0x04) (0x05) /* /* /* /* /* #define #define #define #define TI_ADS1293_LOD_CN_REG TI_ADS1293_LOD_EN_REG TI_ADS1293_LOD_CURRENT_REG TI_ADS1293_LOD_AC_CN_REG (0x06) (0x07) (0x08) (0x09) /* /* /* /* #define TI_ADS1293_CMDET_EN_REG #define TI_ADS1293_CMDET_CN_REG #define TI_ADS1293_RLD_CN_REG (0x0A) (0x0B) (0x0C) /* Common Mode Detect Enable */ /* Commond Mode Detect Control */ /* Right Leg Drive Control */ #define #define #define #define (0x0D) (0x0E) (0x0F) (0x10) /* /* /* /* #define TI_ADS1293_REF_CN_REG (0x11) /* Internal Reference Voltage Control */ #define TI_ADS1293_OSC_CN_REG (0x12) /* Clock Source and Output Clock Control */ #define #define #define #define #define TI_ADS1293_AFE_RES_REG TI_ADS1293_AFE_SHDN_CN_REG TI_ADS1293_AFE_FAULT_CN_REG TI_ADS1293_AFE_DITHER_EN_REG TI_ADS1293_AFE_PACE_CN_REG (0x13) (0x14) (0x15) (0x16) (0x17) /* /* /* /* /* Analog Analog Analog Enable Analog #define #define #define #define #define #define TI_ADS1293_ERROR_LOD_REG TI_ADS1293_ERROR_STATUS_REG TI_ADS1293_ERROR_RANGE1_REG TI_ADS1293_ERROR_RANGE2_REG TI_ADS1293_ERROR_RANGE3_REG TI_ADS1293_ERROR_SYNC_REG (0x18) (0x19) (0x1A) (0x1B) (0x1C) (0x1D) /* /* /* /* /* /* Lead Off Detect Error Status */ Other Error Status */ Channel Amplifier Out of Range Status */ Channel Amplifier Out of Range Status */ Channel Amplifier Out of Range Status */ Synchronization Error */ #define #define #define #define #define #define #define #define #define #define TI_ADS1293_R2_RATE_REG TI_ADS1293_R3_RATE_CH1_REG TI_ADS1293_R3_RATE_CH2_REG TI_ADS1293_R3_RATE_CH3_REG TI_ADS1293_P_DRATE_REG TI_ADS1293_DIS_EFILTER_REG TI_ADS1293_DRDYB_SRC_REG TI_ADS1293_SYNCOUTB_SRC_REG TI_ADS1293_MASK_DRDYB_REG TI_ADS1293_MASK_ERR_REG (0x21) (0x22) (0x23) (0x24) (0x25) (0x26) (0x27) (0x28) (0x29) (0x2A) /* /* /* /* /* /* /* /* /* /* R2 Decimation Rate */ R3 Decimation Rate for Channel */ R3 Decimation Rate for Channel */ R3 Decimation Rate for Channel */ 2x Pace Data Rate */ ECG Filter Disable */ Data Ready Pin Source */ Sync Out Pin Source */ Optional Mask Control for DRDYB Output */ Mask Error on ALARMB Pin */ #define TI_ADS1293_ALARM_FILTER_REG #define TI_ADS1293_CH_CNFG_REG (0x2E) (0x2F) /* Digital Filter for Analog Alarm Signals */ /* Configure Channel for Loop Read Back Mode */ #define TI_ADS1293_DATA_STATUS_REG #define TI_ADS1293_DATA_CH1_PACE_H_REG (0x30) (0x31) /* ECG and Pace Data Ready Status */ /* Channel1 Pace Data High [15:8] */ TI_ADS1293_WILSON_EN1_REG TI_ADS1293_WILSON_EN2_REG TI_ADS1293_WILSON_EN3_REG TI_ADS1293_WILSON_CN_REG Flex Routing Swich Control Flex Routing Swich Control Flex Routing Swich Control Flex Routing Swich Control Flex Routing Swich Control Monitoring */ Lead Off Detect Control */ Lead Off Detect Enable */ Lead Off Detect Current */ AC Lead Off Detect Current Wilson Wilson Wilson Wilson Reference Reference Reference Reference Input Input Input Input for for for for for Channel */ Channel */ Channel */ Pace Channel */ Battery */ one Selection */ two Selection */ three Selection */ Control */ Front-End Frequency and Resolution */ Front-End Shutdown Control */ Front-End Fault Detection Control */ Dithering in Signma-Delta */ Pace Channel Output Routing Control */ 94 an #define #define #define #define #define #define #define #define #define #define #define #define #define #define TI_ADS1293_DATA_CH1_PACE_L_REG TI_ADS1293_DATA_CH2_PACE_H_REG TI_ADS1293_DATA_CH2_PACE_L_REG TI_ADS1293_DATA_CH3_PACE_H_REG TI_ADS1293_DATA_CH3_PACE_L_REG TI_ADS1293_DATA_CH1_ECG_H_REG TI_ADS1293_DATA_CH1_ECG_M_REG TI_ADS1293_DATA_CH1_ECG_L_REG TI_ADS1293_DATA_CH2_ECG_H_REG TI_ADS1293_DATA_CH2_ECG_M_REG TI_ADS1293_DATA_CH2_ECG_L_REG TI_ADS1293_DATA_CH3_ECG_H_REG TI_ADS1293_DATA_CH3_ECG_M_REG TI_ADS1293_DATA_CH3_ECG_L_REG (0x32) (0x33) (0x34) (0x35) (0x36) (0x37) (0x38) (0x39) (0x3A) (0x3B) (0x3C) (0x3D) (0x3E) (0x3F) /* /* /* /* /* /* /* /* /* /* /* /* /* /* #define TI_ADS1293_REVID_REG #define TI_ADS1293_DATA_LOOP_REG (0x40) (0x50) /* Revision ID */ /* Loop Read Back Address */ // Useful definitions #define ADS1293_READ_BIT #define ADS1293_WRITE_BIT (0x80) (0x7F) #endif Channel1 Channel2 Channel2 Channel3 Channel3 Channel1 Channel1 Channel1 Channel2 Channel2 Channel2 Channel3 Channel3 Channel3 Pace Data Low [7:0] */ Pace Data High [15:8] */ Pace Data Low [7:0] */ Pace Data High [15:8] */ Pace Data Low [7:0] */ ECG Data High [23:16] */ ECG Data Medium [15:8] */ ECG Data Low [7:0] */ ECG Data High [23:16] */ ECG Data Medium [15:8] */ ECG Data Low [7:0] */ ECG Data High [23:16] */ ECG Data Medium [15:8] */ ECG Data Low [7:0] */ // HEADER_FILE_TI_ADS1293_H 95 an TI_ADS1293_REGISTER_SETTINGS.H #ifndef HEADER_FILE_TI_ADS1293_REGISTER_SETTINGS_H #define HEADER_FILE_TI_ADS1293_REGISTER_SETTINGS_H /************************************************************ * TI ADS1293 REGISTER SET INITIALIZATION VALUES ************************************************************/ #define TI_ADS1293_CONFIG_REG_VALUE (0x00) /* Main Configuration */ #define #define #define #define #define TI_ADS1293_FLEX_CH1_CN_REG_VALUE TI_ADS1293_FLEX_CH2_CN_REG_VALUE TI_ADS1293_FLEX_CH3_CN_REG_VALUE TI_ADS1293_FLEX_PACE_CN_REG_VALUE TI_ADS1293_FLEX_VBAT_CN_REG_VALUE (0x00) (0x1C) (0x00) (0x00) (0x00) /* /* /* /* /* Flex Flex Flex Flex Flex #define #define #define #define TI_ADS1293_LOD_CN_REG_VALUE TI_ADS1293_LOD_EN_REG_VALUE TI_ADS1293_LOD_CURRENT_REG_VALUE TI_ADS1293_LOD_AC_CN_REG_VALUE (0x08) (0x00) (0x00) (0x00) /* /* /* /* Lead Off Detect Control - shut down */ Lead Off Detect Enable */ Lead Off Detect Current */ AC Lead Off Detect Current */ #define TI_ADS1293_CMDET_EN_REG_VALUE #define TI_ADS1293_CMDET_CN_REG_VALUE #define TI_ADS1293_RLD_CN_REG_VALUE (0x00) (0x00) (0x08) /* Common Mode Detect Enable */ /* Commond Mode Detect Control */ /* Right Leg Drive Control */ #define #define #define #define (0x00) (0x00) (0x00) (0x00) /* /* /* /* #define TI_ADS1293_REF_CN_REG_VALUE (0x00) /* Internal Reference Voltage Control */ #define TI_ADS1293_OSC_CN_REG_VALUE (0x04) /* Clock Source and Output Clock Control */ #define #define #define #define #define (0x00) (0x2D) (0x05) (0x00) (0x05) /* /* /* /* /* TI_ADS1293_WILSON_EN1_REG_VALUE TI_ADS1293_WILSON_EN2_REG_VALUE TI_ADS1293_WILSON_EN3_REG_VALUE TI_ADS1293_WILSON_CN_REG_VALUE TI_ADS1293_AFE_RES_REG_VALUE TI_ADS1293_AFE_SHDN_CN_REG_VALUE TI_ADS1293_AFE_FAULT_CN_REG_VALUE TI_ADS1293_AFE_DITHER_EN_REG_VALUE TI_ADS1293_AFE_PACE_CN_REG_VALUE //#define //#define //#define //#define //#define //#define TI_ADS1293_ERROR_LOD_REG_VALUE TI_ADS1293_ERROR_STATUS_REG_VALUE TI_ADS1293_ERROR_RANGE1_REG_VALUE TI_ADS1293_ERROR_RANGE2_REG_VALUE TI_ADS1293_ERROR_RANGE3_REG_VALUE TI_ADS1293_ERROR_SYNC_REG_VALUE (0x00) (0x72) (0x12) (0x12) (0x36) (0x00) Routing Routing Routing Routing Routing Wilson Wilson Wilson Wilson Swich Swich Swich Swich Swich Reference Reference Reference Reference Control Control Control Control Control Input Input Input Input for for for for for Channel */ Channel */ Channel */ Pace Channel */ Battery Monitoriing */ one Selection */ two Selection */ three Selection */ Control */ Analog Front-End Frequency and Resolution */ Analog Front-End Shutdown Control, tat ch2, ch3 */ noteAnalog Front-End Fault Detection Control */ Enable Dithering in Signma-Delta */ Analog Pace Channel Output Routing Control */ /* /* /* /* /* /* Lead Off Detect Error Status */ Other Error Status */ Channel Amplifier Out of Range Status */ Channel Amplifier Out of Range Status */ Channel Amplifier Out of Range Status */ Synchronization Error */ #define TI_ADS1293_R2_RATE_REG_VALUE #define TI_ADS1293_R3_RATE_CH1_REG_VALUE #define TI_ADS1293_R3_RATE_CH2_REG_VALUE #define TI_ADS1293_R3_RATE_CH3_REG_VALUE #define TI_ADS1293_P_DRATE_REG_VALUE #define TI_ADS1293_DIS_EFILTER_REG_VALUE #define TI_ADS1293_DRDYB_SRC_REG_VALUE (or fastest channel)*/ #define TI_ADS1293_SYNCOUTB_SRC_REG_VALUE #define TI_ADS1293_MASK_DRDYB_REG_VALUE #define TI_ADS1293_MASK_ERR_REG_VALUE (0x02) (0x02) (0x02) (0x02) (0x00) (0x00) (0x10) /* /* /* /* /* /* /* (0x00) (0x00) (0x00) /* Sync Out Pin Source */ /* Optional Mask Control for DRDYB Output */ /* Mask Error on ALARMB Pin */ #define TI_ADS1293_ALARM_FILTER_REG_VALUE #define TI_ADS1293_CH_CNFG_REG_VALUE (0x33) (0x20) /* Digital Filter for Analog Alarm Signals */ /* Configure Channel for Loop Read Back Mode */ //#define //#define //#define //#define //#define //#define //#define //#define //#define //#define //#define //#define //#define //#define TI_ADS1293_DATA_STATUS_REG_VALUE TI_ADS1293_DATA_CH1_PACE_H_REG_VALUE TI_ADS1293_DATA_CH1_PACE_L_REG_VALUE TI_ADS1293_DATA_CH2_PACE_H_REG_VALUE TI_ADS1293_DATA_CH2_PACE_L_REG_VALUE TI_ADS1293_DATA_CH3_PACE_H_REG_VALUE TI_ADS1293_DATA_CH3_PACE_L_REG_VALUE TI_ADS1293_DATA_CH1_ECG_H_REG_VALUE TI_ADS1293_DATA_CH1_ECG_M_REG_VALUE TI_ADS1293_DATA_CH1_ECG_L_REG_VALUE TI_ADS1293_DATA_CH2_ECG_H_REG_VALUE TI_ADS1293_DATA_CH2_ECG_M_REG_VALUE TI_ADS1293_DATA_CH2_ECG_L_REG_VALUE TI_ADS1293_DATA_CH3_ECG_H_REG_VALUE (0x00) (0x00) (0x00) (0x00) (0x00) (0x00) (0x00) (0x00) (0x00) (0x00) (0x00) (0x00) (0x00) (0x00) R2 Decimation Rate */ R3 Decimation Rate for Channel */ R3 Decimation Rate for Channel */ R3 Decimation Rate for Channel */ 2x Pace Data Rate for all channels */ ECG Filters Disabled */ Configures the DRDYB source to ECG channel /* /* /* /* /* /* /* /* /* /* /* /* /* /* ECG and Pace Data Ready Status */ Channel1 Pace Data High [15:8] */ Channel1 Pace Data Low [7:0] */ Channel2 Pace Data High [15:8] */ Channel2 Pace Data Low [7:0] */ Channel3 Pace Data High [15:8] */ Channel3 Pace Data Low [7:0] */ Channel1 ECG Data High [23:16] */ Channel1 ECG Data Medium [15:8] */ Channel1 ECG Data Low [7:0] */ Channel2 ECG Data High [23:16] */ Channel2 ECG Data Medium [15:8] */ Channel2 ECG Data Low [7:0] */ Channel3 ECG Data High [23:16] */ 96 an //#define TI_ADS1293_DATA_CH3_ECG_M_REG_VALUE //#define TI_ADS1293_DATA_CH3_ECG_L_REG_VALUE #define TI_ADS1293_REVID_REG #define TI_ADS1293_DATA_LOOP_REG (0x00) (0x00) (0x40) (0x50) // Useful definitions #define ADS1293_START_CONV #endif HEADER_FILE_TI_ADS1293_REGISTER_SETTINGS_H /* Channel3 ECG Data Medium [15:8] */ /* Channel3 ECG Data Low [7:0] */ /* Revision ID */ /* Loop Read Back Address */ (0x01) // Start Conversion Bit // 97 an PROGRAM FOR ACQUISITION SIGNAL #include #include #include #include #include #include #include #include #include #include "TI_ADS1293.h" "TI_ADS1293_register_settings.h" #define SPI_PATH "/dev/spidev0.0" #define TI_ADS1293_CONFIG_REG (0x00) /* Main Configuration */ uint8_t bits = 8; uint32_t speed = 1000000; uint8_t data_rdy = 0; uint8_t reg; int fd; unsigned char null=0x00; // sending only a single char #define SAMPLE_ARRAY_SIZE 10 #define CH_DATA_SIZE uint32_t adc_sample_array[SAMPLE_ARRAY_SIZE]; uint8_t read_buf[CH_DATA_SIZE]; // Store last 10 ecg samples for processing // 3bytes: ch1 ecg // // Function transfer // int transfer(int fd, unsigned char send[], unsigned char rec[], int len){ struct spi_ioc_transfer transfer = { tx_buf = (unsigned long)send, rx_buf = (unsigned long)rec, len = len, delay_usecs = 0, speed_hz = speed, bits_per_word = bits, }; //transfer.cs_change = 1; // affects chip select after transfer // transfer.tx_nbits = 0; // no bits for writing (default 0) // transfer.rx_nbits = 0; // no bits for reading (default 0) // transfer.pad = 0; // interbyte delay - check version // send the SPI message (all of the above fields, inc buffers) int status = ioctl(fd, SPI_IOC_MESSAGE(1), &transfer); if (status < 0) { perror("SPI: SPI_IOC_MESSAGE Failed"); return -1; } return status; } // // Read Regiter // uint8_t ADS1293_ReadReg(uint8_t addr) { unsigned char data[2], rc[2]; data[0] = 0x80 | addr; data[1] = 0x00; transfer(fd, &data, &rc, 2); //printf("read: address %.2X = %.2X\n",addr,rc [1]); 98 an return rc[1]; } // // Write Regiter // void ADS1293_WriteReg(uint8_t addr, uint8_t value) { unsigned char data[2], rc[2]; data[0] = 0x7F & addr; data[1] = value; transfer(fd, &data, &rc, 2); //printf("Write Addr: %.2X |Value: %.2X\n", data[0], data[1]); } // // Stream Read Register // void ADS1293_StreamReadReg(uint8_t *buf, uint8_t count) { unsigned char data[ + CH_DATA_SIZE ] = { NULL }, rc[ + CH_DATA_SIZE ] = { NULL }; data[0] = 0x80 | TI_ADS1293_DATA_LOOP_REG; transfer(fd, &data, &rc, + count); for(int i=0; i

Ngày đăng: 02/02/2023, 09:05

Xem thêm: