1 of 17

EMG

Sensor

Electromyography : Processing Signals from motor neurons

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

2 of 17

About

Neurotech

12.8 Billion Dollar Industry

Pacemakers

Prosthetics

Brain-chip interfaces

EEG’s EMG’s . . .

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

3 of 17

Goals

Assemble EMG

Print to LCD &

Unity Simulation

Electromyography

Reading the tiniest signals from motor neurons

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

4 of 17

References

EMG: https://www.instructables.com/Muscle-EMG-Sensor-for-a-Microcontroller/

  • Details construction of custom EMG Circuit
  • Ours Added an LCD screen to output the data

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

5 of 17

Components

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

x3 TL072 IC Chip

x1 INA106 IC Chip

x6 EMG Electrodes

x2 9V Battery Clip

x1 1.0 uF Tant Capacitor

x1 0.01 uF Ceramic Disk Capacitor

x1 1.0 uF Ceramic Disk Capacitor

x3 150 kOhm 1% Resistor

x2 1 MOhm 1% Resistor

x2 80.6 kOhm 1% Resistor

x6 10 kOhm 1% Resistor

x1 100 kOhm Trimmer

x1 1 kOhm 1%

x2 1N4148 Diode

Jumper Wires

x3 Alligator Clip Cables

x2 9v Battery

6 of 17

Circuit Design

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

7 of 17

USB Comm

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

#include "mbed.h"��static BufferedSerial serial_port(PA_2, PA_3, 9600);�AnalogIn emg(A1);��int main()�{� serial_port.set_baud(9600);� serial_port.set_format(8,BufferedSerial::None,1);� DigitalOut led(LED1);��while . . .

while (true) � {� float value = emg.read();� char buffer[32];� snprintf(buffer, sizeof(buffer), "%.3f\n",value);� serial_port.write(buffer, strlen(buffer));� thread_sleep_for(50);� }�

8 of 17

C# Unity

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

string[] ports = SerialPort.GetPortNames();� Debug.Log($"Available ports: {string.Join(", ", ports)}");�� serialPort = new SerialPort(portName, baudRate, Parity.None, 8, StopBits.One);� � serialPort.ReadTimeout = 1000;� serialPort.WriteTimeout = 1000;�� serialPort.Open();�� // Start a separate thread for reading serial data� serialThread = new Thread(ReadSerialData);� serialThread.IsBackground = true;� serialThread.Start();

//! Read index 1 because 0 will be previous entryif (float.TryParse(lines[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out float floatValue))�{� Debug.Log($"Converted float value: {floatValue}");� UpdateCurrentValue(floatValue);�}�else�{� Debug.LogWarning($"Failed to convert line to float: [{lines[1]}]");�}��void Update()�{� muscleMat.color = new Color(1f, 0f, 0f, (currentValue - cutoff) / 0.003f);�}

9 of 17

LCD Readout

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

void lcd_command(int cmd) {� lcd_send(cmd, LCD_CMD);� thread_sleep_for(2);��void lcd_data(char data) {� lcd_send(data, LCD_DATA);��void lcd_set_cursor(int col, int row) {� const int row_offsets[] = {0x00, 0x40, 0x14, 0x54};� lcd_command(0x80 | (col + row_offsets[row]));

void lcd_print(const char str) {� while (str) {� lcd_data(*str++);

void lcd_clear() {� lcd_command(0x01);� thread_sleep_for(2);��

while (true) {

//average of 30 readingsfloat emgValue = getAverageEMGValue(30); � float voltage = emgValue;�

if (voltage < 0) voltage = 0;� char buffer[16];� snprintf(buffer, sizeof(buffer), "EMG: %.3f V", voltage);

� lcd_clear();� lcd_set_cursor(0, 0); //set to first line� lcd_print(buffer);� thread_sleep_for(50);�

10 of 17

Problems

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

Problems

How it was handled

Components we purchased were meant to be soldered onto a board not inserted

Found the larger components with similar specifications after researching online

2 Weeks Shipping Time. . .

11 of 17

Problems

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

Problems

How it was handled

Circuit was outputting extremely incoherent values

Contacted Professor Kamali and read through the block diagram instead of the visual demonstration to find a missing wire and that the battery’s polarity was flipped

1 Week of back and forths. . .

12 of 17

The positive side of the battery is colored black and goes to ground. . . But its the positive side

13 of 17

Problems

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

Problems

How it was handled

USB Communication wasn’t working

12 hours of pain (Asking the president of robotics and GPT for help just to find out you were using a bad adapter and if you don't run the program as administrator you just cant use USB Communication ;-;)

1 Week . . .

EVIL USB CABLE

14 of 17

Future Improvements

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

Improvements

Multi-dimensional EMG

Power Supply in place of batteries

Reusable Electrode Pads (We used so many in testing that we bought a bulk pack of 50)

Higher Precision and Update Unity to work with Lower Voltage readouts

15 of 17

Contributions

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

Task

Names

Circuit Design/ Topic Research/ Components Research

Everyone

Nucleo Readout Code

Curtis

Unity C# & USB Communication Code

Alexander

LCD Code

Javier

16 of 17

References

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System

References:�1. Technologies, Advancer, and Instructables. “DIY Muscle Sensor / EMG Circuit for a Microcontroller.” Instructables, Instructables, 1 Nov. 2017, www.instructables.com/Muscle-EMG-Sensor-for-a-Microcontroller/.

This source breaks down how to construct a EMG as well as the required components to do so. We were able to use this source as a jumping off point to find our own components.

2. Cannan, James. “Super Simple Muscle (EMG) Sensor.” Hackaday.Io, hackaday.io/project/8823-super-simple-muscle-emg-sensor. Accessed 2 Nov. 2024.

This source was another educational resource for constructing an EMG however we decided to go with another approach.

3. glowascii. “DIY EEG to Arduino.” YouTube, YouTube, 17 Dec. 2017, www.youtube.com/watch?app=desktop&v=LHBcDVO60Hc.

We wanted to read neurological activity of some kind and this is one of many resources we found that explained the process and purpose of components. We decided to go with an EMG circuit for simplicity after understanding the concepts in this video.

17 of 17

THANK YOU FOR LISTENING

12/4/2024

Alexander, Javier, Curtis

CS435 - Introduction to Embedded System