Myoelectric Amplifier - 0.8.1

Description

Myoelectric devices are a subset of electromyography which focuses on the measurement of the small potential that flows across a muscle. These devices are most commonly used in the prosthesis industry to add motor function to a prosthetic limb that would otherwise be a solid lump of plastic. I am not actually an amputee but about a while back I saw this muscle sensor made by myoware. I thought this was pretty cool and was definitely something I wanted to work with but I also thought I could probably make one for cheaper than £30. So, after some research, I came up with a design.

Before I get onto that however, let's talk a little about the very basics. Muscles contract when a small potential flows across them, this is usually in the range of -40mV to -80mV in the actual muscle membrane. Measuring this potential is usually done via three electrodes, usually placed on the surface of the skin above the muscle but can also be inserted into the muscle for a more precise reading. The signal from the electrodes can then be amplified to a more useful state and then interrogated for your purpose. In my case, this involves rectifying the signal so that it can be read by an Arduino. This page is more of a log than a description of the design as I'm still working on the design as of December 2019.

Section 0 - The Plan

The plan is fairly simple, attach 3 electrodes to my arm, filter the signal to remove any unwanted frequencies that are picked up along the way, rectify the signal to a range of 0-5V, smooth the result to remove the dips in the signal and then finally pass it to an Arduino to be used to control a prosthetic or whatever.

Section 1 - Electrodes

The first step was to buy or put together some electrodes. I've been informed that prosthetics which incorporate this technology use stainless steel electrodes to prevent corrosion, so in order to make this as cheap as possible my first plan was to macgyver some electrodes together by printing some armbands and threading some bolts through them. Preliminary tests showed these as ineffective electrodes, maybe I needed a coupling fluid to reduce the resistance but I bought some proper electrodes with a coupling gel pre-applied and decided to use those instead.

That's the electrodes sorted but why use 3 when you're only measuring one muscle? To explain this we need to take quick a biology lesson. Two of the three electrodes will be placed on the muscle we are measuring, in my case, this is the bicep. This is because your body will act as an antenna when hooked up to the circuit creating lots of interference in the signal you'll be measuring. However, the potential that flows across muscles travels much slower than it would across a copper wire meaning that taking a reading from two points on the muscle at the same time will produce different readings. One will just read the interference and one will read the interference and the signal, subtracting one from the other will result in only the signal showing up. As for the third electrode this is placed somewhere else on the body as a reference. The human body is not usually grounded and therefore its base potential is not always 0V. This third electrode reads the base potential of the body so that the signal can be shifted to ground as a base potential when it is amplified.

Section 2 - Signal Filtering

Now that I have electrodes I can start processing the signal. First off I need to remove the unwanted frequencies and any DC voltage that will mask the signal when amplified. To do this we can use a band-pass filter on each of the electrodes attached to the muscle. I used the circuit below on each of the electrodes to do this. If I wanted to make the cut-off even more immediate I could add a second band-pass filter, I may do this in the future but currently, a single filter does just fine.


For those stumbling across this unaware of what a band-pass filter is. Essentially it's a circuit formed of a low and high pass filter used to cut out, or filter, all frequencies except a specific range. A these filters are formed of a capacitor and resistor in a potential divider that takes advantage of a capacitors resistance to current changing depending on the frequency of the current passing through the capacitor. Frequency cut-off for a low or high pass filter can be calculated using:
fc = 1/(2πRC)
Normally you would have a cut-off frequency in mind, choose a resistance and solve the equation for capacitance but I have a larger range of resistances that capacitors so I'm going to solve for resistance using:
R = 1/(2πCfc)
Myoelectric signals are usually in the range of 5-500Hz according to my notes. So the resistances I need for the 0.1uF capacitors I'm using are:
R = 1/(2π*5*(0.1*10-6)) = 319319Ω ≈ 0.3MΩ for the high pass filter and:
R = 1/(2π*500*(0.1^10-6)) = 3183Ω ≈ 3.2kΩ for the low pass filter.

Section 3 - Amplification

