Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Servo motors control with emg signal

Status
Not open for further replies.

Revestroke

Newbie level 4
Newbie level 4
Joined
Jan 9, 2013
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,356
Hello friends, greetings. I have designed a robotic arm based on emg signal extracting from biceps. The emg signal I extracted using amplifiers is faithful and reliable. So to interface it with the arduino board I am giving emg signal to analog pin of the board and did common ground (of both emg circuit and arduino board). The robotic arm I have constructed have three servo motors:
1. Base (shoulder)
2. Elbow
3. Wrist

Well, I want to control base servo motor using emg signal and the other two servo motors should actuate with the base motor movement using arduino control, i.e;
1. Base motor activate using emg signal
2. Elbow motor activate using base motor movement
3. Wrist motor activate using base motor movement.

I need help in program code.
Thank you.
 

Revestroke,

Way before you write any code, you need to know what the code is supposed to do, and how it should do it, and why.

What is the relationship between the motion of each joint and the EMG signal, exactly? Without that, there is no code to write.

You have one signal and three motors. How can you generate the three motor signals from only one EMG signal? Well, it's possible, if you consider that one EMG signal could indicate one intended complex motion. Then you can use a separate algorithm to find one of the infinite number of solutions for the motor positions as functions of time, that will result in a transition between the current position (or state) and the correct final state of, say, the hand or wrist (or something like that).

You have two complete processes or algorithms to design and code:
1) A "pattern recognition" algorithm, the output of which is the intended motion of the arm, given the EMG signal as input
2) a kinematics/dynamics "backwards solver", to generate the coordinated motion profiles of the three motors, in order to produce the intended motion of the arm

It should not be as difficult as it might sound. Remember that you will probably have continuous visual feedback, with your eyes. So the algorithm might only need to produce the next INCREMENT of motion, rather than a complete complex motion.

You might find it to be easier to perform the pattern recognition if you use two EMG signals instead of one, for example one from biceps and one from triceps.

I did a little work in that field, when I was a graduate student in EE, way back in 1982. See the abstract at the first link at:

https://www.google.com/#q=gootee+EMG

Basically, you will need to record many sets of EMG waveforms, for specific arm motions, and then use that data to find a way to tell what complex arm motion is intended, if you are given only some portion of a new set of EMG waveforms.

First, you need to do "feature extraction", to find some things you can calculate, from only the EMG waveforms, that will enable your algorithm to determine the overall motion that is intended. You might want to first try breaking it down into the two directions of rotation of each joint, one at a time, and also their speeds (or torques) and extents. Then you can try to find a way to still do that, even though it's not only one at a time.

If I can find my copy of that paper, I will see if there is anything that might be useful for you, in there. But I am sure that there are much better techniques in some more-recent papers, that might be freely available.

Cheers,

Tom Gootee
 
Last edited:

Thank you, Mr. Gootee for your deep explanation.
Here is my code, kindly do rectification if possible.
/*
Three servo motor rotation using emg signal
1. Servo0 is controlled by emg signal
2. Servo1 is controlled with an actuation signal from Servo0
3. Servo2 is controlled with an actuation signal from Servo1
Created: AVSR_2k13.8.29
*/

#include <Servo.h>

Servo servo0; //Object defining three servos control
Servo servo1;
Servo servo2;

int emgpin; // Pin where emg signal is connected to POT
int val = 0; // Any variable value to store POT data

int motorpin_A; // Pin where digital data rotates servo0
int motor_A = 9; // Variable writing the ADC converted PWM s/n

int motorpin_B; // Pin where digital data rotates servo1
int motor_B = 10; // Variable writing the ADC converted PWM s/n

int motorpin_C; // Pin where digital data rotates servo1
int motor_C = 11; // Variable writing the ADC converted PWM s/n


void setup() {
servo0.attach(9); // attaching the servo motors to pin 9, 10, 11
servo1.attach(10); // and to the servo objects: servo0, servo1, servo2
servo2.attach(11);
}

void loop() {
val = analogRead(emgpin); // variable reading POT value
val = map(val, 0, 1023, 0, 179); //scaling the desired value using ADC
servo0.write(val); // servo0 writing data for rotation
delay(15); // Waiting for servo


motor_B = digitalRead(motorpin_A); // Motor_B Reads the value from pin 9 of servo0 rotation
for(motor_B = 0; motor_B < 180; motor_B += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
servo1.write(motor_A); // tell servo1 to go to position in variable 'motor_B'
delay(15);
}
motor_C = digitalRead(motorpin_B); // Motor_B Reads the value from pin 10 of servo1 rotation
for(motor_C = 0; motor_C < 180; motor_C += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
servo2.write(motor_B); // tell servo2 to go to position in variable 'motor_C'
delay(15);
}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top