Upsidedown Labs Muscle bioamp candy Electroboffin

Muscle BioAmp Candy

What is Muscle BioAmp Candy?

It’s an affordable Muscle sensor for recording precise EMG signals. It can be used with any microcontroller with ADC. Its hardware and software are completely open-source, and you can take a look at its GitHub page.

Features and specifications:

  1. Dimensions: 35 X 15mm
  2. Input Voltage: 3.3V -30V
  3. Input Impedance: 10^11 Ω
  4. Bandpass Filter: 72-720Hz
  5. No. of channels: 1

But the question is what is EMG?

EMG or Electromyography procedure to diagnose the muscle health and motor neurons which controls them. EMG is helpful in the detection of muscle dysfunction, nerve dysfunction, or issues in signal transmission between nerve and muscle. With the help of electrodes, the electrical signals transmitted by motor neurons can be detected and can be translated into graphs, numerical values, and sounds which can be used by doctors for the diagnosis of problems faced by patients. The electrical signals will only be generated when the person is willing to move the muscle, if someone else moves that muscle of the person whose EMG is being recorded, the electrical signals will not be generated which is shown by the Upsidedown Labs team in the video below:

Now the question is how to use this sensor, so the circuit diagram for this sensor with Arduino Nano board is shown in Figure 1 below. Don’t worry, it’s not complex at all to connect this sensor with other development boards such as Arduino UNO, ESP32, ESP8266, etc. There are only 3 pins in the sensor viz. VCC, GND, and OUT. Connect VCC to 5V, GND to GND, and OUT to the Analog Input pin of the development board.

The next step is to stick the electrodes to the muscle from where the EMG signal is to be recorded. The placement of electrodes for the same is shown in Figure 2 below. Once you are done with sticking your electrodes, connect the BioAmp Cable V2 with the sensor.

// Upside Down Labs invests time and resources providing this open source code,
// please support Upside Down Labs and open-source hardware by purchasing
// products from Upside Down Labs!

// Copyright (c) 2021 Upside Down Labs - contact@upsidedownlabs.tech

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#define SAMPLE_RATE 500
#define BAUD_RATE 115200
#define INPUT_PIN A0
#define BUFFER_SIZE 128

int circular_buffer[BUFFER_SIZE];
int data_index, sum;

void setup() {
	// Serial connection begin
	Serial.begin(BAUD_RATE);
}

void loop() {
	// Calculate elapsed time
	static unsigned long past = 0;
	unsigned long present = micros();
	unsigned long interval = present - past;
	past = present;

	// Run timer
	static long timer = 0;
	timer -= interval;

	// Sample and get envelop
	if(timer < 0) {
		timer += 1000000 / SAMPLE_RATE;
		int sensor_value = analogRead(INPUT_PIN);
		int signal = EMGFilter(sensor_value);
		int envelop = getEnvelop(abs(signal));
		Serial.print(signal);
		Serial.print(",");
		Serial.println(envelop);
	}
}

// Envelop detection algorithm
int getEnvelop(int abs_emg){
	sum -= circular_buffer[data_index];
	sum += abs_emg;
	circular_buffer[data_index] = abs_emg;
	data_index = (data_index + 1) % BUFFER_SIZE;
	return (sum/BUFFER_SIZE) * 2;
}

// Band-Pass Butterworth IIR digital filter, generated using filter_gen.py.
// Sampling rate: 500.0 Hz, frequency: [74.5, 149.5] Hz.
// Filter is order 4, implemented as second-order sections (biquads).
// Reference: 
// https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.butter.html
// https://courses.ideate.cmu.edu/16-223/f2020/Arduino/FilterDemos/filter_gen.py
float EMGFilter(float input)
{
  float output = input;
  {
    static float z1, z2; // filter section state
    float x = output - 0.05159732*z1 - 0.36347401*z2;
    output = 0.01856301*x + 0.03712602*z1 + 0.01856301*z2;
    z2 = z1;
    z1 = x;
  }
  {
    static float z1, z2; // filter section state
    float x = output - -0.53945795*z1 - 0.39764934*z2;
    output = 1.00000000*x + -2.00000000*z1 + 1.00000000*z2;
    z2 = z1;
    z1 = x;
  }
  {
    static float z1, z2; // filter section state
    float x = output - 0.47319594*z1 - 0.70744137*z2;
    output = 1.00000000*x + 2.00000000*z1 + 1.00000000*z2;
    z2 = z1;
    z1 = x;
  }
  {
    static float z1, z2; // filter section state
    float x = output - -1.00211112*z1 - 0.74520226*z2;
    output = 1.00000000*x + -2.00000000*z1 + 1.00000000*z2;
    z2 = z1;
    z1 = x;
  }
  return output;
}

Application:

  1. Controlling Robotic arm
  2. Control prosthetic Hand

and many more……

ABOUT Upside Down Labs

Upside Down Labs is India’s first company to introduce affordable DIY Neuroscience Kits. for learners and students so that they can make innovative projects at ease. All of their products are certified and tested with precision.
Deepak Khatri, Founder of Upside Down Labs is a passionate biotechnologist with a mindset for innovation and a love for Electronics and Computer Science. He works with a team of talented engineers to develop community-driven products like Muscle BioAmp Candy, Muscle BioAmp Shield, BioAmp EXG Pill, and many more.

Support them by following them on various social media platforms and purchasing components from their store💖

DISCLAIMER

This Muscle BioAmp candy is sent to us free of cost and I am free to write my opinions w/o any restrictions and no money is exchanged for the review.

Comments (2)

  • Harold Burdette December 2, 2023

    Hello just wanted to give you a quick heads up.
    The words in your content seem to be running off the screen in Firefox.
    I’m not sure if this is a formatting issue or something to do with
    internet browser compatibility but I figured I’d post
    to let you know. The style and design look great though!
    Hope you get the problem resolved soon. Thanks

    • Avatar photo
      Admin December 2, 2023

      Hey Harold,
      Thank you so much for pointing out the error. I will soon fix the issue 🙂

Leave a Reply