Development of a Double-Channel Medical Signal Generator Based on STM 32 with High Performance

An open-ended and multifunctional double-channel signal generator, which based on a 32 bits monolithic integrated microcomputer, highly integrated device and LCD, is introduced in this paper. The instrument is composed of microcomputer STM32F103RD and some integrated chips (IC), which includes programmable waveform generatorsAD9833 with highly frequency and phase precision. As a result, this signal generator may output not only double channels accurate sine, square or triangle waveforms with digital-controlled frequency and phase at the same time, but also many kinds of physiological signals that can be modified by USB connection with well open property. Therefore, it is convenient to measure and teach about hearing, research and study on frequency characteristic of human ear and impedance characteristic of human body in medical science. In addition, it is also very easy in experiment and research of college and medical physics for using double channels sine signal to show synthesis of two simple harmonic vibrations under different frequency, phase difference and direction, such as beat pattern and Lissajous figures. Thus it has many merits, such as the small volume, stable property, simple operation, visual display and so on. Consequently, it can be widely used in researching, teaching, debugging and maintaining.


Introduction
In many research, experiment, maintenance or debugging of medical equipment and other equipment, classic or abnormal physiologic signals, such as ECG, EEG, pulse wave and respiratory wave signal, are often need to be input.Besides, for studying and teaching of the human ear frequency, human impedance characteristics and biosensor, sine signal with high precision in frequency, purity and ability to drive heavy load, are also required.In physics experiment and other related teaching of universities and colleges, to show synthesis of two simple harmonic vibration under different frequency, phase difference and directions, such as beat pattern and Lissajous chart, two sine signals with controllable frequency and difference of phase are demanded, and this contributes to students, especially to medical students, for understanding frequency spectrum, which is very important for signal analysis.At present many medical signal generator or signal producing instruments can not meet the demands [1,2].Although, many medical signal generators may output common physiological signals, the waveform signal generally is fixed, and commonly used signals, such as sine, triangle and square-wave, are not offered.On the contrary, some signal generators, which may output commonly signals, dose not supply physiological signals.
Based on above, authors developed an open-ended and double-channel signal generator with USB interface and high performance, which overcome the shortages and can be widely used in scientific researching, experiment teaching and medical instrument debugging and maintaining.

Instrument Struction
Design of the instrument includes two sides, hardware and software.Hardware is divided into eleven units: microcontroller, double-channel signal generator, memory, double-channel filter, and signal selector, gain regulator, amplitude detector, power amplifier, keyboard, LCD monitor and power source unites.The instrument block diagram is shown in Figure 1.
This instrument mainly based on microcontroller and high-performance integrated chips, such as STM32-F103RD, AD9833, K9W5608U1M, which not only can increase its intelligence, precision, stability, but also reduce its power consumption and volume.The method for this generator includes the following sides: on the one hand, STM32F103RD, which has double on-chip DAC with 12 bit resolutions and may get data of signals from external memory K9W5608U1M, can output physiologic and special signals.Then, they are input to signal selector after double-channel filters.Finally, we can obtain double-channel physiologic and special signals that may be modified, deleted and appended by USART or USB.On the other hand, controlled by microcontroller, two pieces AD9833, programmable waveform generators, may produce double-channel general signals, which are sine, triangle and square-wave ones.And, they are also input to signal selector, which choices two channel signals from four ones to input gain regulator and power amplifiers in sequence.As a result, the two channel signals which meet user's demand are generated.Microcontroller, STM32F103RD, output all kinds of commands and data signal to control relative chips for generating needed signals.The gain regulator unit for adjusting amplitude of signals, power amplifier unit for enhancing ability of driving load, amplitude detector unit for measuring amplitude of real-time output signals, keyboard unit for user's imputing command, LCD monitor unit for display all kinds of information with FM19264, and power source unit for providing other parts with power to work are designed in this instrument.Hardware of eleven parts effectively ensures to realize the function of outputting double-channel medical and general signals.
The software of this instrument was designed by Kiel uVision3 for STM32F103RD.
The following below, we mainly describe six units of hardware and software of this instrument in detail.

