In order to study the mechanism of DBS in treating epilepsy, a miniature vagus nerve stimulator (VNSr) was first developed and implanted in rats for epilepsy treatment. The nerve stimulator stimulating electrodes and electroencephalogram (EEG) recording electrodes were implanted in rats at postnatal 35 days (P35) and P60, respectively. The vagus nerve was stimulated by the electrical stimulator with pulses of a certain frequency, pulse width and intensity. The therapeutic effect of the nerve stimulator on epilepsy was determined by observing the frequency of spontaneous recurrent seizures (SRSs), the spectral changes of cortical and hippocampal EEG, the visual-spatial memory function of the animals by water maze, and the neuropathological changes of the brain by Timm and Thionin tissue staining.
The electrical stimulator consists of three parts: implanted electrodes, connecting wires, and a subcutaneous pulse generator. The stimulation current generated by the pulse generator stimulates the vagus nerve through the stimulation electrode. The electrical stimulator implanted in the animal needs to be turned on at a set time. In a time interval, a certain frequency of stimulation pulse current is emitted. This article mainly describes the design concept of the electrical stimulator.
1 Electrical stimulator design requirements
The electrical stimulator implanted in the animal in this system is open-loop controlled and set to intermittent working mode. According to the previous experimental results and the parameters provided in reference 1, the working interval of the stimulator is 5 and a half minutes. The stimulator outputs a stimulation current every 30 seconds, and then stops working for 5 minutes, and repeats this cycle. The working process is to output a stimulation current with a frequency of 30Hz and a pulse width of 500μs. In order to accurately control the set parameters, a single-chip microcomputer is embedded in this system. The system structure block diagram is shown in Figure 1.
The key to the design of the electrical stimulator is high reliability, miniaturization and low power consumption. Therefore, a button battery is used for power supply, and a high-reliability single-chip microcomputer and components with low power consumption and small package are selected.
2 Voltage Regulation
This system is powered by a 3V button-type lithium battery. In order to meet the intensity requirements of the stimulation current, the voltage needs to be boosted. The voltage should be boosted by a high-efficiency compact DC/DC. There are many compact boost DC/DC IC components available, such as LM2703 and LM2733 from National Semiconductor, LT1615 from Linear, TPS61040 from Texas Instruments, AP1522 from Taiwan Yiheng Electronics, etc. These ICs are all SOT23-5 compact packages with fully compatible pins, which is why this system uses this IC. There is no need to worry about chip shortages. The ICs can be interchanged by slightly modifying the parameters of the peripheral components. The wiring schematic of the voltage adjustment circuit is shown in Figure 2.
LT1615 is a micro-power high-efficiency step-up DC/DC with an input voltage range of 1.5V~15V, suitable for applications where the maximum output current is less than 100mA. The chip's quiescent operating current is 20μA when unloaded. When the 4-pin SHDN is low and the chip is turned off, its quiescent operating current is only 0.5μA. The chip's operating efficiency is about 75%. The output voltage value is determined by R2 and R4 in the figure: .
Use a 3V battery to directly power the microcontroller. The microcontroller controls the power supply of peripheral circuits including the DC/DC circuit through the ON_OFF in the figure. When it enters the sleep state without output pulses during the intermittent period of work, ON_OFF is set to a high level to cut off the power supply of the peripheral circuits, thereby effectively reducing the current consumption of the system.
3 ATmega48 microcontroller and its pulse generation circuit
3.1 ATmega48 MCU and its applications
ATmega48 microcontroller is a micro-power high-performance 8-bit microcontroller launched by Atmel at the end of 2004. It adopts TQFP32 compact package. For mass production, it can also choose MLF32 package with smaller volume (size is only 5mm×5mm). It has 4KB Flash program memory, 256B EEPROM and 512B static memory. It supports ISP serial download mode.
The ATmega48 microcontroller is a RISC structure with a speed of 1MIPS at a frequency of 1MHz. The system clock has multiple working modes to choose from, such as external low frequency, external high frequency, and internal RC oscillator clock. The selection method is achieved by programming the fuse bit and combining software programming with the clock-related registers. The higher the clock frequency of the microcontroller, the greater the power consumption of the microcontroller. This system uses a 128kHz internal RC oscillator. When the operating voltage is 3V, the static current is less than 60μA. The static current is even lower in sleep mode. There are six power-saving sleep modes in the ATmega48 microcontroller, which can put the instrument into sleep mode during non-working periods. The system clock of ATmega48 can also be further reduced by programming frequency division to reduce power consumption. During the instrument sleep period, a 32-fold frequency division factor is used to reduce the clock to 4kHz.
The ATmega48 microcontroller has two 8-bit timers/counters and one 16-bit timer/counter, which can meet the precise control of the opening time, pulse width, and pulse frequency of this system. In addition, the microcontroller has 6 PWM output ports, which can be used to adjust the stimulation intensity of the instrument. The ATmega48 microcontroller has an independent hardware watchdog clock inside, which can effectively prevent the microcontroller from crashing.
The ATmega48V used in this system is a low-voltage chip of ATmega48. ATmega48V is used as the main control chip of the electric stimulator, and almost no other components are needed. ATmega48V can work at a voltage range of 1.8V~5.5V. Within the effective voltage range of the battery, the microcontroller can work normally and make full use of the battery capacity. [page]
3.2 Pulse generating circuit
Usually, a pulse output circuit with a certain driving power first generates a pulse waveform, and then drives and amplifies the pulse waveform with an integrated power amplifier, and the amplifier circuit works in the linear amplification area. This amplifier circuit must have a static current to maintain a suitable static operating point, and the power consumption is relatively large. In order to reduce the current consumption, the electrical stimulator of this system generates stimulation pulses in a switching manner. The circuit principle of the single-chip microcomputer and its pulse generator is shown in Figure 3. J1 is the wiring terminal of the stimulation electrode, and OC0A is the PWM output port of ATmega48V timer 0. The output intensity is adjusted according to the requirements of the experiment. The PWM output and the filter composed of R6, R7, C6 and C7 are used to adjust the input voltage of U3A positive phase. The operational amplifier U3A is connected in a positive phase amplification mode, and the amplification factor is determined by R8 and R9. Q2 is a power amplifier transistor to increase the output driving capability. Q3 works in a switching state and is used to control the width and frequency of the output pulse. When the 9th pin of ATmega48V is at a high level, Q3 is turned on and a stimulation pulse is output. After 500μs of conduction, the 9th pin of ATmega48V changes to a low level, Q3 is turned off, and the pulse ends. This cycle repeats at a frequency of 10Hz.
4 Function Implementation and Software Programming
ATmega48 has 131 instructions, most of which are single machine cycle instructions, and the instruction system is very rich. ATmega48 takes the operation mode of C language into consideration when designing instructions, and programming in C language can achieve high code efficiency. ATmega48 belongs to the AVR series of single-chip microcomputers. There are two commonly used C languages for AVR single-chip microcomputer development: AVR-ICC and AVR-GCC. AVR-ICC is a commercial AVR C language integrated development tool (IDE), with a friendly interface, simple to use, and good technical support from manufacturers and agents. AVR-GCC is a free software that relies on the popular open source code on the Internet. You can download the compiler software and various tool software for free from the Internet (http://www.avrfreaks.net). Since AVR-GCC has a large number of experts involved in the development and many online participants in the test, its software update speed, code efficiency and software defect rate elimination are very good. However, AVR-GCC is transplanted from the UNIX platform and retains the UNIX-like operation mode. For Windows users who are not familiar with UNIX, it is difficult to get started with it. Only after being proficient in it can you feel its powerful functions. There is a forum about AVR-GCC on http://www.avrfreaks.net, and many problems in use can be helped in the forum. Because AVR-GCC has low cost and excellent functions, this system uses AVR-GCC as a programming tool.
The electrical stimulator enters a dormant state during the intermission period of work. ATmega48 has 6 dormant modes. Different components are put into dormancy in each mode, and the power consumption of the microcontroller after dormancy is also different. Since the electrical stimulator requires regular reawakening to work when in dormancy, a timer must be kept working. Therefore, the selected dormancy mode is IDLE. In IDLE mode, timer 2 can still work. The following is the program for the dormancy part.
set_sleep_mode(SLEEP_MODE_IDLE); //Set sleep mode to IDLE
SMCR |= _BV(SE); //Allow sleep
_asm_ _volatile_ ('sleep' 'nt' :: ); //Enter sleep
SMCR &= ~_BV(SE); //Wake up from sleep and enter working state, do not allow sleep
Timer 2 is used to time the time interval of the sleep period. t2_init_idle(void) is the program for initializing timer 2 before entering the sleep state, and SIGNAL(SIG_OVERFLOW2) is the interrupt service program for timer 2 in the sleep state. Timer 2 will generate an overflow interrupt every 1 minute to wake up the MCU.
void t2_init_idle(void){ //Timer 2 initialization before entering sleep state
CLKPR=(1<<CLKPCE); //Allow system clock to change; change system clock before entering sleep state
CLKPR=0x05; //System clock division ratio is 32, system clock is 4kHz
TCCR2A=0; //Timer/Counter 2 works in timer mode
TIMSK2=(1<<TOIE2); //Allow timer 2 overflow interrupt
TCCR2B=0x07; //Timer 2 clock division ratio is 1024
TCNT2=32; //Timer 2 generates the initial value of 1 minute timing
}
SIGNAL(SIG_OVERFLOW2){ //Timer 2 overflow interrupt service routine
TCNT2=32; //Reset timer 2 to generate the initial value of 1 minute timing
min++; //Minute count
}
After waking up 5 times, that is, sleeping for 5 minutes, the microcontroller re-enters the wake-up working state. In the wake-up working state, timer 2 is used to control the width and frequency of the pulse. Timer 2 needs to be reinitialized and the system clock is restored to 128kHz (the program is omitted).
Set timer 0 to work in PWM output mode to control the stimulation intensity.
void t0_init(void){ //Timer 0 initialized to PWM output
TCCR0B=(1<<CS01); //Timer 0 clock division ratio is 8
TCCR0A=(1<<WGM00)|(1<<WGM01); //Fast PWM mode
TCCR0A|=(1<<COM0B1); //Low level when meets, peak value becomes high
OCR0B=outv; //Output level is controlled by OCR0B
}
The overall system program flow is shown in Figure 4.
The development of the electrical stimulation experiment device is to be implanted in rats to study the mechanism of electrical stimulation on epilepsy suppression. The overall structural size of the electrical stimulation experiment device developed in this study is Φ17mm (diameter) x 7mm (thickness). The pulse generation and amplification circuit is implemented in a switching manner, which greatly reduces the power consumption of the system. The ATmega48 microcontroller is used to control the output pulse, which has high precision, low power consumption, reliable operation, and can work continuously for more than one month, meeting the requirements of the experiment.
Previous article:Design and implementation of home alarm system based on ATmega128 and GSM
Next article:USB interface design based on ATmega128 and CH374
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- Power supply obstacle" + electromagnetic interference and inductive howling
- Install an N102 on STM32F103 and experience NB-IoT development at home
- Switching Power Supply
- TMS320C6748 DSP Development Kit (LCDK)
- Selecting a buck-boost solution
- MSP430F5529 library functions
- Recruitment for part-time MBSE technical or consulting services
- EEWORLD University - 10 hours to learn image processing opencv introductory tutorial
- Single chip LCD1602 display program-controlled measurement amplifier
- Simple laser flashlight circuit diagram