EMG Analog Signal reads 1023

Hi,

As I've said in the title, I'm trying to rig my Arduino Mega to read EMG signals, to use as control signals for other fun things.

However, after setting up my breadboard, no matter how much I've connected and reconnected, or generally futzed around with it, all I've managed is for the plotter to return the signal maxed at 1023.

The code I'm using is, quite literally, only to read the signal, but I'll add it in just on the off chance that I'm an idiot and got something wrong there:

//Pin number where the sensor is connected. (Analog 14)
#define EMG_PIN 14

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 57600 bits per second, due to speed of other sensor:
  Serial.begin(57600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 14:
  int sensorValue = analogRead(EMG_PIN);
  // print out the value you read:
  Serial.println(sensorValue);
}

Setup is as follows:

  • The sensor operates between ±9V (Acquired from the two 9V batteries)

  • The midway-point is taken as 0V and grounded (to the Power Supply-Gnd as well as Arduino-GND)

  • Signal is connected to A14

  • Signal Gnd is connected to Arduino GND

Any insight you can provide me with is greatly appreciated, thanks!

Pin 14 on the Mega is not an analog pin.

A14 is not the same as 14

MarkT:
Pin 14 on the Mega is not an analog pin.

A14 is not the same as 14

I thought I saw on the pinout that the IDE interpreted 14 as a valid name for A14, and the signal changes when I plug and unplug the pin, however?

Regardless, what do you suggest? If I'm reading this right, I should

#define EMG_PIN 83

Is that correct?

Why not use A14? It's the obvious thing to do. The hack in analogRead() for remapping small numbers up
to the analog pin numbers is confusing - pin numbers should be unique. I wouldn't be surprized if the hack doesn't work for all the analog pins on every board for instance.

#define EMG_PIN A14

You can then use the define in any of the pin calls interchangably.

If that's not the problem, have you tried measuring the voltage on that pin with a meter?

I'm assuming EMG you mean electromyogram.

First off you must NEVER attach anything that is in any way connected (or CAN be connected) to the mains system to a person. EG a laptop running from its battery COULD easily be plugged in by accident.

(I used to service electronic equipment used in hospitals and the precautions they take - including specially wound transformers with a protection winding - were extreme.)

WHY? because the mains earth can fail, and expose the patient (AKA corpse) to mains voltages and your electrodes bypass your protective skin resistance.

The patient should be grounded to a SAFE earth point via a large value (100k) resistance.

If your arduino is connected to a computer by a usb lead that IS a mains connection.

Thats not an issue; you can use a battery powered arduino and use a usb isolator, wifi, bluetooth, whatever to communicate.

Secondly you will need to amplify the signals and provide a reference - so you need three sensor pads.
good info here

you will need an instrumentation amplifier to give suitable gain and common mode rejection. Then a simple rectifier & filter will give you a signal the arduno can measure.

Sorry for my late response, I've been somewhat busy.

Why not use A14? It's the obvious thing to do.
[...]

#define EMG_PIN A14

You can then use the define in any of the pin calls interchangably.

If that's not the problem, have you tried measuring the voltage on that pin with a meter?

I've tried both what you mentioned, and defining the pin as 83, both return the same issue.
I don't currently have access to a multimeter, sadly, but I've managed to ensure that the pin I'm using is in fact the one that I've tasked my Arduino to read.

The problem, therefore and as far as I can tell, should be that the signal is too high voltage for my Arduino to read as anything other than max value (1023 for the 10bit resolution of the Analog ports).

I'm confused, however, as I've seen this setup in a youtube video, and I've copied it exactly, minus the fact that my Arduino isn't UNO, but MEGA (which afaik, shouldn't be an issue due to the exact same voltage specifications of their analog pins)

I'm assuming EMG you mean electromyogram.

Yes, I mean electromygram. Specifically, I'm using surface electromyography.

Secondly you will need to amplify the signals and provide a reference - so you need three sensor pads.
good info here
Sensors | Free Full-Text | Validation of a Low-Cost Electromyography (EMG) System via a Commercial and Accurate EMG Device: Pilot Study

you will need an instrumentation amplifier to give suitable gain and common mode rejection. Then a simple rectifier & filter will give you a signal the arduno can measure.

As I understand it, my interface board goes through the trouble of amplifying the signal already, and I need to acquire a readable signal before filtering it.

I'll check out the document you forwarded me though, and thank you for it!

I managed to figure out what the main problem was: The gain was maxed out on the interface board, and I hadn't noticed I could futz with it.

That out of the way, I find that the signal I read is now sensical, in the sense that it's no longer maxed out, but I can't perceive any difference at all between flexing and not flexing the muscle the sensors are attached to.

All I can think of at this point is that I might be connecting the electrodes in the wrong order, but that's no longer an Arduino problem. Thanks for all your help, everyone!

And as an added adieu, if you know for a fact where the red, green and yellow electrodes are supposed to go in an EMG, I'd be doubly thankful if you could point me in the right direction!

You have two electrodes across the muscle group, and a "reference " ground which sensibly would be green. More info here

You have two electrodes across the muscle group, and a "reference " ground which sensibly would be green. More info here

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

I know this, I just can't find any indication of which is which, and apparently the colors aren't standardized either. All three clip-on heads have the letter R, which is really not helpful either.

There's one Red, which I assume it the positive sensor, one Green, which I assume is the pair, and one Yellow, which I assumed to be the reference, but connecting them in that order (or any other, for that matter) doesn't return a readable signal

Green is a pretty universal standard for ground or reference. However, simply, ONE electrode will have a low impedance apth to ground.
The other two are interchangeable.

I don't currently have access to a multimeter,

if youre playing with electronics a multimeter is a must. Sure you can afford 10$.

As I understand it, my interface board goes through the trouble of amplifying the signal already,

That was your first mention of an interface board. Did it not come with instructions?

Sounds as if it could be broked. The EMG signal is between 1-10mV and 50-150Hz. You can easily generate a test signal with the arduino. Just drop the output signal size with a resistive divider - say 20:1 and apply to one electrode, with the other 2 shorted.

const int t = 1;

void setup()
{
  pinMode(13, OUTPUT);
}

void loop()
{
  digitalWrite(13, HIGH);
  delay(t); // t changes m/s ratio of 100Hz wave
  digitalWrite(13, LOW);
  delay(10-t);
}

good info here