Wireless Electromyograph using ATmega32

Introduction

This project implements a wireless surface electromyograph that displays the signal using a television as an oscilloscope.

Wireless Electromyograph using ATmega32

Electromyography detects the electrical signals that the human body generates to contract muscles. Detecting very low voltages in the milliVolt range on the skin surface is not a trivial task. As shown in figure 1, EMG signals are inherently low frequency signals. The human body is a great antenna and filtering out RF and 60Hz power system noise is essential to observing the EMG signal. The course safety requirement for the final projects required that any human body connection be electrically isolated from the 120V power grid. Thus, the human side of the system must be powered using 9V batteries. Converting the analog EMG signal to digital and transmitting using a wireless transmission protocol was an effective way to electrically isolate the human. The transmitted EMG data was displayed on a television we setup to be a virtual oscilloscope.

High Level Design

The study of these electrical signals contractions is an important research tool when studying animal and human biology. We chose this project because it was an interesting way to combine our knowledge from a variety of fields to build a complex machine. We used what we learned in this class about microcontrollers to build an analog to digital converter and generate a TV display. We used our knowledge of analog circuitry to build the infrared transmission. Finally, we learned about nerve conduction across muscles to build an amplifier capable of detecting nerve impulses while filtering out noise.
In order to implement a wireless EMG, four major components are required. First an instrumentation circuit is required to receive, filter, bias, and amplify the signal so that it can be converted to a form suitable to be digitally sampled using 8-bit, 0-5v analog to digital conversion. The second component is the transmission circuit. This circuit performs the analog to digital conversion, transmits the signal in RS-232 format, translates the RS-232 format to the IrDA standard, and transmits the wireless infrared signal. The third component is the receive circuit which receives the IrDA standard signal and converts it back to RS-232. The fourth component is the display circuit. A microcontroller is used to receive the RS-232 signal and drive a television with the necessary NTSC compatible signals that display the EMG signal digitally on the TV as a digital oscilloscope (figure 2).

Figure 2: Wireless EMG in four steps

To implement this design, four components were used: a front end EMG amplifier, encoder, and transceiver (figure 3), an STK500 (figure 4), a back end transceiver and decoder (figure5), and a Mega32 prototype board (figure 5). The front end amplifier is a differential amplifier (INA106, see appendix) that amplifies the voltage drop between the two skin adhesive electrodes the human is wearing (generally on the bicep). This signal is sent to the analog to digital converter (ADC) of the STK500 to be converted into an RS-232 signal and sent back out using the UART. The RS-232 signal is then encoded by the MCP2120 IR encoder and sent to the IR transceiver. The IR transceiver on the back end breadboard receives the signal and sends it to the MCP2120 for the data to be decoded into RS-232 data. The prototype board receives the RS-232 data and outputs it to the TV.
There were opportunities to trade software for hardware. The gain of the differential amplifier was set by the resistors in the INA106 precision gain differential amplifier packaging (see appendix) and external resistors. Using the hardware gain, a small amplitude signal appears on the TV/oscilloscope. The hardware gain could be increased only so far, because it became difficult to match the resistors used to set the gain. Instead of trying to increase the hardware gain more, we chose instead to add a variable software gain. By pressing a button, a gain of 1, 2, 4, or 8 can be selected by left shifting the amplitude of the signal displayed on the TV. Another tradeoff was the choice to use the MCP2120 Infrared Encoder/Decoder (see appendix) to encode the signals before they were transmitted and decode them when they were received. It was possible to use the Atmel Mega32 to encode and decode the signals, but since the Mega32 on the decode side was running the TV display code, this option had to be discarded.
Three standards were used in this project: RS-232, IrDA, and NTSC. RS-232 is the standard for serial communication. It was used to communicate between the Mega32 chips and the infrared (IR) encoder/decoders. IrDA stands for the Infrared Data Association and is the standard for short range communication using infrared light. It was used to communicate between the two IR transceivers and between the IR transceivers and the IR encoder/decoders. NTSC stands for the National Television Systems Committee who defined the standard for monochrome television display.
Since one of the lab partners is an MEng student, Cornell University owns all copyrights and potential, patents related to this project. Since the ideas and implementation of our project hardware are solely our own there should not be any trademark, patent, or copyright infringement issues.

Program / Hardware Design