The Primary Hardware
The important and vital units for this instrument are microcontroller unit, double-channel signal generator unit, memory unit, double-channel filter unit, signal selector unit and power amplifier unit.Therefore, we only describe those six units in details. 2

) Double-channel signal generator unit
The basic goal of this unit is to produce double-channel three type general signals with digital-controlled frequency and phase difference.And this function is very easy to show synthesis of two simple harmonic vibrations under different frequency, phase difference and direction, such as beat pattern and Lissajous chart.In this unit, two pieces of AD9833, a programmable waveform generator, are selected to generate single frequency sine signal for measuring human impedance characteristics and other functions.The AD9833 [4-6], whose function block diagram is shown in Figure 2, is a low power, programmable waveform generator capable of producing sine, triangular, and square wave outputs.The frequency, phase and waveform of outputting signal are software programmable, allowing easy tuning and no external components are needed.
The frequency registers are 28 bits wide.As a result, the output signal frequency is where is the value loaded into the selected frequency register, means input clock rate.
K f MCLK Therefore, with a 12 MHz clock rate, the AD9833 can be tuned to about 0.045 Hz resolution, and we can obtain single frequency signal with enough high precision of frequency.
The phase registers are 12 bits wide.Consequently, the phase difference of two output signals is where 1 is the value loaded into the selected phase register of one chip AD9833 and 1 is the other one, output P P K P  means user needed phase difference of two output signals.
Certainly, after STM32F103RD sends corresponding data to selected frequency and phase registers for two pieces of AD9833 at same time, we can get the needed signals with frequency, phase or phase difference and type. 3

) Memory unit
The primary aim of this unit is to save vast data of physiologic and special signals.For this reason, K9W5608U1M, flash memory, offered in 32Mx8bit with spare 8 M bit capacity.Its NAND cell provides the most cost-effective solution for the solid state mass storage market.A program operation can be performed in typical 200 ms on the 528-byte page and an erase operation can be performed in typical 2 ms on a 16 K-byte block.Data in the page can be read out at 50 ns cycle time per word.The I/O pins serve as the ports for address and data input/output as well as command input.The on-chip write control automates all program and erase functions including pulse repetition, where required, and internal verification and margining of data.Even the write-intensive systems can take advantage of the its extended reliability of 100 K program/erase cycles by providing ECC (Error Correcting Code) with real time mapping-out algorithm.
If every physiologic or special signal has 2 K bytes data for DAC producing relevant signal, K9W5608U1M has enough capacity to save 16,000 signals, which are sufficient for us.

4) Double-channel filter unit
Filtering undesired and smooth signal for DAC output is the fundamental target of this unit, which mainly includes one piece of ADG1439 and LT1362.ADG1439 is a CMOS dual 4-channel matrix analog switch with a serially controlled 3-wire interface and each switch is turned on or off by a separate bit, these parts can also be configured as a type of switch array, where any, all, or none of the four switches can be closed at any time.Hence, Controlled by microcontroller, ADG1439 can select 16 kinds of different resistance for RC low pass filter.We can change upper cut-off frequency through STM32F103RD for all kinds of different frequency physiologic and special signals.LT1362 acts as amplifier and constitutes active filter with ADG1439, and is quad low power high-speed operational amplifiers with outstanding AC and DC performance, and has high slew rate with 1 mV maximum input offset voltage and 1 μA maximum input bias current.Consequently, this doublechannel filter has high performance and may be changed upper cut-off frequency by matrix analog switch.

5) Signal selector unit
The signal selector unit, which is compose of ADG1439, is designed to choice two channel signals from four ones to input gain regulator and power amplifier in sequence.As a result, the two channel signals which meet user's demand are generated.ADG1439 is a dual 4-channel matrix analog switch and each switch is turned on or off by a separate bit.For this reason, it is very easy to realize that each output channel signal can be choice from the input four channel ones.

6) Power amplifier unit
The essential aim of this unit is to enhance this instrument's ability of driving load.This power amplifier unit includes THS6042, which is a high-speed line driver ideal for driving signals.THS6042 can output doublechannel high current whose typical maximum is 350 mA with thermal shutdown and short-circuit protection.This performance meets the demanding needs that acts as power amplifier of this instrument.

