Muscle Sensors V3 returning noise

Hey people,

I have been attempting to get a muscle sensor kit from sparkfun working(https://www.sparkfun.com/products/13027). However after hooking everything and running the code provided on the website it seems to return random noise in the serial monitor - the values varying from 200 to 500, whether the muscles sensor are connected or not. What I’m trying to figure out is if there is a problem with my circuit boards, connections or code…

Here is the code I’m using and a photo:

// reads analog input from the five inputs from your arduino board 
// and sends it out via serial

// variables for input pins and
int analogInput[6];
  
// variable to store the value 
int value[6]; 
 
void setup()
{
  // declaration of pin modes
  for(int i=0;i<6;i++)
  {
    analogInput[i] = i+1;
    value[i] = 0;     
    pinMode(analogInput[i], INPUT);    
  }
  
  // begin sending over serial port
  Serial.begin(9600);
}

void loop()
{
  // read the value on analog input
  for(int i=0;i<6;i++)
  {
    value[i] = analogRead(analogInput[i]);
  }

  // print out value over the serial port
  for(int i=0;i<6;i++)
  {
    Serial.println(10000 + i + 1); //prefix
    Serial.println(value[i]);
    Serial.println(10010); //end signal
  }
  // wait for a bit to not overload the port
  delay(10);
}

analogRead() affect each other,
better read all pins twice and use the last read

  for(int i=0;i<6;i++)
  {
    analogRead(analogInput[i]);
    value[i] = analogRead(analogInput[i]);
  }

The code works fine. It probably has to do with the way you've setup the sensor. Can you post some pics? It's easier to spot issues that way.

Cheers, Brian

Thanks Rob, I will try that.

Hey Brian, there is a link to an image below the code called MS_VS-2.

Cheers,

Adam.

robtillaart: better read all pins twice and use the last read

I've seen that suggested before Rob: what does it actually do that reduces the problem? (Why would a second read be any more trustworthy than the first?)

Didn't know Arduino pins 1 - 6 were analog inputs ??

How do you read anything from analog inputs 1 - 5 when there are no wires connected to them ??

klubfingers:
How do you read anything from analog inputs 1 - 5 when there are no wires connected to them ??

I wondered that too… assumed the pic was from an intermediate stage in OP’s development.

It is indeed un-logical now that I think about it... The code is just copied from the manufactures website http://www.advancertechnologies.com/p/muscle-sensor-v3.html while the setup is based of the user manual - I naively assumed that the provided example code would work with the setup in the manual. I guess that answers my question - I need to change the code or the setup. Unfortunately I am new to arduino, and have no idea how to write the code required.

So my next question is:

Does anybody have any idea about how to write a basic code that would allow me to see the sensors output in the serial monitor? (This is probably a really basic thing to do, but I am very amateurish at this so any help would be much appreciated)

Cheers,

Adam

Maybe there’s a library missing, why not contact Sparkfun support and ask ?

Yeah I'm gonna hit them up, their code really doesn't seem to match the setup they provide

JimboZA:
I’ve seen that suggested before Rob: what does it actually do that reduces the problem? (Why would a second read be any more trustworthy than the first?)

There is only one ADC in the AVR chip which is multiplexed.
By using 2 reads the ADC has more time to adjust/stabilize to the other value.

mooreadam: Thanks Rob, I will try that.

Hey Brian, there is a link to an image below the code called MS_VS-2.

Cheers,

Adam.

Didn't notice the attachment! Everything looks fine in the pics but you dont show the power supply nor the electrode placement (Usually the culprits). What voltages are you reading at pins +Vs and -Vs w.r.t. ground?

if you just want to see the value on the serial monitor, use the arduino analog input example http://www.arduino.cc/en/Tutorial/AnalogReadSerial

Sorry here is a more inclusive shot(I am using two 9v batteries):

Thanks for that link, I’ll give it a try now.

mooreadam: Sorry here is a more inclusive shot(I am using two 9v batteries):

|500x322

Thanks for that link, I'll give it a try now.

Still a little hard to see which battery wire is going where.

It looks like...

  • the left battery's black wire is connected to the GND pin, and its red wire to +Vs.
  • the right battery's black wire is connected to the -Vs pin, and its red wire to GND.

which would be correct.

Did you solder the wires to the board or are they just stuck in the board's pin holes?

BTW you only have to connect either the board's ground to the arduino's ground or the battery's ground to the arduino's ground. It looks like you have both. While this is technically OK, it's not necessary.

Could be that the gain adjustment is out of range or set too high (there's no limit resistor on the gain circuit) shown in their schematic:

Hey Brain, using the analog read serial code has been working better, although it still returns noise. I soldered female headers to the board - I didn't want to commit to soldering the wires but figured it would be a bad idea to leave them hanging loose. Thanks, I didn't realize it only needed one or the other.

Hi, dllyod what would you recommend doing if the gain adjustment is out of range? (Sorry bit of a noob so I don't really know what that means)

Cheers,

Adam.

mooreadam: Hey Brain, using the analog read serial code has been working better, although it still returns noise. I soldered female headers to the board - I didn't want to commit to soldering the wires but figured it would be a bad idea to leave them hanging loose. Thanks, I didn't realize it only needed one or the other.

Hi, dllyod what would you recommend doing if the gain adjustment is out of range? (Sorry bit of a noob so I don't really know what that means)

Cheers,

Adam.

I wouldnt recommend messing with the gain. The default setting should be fine.

Can you paste the output youre seeing? Also, did you see me ask about the voltages at +Vs and -Vs pins?

User's Manual

Looks like the gain control uses a 100K pot ... if set to max (100K), the gain would be 20,700. If set to max, I would guess that the circuit would be highly susceptible to noise.

Here, this simplified sketch can be used to calibrate the sensor board. It just continuously reads analog input A0 and prints the reading. Arduino's LED turns on when 1023 is reached.

When testing with a sensor pad, if you find that its too easy to get maximum reading of 1023, then you could turn back the pot until it takes the desired maximum effort to get the maximum reading of 1023.

int value;

void setup()
{
  pinMode(13, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  value = analogRead(A0);
  Serial.println(value);
  if (value == 1023) {
    digitalWrite(13, HIGH);
  }
  delay(100);
  digitalWrite(13, LOW);
}

EDIT:

Have you checked the charge (voltage) on both batteries? They should preferably have similar voltage levels.

dlloyd: User's Manual

Looks like the gain control uses a 100K pot ... if set to max (100K), the gain would be 20,700. If set to max, I would guess that the circuit would be highly susceptible to noise.

Here, this simplified sketch can be used to calibrate the sensor board. It just continuously reads analog input A0 and prints the reading.

When testing with a sensor pad, if you find that its too easy to get maximum reading of 1023, then you could turn back the pot until it takes the desired maximum effort to get the maximum reading of 1023.

int value;

void setup() {   Serial.begin(9600); }

void loop() {   value = analogRead(A0);   Serial.println(value);   delay(100); }



EDIT:

Have you checked the charge (voltage) on both batteries?
They should preferably have similar voltage levels.

The default setting for the gain is 50kOhms

Hey Brian,

I've had some weird developments, now I run the code I get an output like so:

|500x442

But when put on the muscle sensors every turns to 0.

Sorry, this is probably a dumb question but do you want me to test the vs pins with a multimeter or through arduino? I ran this sketch to test the voltage but not sure if thats what you meant...

|500x368

Cheers,

Adam.