There are two Mega32s running different code in this project. The basic code was fairly simple: the first Mega32 runs ADC code studied in the digital thermometer lab, while the second Mega32 runs the TV code studied in the video game lab. There was a problem in that the STK500 Mega32 only communicates the ADC data. Several inputs were considered for the STK500, but integrating data in addition to ADC data was not feasible in the amount of time for the project. The prototype board Mega32 has two inputs, one freezes the data on the screen, the other performs a shift operation on the EMG signal before displaying it, creating a software gain. This was difficult to write because the Mega32 was close to its memory limit. Several unused functions were deleted and some of the variables were recast to keep memory use down.
The circuitry for the EMG measurement, above, needed to be electrically isolated from the 120V ground for the building for safety reasons. A 9V battery was used to charge the amplifier circuitry. The STK500, where the analog to digital conversion takes place, uses a Vcc of 5V, so instead of powering the amplifier with 9V, we used the MAX666CPA (see appendix) voltage regulator to create a Vcc for the whole breadboard of 5V.
The LM7111 operational amplifier was used to provide a virtual ground for the differential amplifier. Since the EMG signals are positive and negative, the amplifier needed to have positive and negative rails. Thus, the virtual ground was set at 2.5V. The differential amplifier used the 0V ground as -2.5V and the 5V Vcc as 2.5V. Since the STK500 and the breadboard share the same 0V ground, the signal coming in to the ADC would be an EMG signal with a 2.5V positive offset. The virtual ground was created by using a voltage divider to split 5V in half and apply it to the non-inverting terminal of the LM7111. The output was fed back to the inverting terminal of the op amp, creating a buffer, or voltage follower. In this way a stable reference voltage was created without loading the battery except through the voltage divider.
The front end amplifier was designed to amplify the potential across two points on a human muscle group. These potentials are fairly weak, since human nerve impulses travel at a variable depth beneath the skin surface. The signals are also strongest at 50Hz, which is close to the 60Hz noise that comes from the AC devices in the room. The first problem was solved by amplifying the signal as much as possible. The INA106 differential amplifier has a gain of 10, but that can be increased using external resistors. These resistors need to be closely matched, or there will be no output. We used 1MO external resistors, making the gain equal to:
The other problem, the 60Hz noise, was solved by using the differential amplifier to measure the signal. The signal from the proximal electrode m1, is subtracted from the signal from the distal electrode, m2. Since both signals travel the same path to the differential amplifier, it can be assumed that they pick up approximately the same amount of noise, n. The differential amplifier amplifies the difference of these two signals: A((m2 + n) – (m1 + n)) = A(m2 – m1), so the noise is canceled out. In choosing a differential amplifier to use for this project, we looked for one with a gain greater than 1, but we also looked for one with a high common mode rejection ratio (CMRR). The CMRR of a differential amplifier measures its ability to reject noise on the input. Using an amplifier with a low CMRR will produce more noise on the output, but an amplifier with a very high CMRR will also produce more noise on the output because the noise is not likely to arrive in phase, given the measurement tools we are using. The INA106 has a CMRR of 86db. We looked at differential amplifiers with a CMRR between 70db and 100db.
The electrodes for the experiment were connected the same way every time. Two skin adhesive electrodes were connected to Ben’s left bicep. The inverting input of the differential amplifier was connected to the center of the left bicep. The non-inverting input was connected to the distal end of the left bicep. A third electrode was connected to the right elbow. This electrode was used as a reference electrode, and was connected to the virtual ground created by the LM7111. The reference electrode can be placed in any electrically neutral place on the body.
The infrared transmitter circuit, above, was designed to convert the analog signal coming from the differential amplifier to digital and transmit it wirelessly to a receiver. The final digital signal is then output as a standard RS-232 UART signal on pin D.0 of the Mega32. A Microchip MCP2120 IrDA encoder/decoder is then used to convert the RS-232 signal to the IrDA standard. It is essential that the baud rates of the Mega32 UART and the IrDA encoder match. A clock oscillator circuit is used to drive the MCP2120 at 3.575945 MHz. The selection of this clock frequency was due to the fact that we scavenged these parts for free from previous ECE476 projects. Setting the BAUD 0:2 pins to 000 sets the MCP2120 clock divider value to 768. This produces a baud setting of:
The MCU must also be set to transmit at a 4661 baud rate to match the IrDA circuits. This is done by setting the UBRRL register to the correct value according to the equation:
It is worthwhile to note that a clock rate of 3.6864MHz would produce baud rates that are multiples of standard communication frequencies such as:

Wireless Electromyograph using ATmega32  circuit
The IrDA compatible signal is then transmitted using a Zirlog ZHX1010 IrDA Transceiver. This device takes 0-5v CMOS compatible signals and contains a IR diode with sufficient rise time and optimal transmission spectrum of 880m as specified in the IrDA standard. The IrDA standard also specifies that transmitters must transmit using enough power for the signal to be reliably received at 1 meter; a standard that our circuit meets.

Also shown in the schematic is a optional opto-isolator circuit which was used as a backup to directly transfer the UART signal to the receiver via a wire. This was necessary to safely test the instrumentation and display circuitry during the implementation and debugging of the infrared portion of the circuit. Since the bias level of the EMG signal tends to drift we incorporated a bias level adjustment controlled by the buttons on the STK500.

Parts list:

Atmel Mega32
INA106 Precision Gain Differential Amplifier
LM7111 Operational Amplifier
MCP2120 Infrared Encoder/Decoder
Zilog SIR Transceiver
Maxim 666CPA Voltage Regulator
4N35 Optocouplers
Vermed 1 7/8″ foam, solid gel, all purpose electrode
 
For more detail: ECE 476 Final Project: Wireless Electromyograph


About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation and engineering. My writing style is clear and simple, and I am skilled in using infographics and diagrams. I am a great researcher and am able to present information in a well-organized and logical manner.

Follow Us:
LinkedinTwitter
Scroll to Top