Myoware sensor and erratic servo

Hi all,

I’m new to the forum and to arduino so go easy on me lol

I’ll make this as clear as possible, so scope of my project is to move a servo motor using an EMG sensor. So that it rotates to 170 degrees when hand is closed and back to 0 when hand is open.

Here’s what I’m working with, arduino uno, mg90s servo, v3 emg sensor, x2 9v batteries.

I followed this tutorial exactly,

Now the problem is that the values in serial monitor don’t seem to change much, if at all when flexing a muscle operating the sensor. Instead the servo moves back and forward in an erratic twitching fashion.

I’m sure the wiring is OK as the tutorial has a lot of praise in the comment section and nobody seemed to have my issue, typical lol the only difference is the tutorial uses a Nano and I’m using an uno, but does that make any difference?

I know the board and servo are OK as I loaded up the servo sweep from the IDE and it works fine. So I’m thinking maybe it’s the EMG sensor itself unless you guys can spot something i might of missed? I’ve included the code, only thing I tried with the code was I put 3 where it says (servo_pin) and I put 0 where it says (Emg_pin) I did change the threshold as a last attempt to get it working but it didn’t work.

Things I’ve tried,

  • New usb cable,
  • Gave the servo it’s own power supply after trying the 5v supply on the uno same result. Yes I grounded the supply to the uno.
  • Got medical grade electrodes as I thought the ones included may have been the issue.

I hope you guys can help here’s the code, thanks for taking the time to read

#include <Servo.h>

//Threshold for servo motor control with muscle sensor.
//You can set a threshold according to the maximum and minimum values of the muscle sensor.
#define THRESHOLD 250

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

//Pin number where the servo motor is connected. (Digital PWM 3)
#define SERVO_PIN 3

//Define Servo motor
Servo SERVO_1;

/-------------------------------- void setup ------------------------------------------------/

void setup(){

//BAUDRATE set to 115200, remember it to set monitor serial properly.
//Used this Baud Rate and “NL&CR” option to visualize the values correctly.
Serial.begin(115200);

//Set servo motor to digital pin 3
SERVO_1.attach(SERVO_PIN);
}

/-------------------------------- void loop ------------------------------------------------/

void loop(){

//The “Value” variable reads the value from the analog pin to which the sensor is connected.
int value = analogRead(EMG_PIN);

//If the sensor value is GREATER than the THRESHOLD, the servo motor will turn to 170 degrees.
if(value > THRESHOLD){
SERVO_1.write(170);
}

//If the sensor is LESS than the THRESHOLD, the servo motor will turn to 10 degrees.
else{
SERVO_1.write(10);
}

//You can use serial monitor to set THRESHOLD properly, comparing the values shown when you open and close your hand.
Serial.println(value);
}

So exactly what values do you see from the EMG sensor? And when you changed THRESHOLD what did you change it to?

Steve

In the right-lower corner is More/Modify. Use Modify to fix that link please.
You can also alter the title. Perhaps you can put “Myoware” in the title.

Do you have the Myoware board ? How is it connected ?

slipstick:
So exactly what values do you see from the EMG sensor? And when you changed THRESHOLD what did you change it to?

Steve

Hi Steve, thanks for the reply, the values were very hard to see a pattern they'd go from 90 to 150 to 200 300 400 700 1023 and repeat but there was no movement from the servo that was consistent. Even after I changed the value, I didn't notice any difference in the behaviour of the servo, very strange. What do you think?

In the right-lower corner is More/Modify. Use Modify to fix that link please.
You can also alter the title. Perhaps you can put "Myoware" in the title.

Do you have the Myoware board ? How is it connected ?

Hi Koepel, thanks for the reply, I've fixed the link and included the exact screen shot of the wiring diagram used on the tutorial. Also a picture of the board I'm using.

  • You can see on the diagram how it's wired then I have the servo as follows positive to 5v, gnd to gnd and signal to digital pin 3.

Update, after reading more on this about rf inference I shielded the sensor with an anti static protector bag and ran the arduino off a separate power supply not connected to my laptop.
The problem is still there however, the serial plotter data is up and down like a yoyo. There is no difference in signal frequency when I make a muscle movement.
The servo still erratically moves back and forward

When unclipped one of the electrodes from my arm and touched it, it made the servo move to 180 degrees and when I took my finger off it it went back to 0 degrees.

When I touched it, it it read 1023 constantly in serial monitor and when I released it it went to 0 constantly.

So the circuit works but am I missing something in the code? I'm not sure I really need to get this project working anyone any ideas?

Oops, I asked to put perhaps "Myoware" in the title, but this is not a "Myoware" board.

Even with the real MyoWare Muscle Sensor board, it is not easy to make it work. Everything has to be done just right.

Do you have a multimeter ? Then you don't need an Arduino or laptop. Just measure the 'SIG' analog output.

Can you send the value of analogRead() to the serial monitor of the Arduino IDE ?
If you disconnect the laptop from the mains, and let it run on its batteries, then you reduce noise.
The probes must also be placed in the right way. They must press against the skin. Some probes work better when they are not dry. The skin should be washed and cleaned with alcohol. The natural grease of a skin is a good isolator for these very small voltages.

Others can make that board work. So there is probably a certain situation that it works. However, it might not work in your situation. The professional devices in a hospital are much better quality and can not be compared to this hobby board.

Koepel:
Oops, I asked to put perhaps "Myoware" in the title, but this is not a "Myoware" board.

Even with the real MyoWare Muscle Sensor board, it is not easy to make it work. Everything has to be done just right.

Do you have a multimeter ? Then you don't need an Arduino or laptop. Just measure the 'SIG' analog output.

Can you send the value of analogRead() to the serial monitor of the Arduino IDE ?
If you disconnect the laptop from the mains, and let it run on its batteries, then you reduce noise.
The probes must also be placed in the right way. They must press against the skin. Some probes work better when they are not dry. The skin should be washed and cleaned with alcohol. The natural grease of a skin is a good isolator for these very small voltages.

Others can make that board work. So there is probably a certain situation that it works. However, it might not work in your situation. The professional devices in a hospital are much better quality and can not be compared to this hobby board.

Thanks again for the reply, I'm using a laptop yhst has a bad battery so I need to have it plugged in, the board was powered without the USB and gave the same results.
I do have a multimeter and I'm getting 0.2ma on the sensor. I'm not sure how to send a value to the Íde on the serial monitor sorry. I'm a novice at this. I did buy a proper myoware board so hopefully it will be here next week and I will be able to tell if its just the board.
As for the electrodes I used medical grade pads that come with a wet insert for better conductivity, I changed the leads also no joy.
I did notice that when I waved my hand over the board without the anti static film on it, it made the servo move, my guess is either there's a voltage leak or this cheap sensor is highly susceptible to RF.
No idea at this point its driving me mad lol

The module outputs a voltage, not a current.

You are supplying +/-9V to the ADC input of an Uno?

Idahowalker:
You are supplying +/-9V to the ADC input of an Uno?

No look at the diagram I posted, it's a 9v sensor it requires 2 9v batteries

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.