That's signal filtering done. Next up, signal amplification. For this, I used an instrumentation amplifier DIP or in-amp for short. These devices will take 2 signals in, subtract one from the other and then output the resulting signal in relation to the reference voltage amplified by a value set using a calculated resistance. It is worth noting that as we are dealing with AC signals that a supply of negative voltage is required as well as a positive supply. I'm using an Arduino as a power supply as I plan on reading the conditioned signal with one. To get the negative supply I used a negative voltage converter breakout board. The in-amp I chose was an INA126. I am now aware this is not the best in-amp for the job and will probably change it for another if I make another version of this which is likely. Below is a schematic of the setup.


The capacitors on the power supply terminals are bypass capacitors to account for any transient currents. Gain was calculated using the equation supplied in the IC's datasheet:
G = 5 + (80*10^3/Rg)
Rearranging this we can get the equation to calculate the resistance for a specified gain:
Rg = (80*10^3)/(G-5)
The signal we get from the muscle at the surface of the skin is much weaker than the signal inside the muscle. This is about 50uV - 30mV though from my experience I found the maximum was more around 1mV but I'm not as toned as I could be so your mileage may vary. For me, a maximum output of 0.9V away from the input voltage at either peak (5-0.1=4.1V) means I want my gain to be Vmax-0.9/Vin which ends up as 5-0.9/0.1x10^-3 or ~4000. Substitute this number into the gain equation for Rg we get 80000/(4000-5) which ends up being ~20Ω

Now the amplifier is set up we can test it using an oscilloscope to find out that while the circuit is not perfect it does output what seems to be a signal that increases with muscle contraction. Next up rectification. Coming whenever my replacement headphone ports get here from China.

Update: While waiting on replacement parts I took the opportunity to switch the in-amp to an AD8221 which seems to be working better or atleast more consistently than the INA126. This also seems to be the one the myoware sensor that inspired this project uses.

Section 4 - Rectification

The common rectifiers used in AC-DC mains transformers are usually formed up of 4 diodes and a capacitor, The diodes ensure the AC voltage always stays above ground and the capacitor smooths the signal during the dips. Rectifiers like this are fine for when the value of the signal is unimportant but when the you want to measure a rectified signal using a conventional rectier is less than ideal. Potential will be lost over the diodes or the signal will be lost completely as the potential required to activate the diode is higher than the actual signal used. For this reason when rectifying signals that need to be measured precision rectifiers are used. These involve using op-amps to account for the voltage drops of diodes.

I will be using a full wave precision rectifier (FWPR). Like full wave bridge rectifiers these invert any signal below ground so that none of the signal is lost. FWPRs are formed of two parts. The first part is a half wave precision rectifer. The second part is an inverting summer. The end result looks something like this:


Full-wave precision rectification is done in 2 stages. First the input signal, in my case the signal output from the instrumentation amplifier, is passed through a half-wave precision rectifier (HWPR) which takes the full wave and only outputs negative half of the wave form. This is done by 2 diodes and a virtual ground. If the signal output by the first op amp is positive than the signal will go through D1 but because of the vitual ground the signal will only be equal to the voltage drop of the diode, therefore the output into the inverted summer will be 0. If the signal output by the first op amp is negative than D2 will be activated and will be passed to the inverted summer.The inverted summer section does what the name suggests, it outputs the inverse of the sum of the signals going into the negative input. The two inputs in this case are the negative half of VIN output by the HWPR and the full wave form of VIN taken directly from the VIN terminal. If VIN is negative then the output of the HWPR is 0 so the ouput of opamp2, and therefore the whole circuit, is -VIN which in this case is positive as VIN was negative (-VIN*-1 = VIN). If VIN is positve then the output of opamp1 is negative. This means that the signal at the negative terminal is -VIN + VA. However, because VA is calculated based on VIN we can right this equation completely in terms of VIN:

According to OPAMP1 VA = -VIN and if the input of OPAMP2 is only made up of VA that means that VOUTva = -(R5/R4)*VIN = -2(VIN).

Therefore taking into account both inputs this means that VOUT = -VIN - -2(VIN) or simplified: VOUT = VIN


So after all that when VIN is positive VOUT is positive and when VIN is negative VOUT is also positive. Therefore rectifying the signal completely so that no section of the signal is lost. Now that the signal is rectified I can actually pass the signal to an arduino so I can use it to manipulate other components. However the signal still has dips to ground in it from when the signal was bipolar so I'm first going to smooth the signal on a hardware level so that the microcontroller has to do less processing. This will be the next stage but before that below is a very low quality gif (thanks to the file convertor and my potato phone) of the current circuit working.

Links