Go Down

Topic: Newb Servo issues (Read 1 time) previous topic - next topic

Hey guys I'm new here.  Little bit of background info.  I am a 19 year old Drexel University freshman in Philadelphia, PA. I am currently doing my final project for the year.  My group has decided to interface EMG tech with an Arduino to make a hand prosthesis. 

The original idea was to make the middle finger to the pinky as one unit, index finger and thumb move independently of each other. To make things simpler for the time being we decided to move the four finger as a unit and forget about the thumb.  We are going to use electrodes attached to our hand/forearm to send a signal through the Olimex EKG-EMG shield (https://www.olimex.com/Products/Duino/Shields/SHIELD-EKG-EMG/) and then send a signal to a servo to spin and open the hand.

Our issue at this point in the project is getting an unhacked servo to spin more than 90* with a shield attached.  Without a shield, I can get the servo to spin 180*.   I have tried two different shields and two different servos and still can not get the servo(s) to spin more than 90*.

Attached is a copy of the code I am using to trouble shoot the servo.

oric_dan

Why don't you try writing a sketch to command the servo directly, and once that works
correctly, add in the bit about the analogRead().

That's how you do this stuff. Write the different parts in "isolation", test them, fix them,
and then combine them. It's 10X easier to troubleshoot that way.

zoomkat

Servo/pot test code that might be of use as it prints values to the serial monitor for troubleshooting.

Code: [Select]

//zoomkat dual pot/servo test 12-29-12
//view output using the serial monitor

#include <Servo.h>
Servo myservo1;
Servo myservo2;

int potpin1 = 0;  //analog input pin A0
int potpin2 = 1;

int newval1, oldval1;
int newval2, oldval2;

void setup()
{
  Serial.begin(9600); 
  myservo1.attach(2); 
  myservo2.attach(3);
  Serial.println("testing dual pot servo"); 
}

void loop()
{
  newval1 = analogRead(potpin1);           
  newval1 = map(newval1, 0, 1023, 0, 179);
  if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){ 
    myservo1.write(newval1);
    Serial.print("1- ");
    Serial.println(newval1);
    oldval1=newval1;
  }

  newval2 = analogRead(potpin2);
  newval2 = map(newval2, 0, 1023, 0, 179);
  if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){ 
    myservo2.write(newval2);
    Serial.print("2- ");   
    Serial.println(newval2);
    oldval2=newval2;
  }
  delay(50); // adjust as needed for viewing output
}

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Chagrin

A "sail winch" servo will give 360 degree or more rotation, unhacked.

MostafaHamdy

hi , i have the same shield and have EMG sensor
https://www.olimex.com/Products/Duino/Shields/SHIELD-EKG-EMG/
https://www.olimex.com/Products/Duino/Shields/SHIELD-EKG-EMG-PA/
but i can't get signal to move servo motors any one have code or any way to get analog signal from this shield i try to make code but i failed
is this shield used only to make heart rate analysis in elecguru program ?     

Go Up