Design of Software
To realize the function, the software of this instrument must be designed, and we completed it by Kiel uVision3 for STM32F103RD with C language.The software, whose control flow is shown in Figure 3, is primarily composed of one main program and eight subprograms, which are memory control, AD9833 control, DAC control, signal selection and gain regulation control, ADC control, filter control, display and read key subprograms.Main program mainly calls read key subprogram to obtain the user input information and calls the correspond-ing subroutine to display frequency, amplitude and to choose right signals and channels output.Read key subprogram mainly gets the input keys' value and informs the main program.Display subprogram Controls LCD, FM19264, to display relevant information, such as frequency, amplitude, waveform type and so on.AD9833 control subroutine controls AD9833 to generate corresponding frequency, phase and type signal or disable it.DAC control one is to produce right physiologic and special signals.Memory control subprogram completes to read data from and write data to K9W5608U1M for DAC.At the same time, filter control one controls filter to realize filter interference signal.Signal selection and regulation control subprogram control signal selector and gain regulator unit to output user's needed double-channel signals.ADC control subprogram realizes to measureing amplitude of output signals.Interface control subprogram aims to communicate with external device and output or input data.Finally, through all subprograms, we can get our needed signals.

Operation Mode
This instrument has two operation modes.One is signal extraction mode for physiologic or special signals.The other is signal output mode.In each work mode, graphics dot matrix LCD shows corresponding signal waveform and related important information for information exchange with user.Two working modes can be directly switched through the key "Operation Mode Choice".Under first mode, user can send data of physiologic or special signal to STM32F103RD by USART or USB interface, and microcontroller saves corresponding data to flash memory K9W5608U1M.Of course, how to get the data about our needed physiologic or special signals is of great concern.However, it is very easy to gain the data by using software author designed [7], which can change the waveform figure to corresponding signal data.Therefore, under this mode, we can get all kinds of physiologic or special signals.
For second mode, needed double-channel signals, such as ECG signal, physiological and special signals, user's own defined signal or commonly used square, sine, and triangular signals, may be generated.Under this mode, we can gain signals that meet our needs by input relevant information to this instrument.

Discussions and Conclusions
This instrument adopts single-chip control and highperformance signal waveform generators and 32-bit Cor-tex™-M3 CPU.As a result, it can output double-channel signals and applies LCD to display all kinds of information.At same time, this instrument equipped with two kinds of signal sources.One comes from double-channel generator unit and other from double-channel filter unit.In addition, all kinds of control and choices are application of electronic switch without mechanical contact, by using in practical, it not only is convenient to be operated, but also has performance extremely high working stability and reliability.
Using this instrument, many kinds of physiological signals can be modified by USART and USB interface that has well open property.Therefore, it is convenient to append, delete and modify physiological and special sig- In addition, this instrument can be used as high-precision frequency and high drive sinusoidal signal source for research and teaching in testing human impedance haracteristics.And using this instrument, it is easy to show synthesis of two simple harmonic vibrations under different frequency, phase difference and direction, such as beat pattern and Lissajous chart.For testing its soundness, we show synthesis of two simple harmonic vibrations under different frequency and same phase along perpendicular direction as c Therefore, with full confidence, we could draw a conclusion that this generator is very convenient to get needed all kinds of physiological signals and common signals.In general, this generator has many merits, such as the small volume, stable property, simple operation, visual display.And, it can be widely used in researching, teaching, debugging and maintaining in medical field and other fields.

Figure 1 .
Figure 1.Block diagram of the instrument.

1 )
Microcontroller unit The microcontroller is composed of microprocessor STM32F103RD [3] and its peripheral components.It is a single-chip microcontroller that bases on a high-performance ARM 32-bit Cortex™-M3 CPU and can work in 72 MHz maximum frequency, has USB 2.0 full speed and five USARTs interface, and has 12-channel DMA controller, 3 × 12-bit and 1 μs A/D converters, 2 × 12-bit D/A converters with 384 K bytes Flash program memory, 64 K bytes SRAM memory, a Watchdog Timer.Furthermore, all sorts of physiologic and special signals are generated by using the two 12-bit DACs integrated in STM32F103RD and two 12-bit on-chip ADCs are used to measure amplitude of outputting signals.In a word, STM32F103RD play a major role and controls other parts to realize data exchange and corresponding function in this instrument.

Figure 4 .
Figure 4. Examples for application of this generator: (a) Shows two physiological signals; (b) Shows one physiological and one triangular signals; (c) Shows synthesis of two simple harmonic vibrations with frequency ratio 3:1 and the same phase along perpendicular direction; (d) Shows synthesis of two simple harmonic vibrations with frequency ratio 3:1 and phase difference π/2 along perpendicular direction.
nals.For example, physiological and triangular signals, which generated by the instrument, are shown in Figures 4(a) and (b).
Figure 4(c) and at the same time, show synthesis of two simple harmonic vibrations under different frequency and phase difference π/2 along perpendicular direction as Figure 4(d).