Design of a micro-power electrical stimulator based on ATmega48

Publisher:数字冒险Latest update time:2012-02-24 Source: 21ICKeywords:ATmega48 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Movement disorders originate from the imbalance between different neurotransmitters, and the deformation and necrosis of nerve cells in different parts are the neurobiological basis for the imbalance of neurotransmitters. In the past, the treatment of movement disorders mainly used two methods: drug therapy or surgical destruction of the globus pallidus. The first treatment approach is either ineffective or cannot be tolerated by patients due to the large side effects of the drugs; and the second approach, namely surgical destruction, also has particularly large side effects. If a specific nucleus in the brain can be stimulated to change the functional activity of the nucleus, it is possible to correct the imbalance between neurotransmitters to a certain extent, thereby achieving the purpose of treating movement disorders. Since 1960, neurologists and neurosurgeons have found through research that deep brain stimulation (DBS) can improve certain symptoms of neurological diseases such as essential tremor and Parkinson's disease. Researchers predict that DBS may also be used to treat diseases such as epilepsy, pain, multiple sclerosis, paralysis, obsessive-compulsive disorder and depression.

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.

Design of a micro-power electrical stimulator based on ATmega48

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.

Design of a micro-power electrical stimulator based on ATmega48

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: Design of a micro-power electrical stimulator based on ATmega48 .

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.

Design of a micro-power electrical stimulator based on ATmega48

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.

Design of a micro-power electrical stimulator based on ATmega48

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.

Keywords:ATmega48 Reference address:Design of a micro-power electrical stimulator based on ATmega48

Previous article:Design and implementation of home alarm system based on ATmega128 and GSM
Next article:USB interface design based on ATmega128 and CH374

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号