Hello I am woking on my thesis and I am developing a prosthetic arm, sorry if my english is not correct.
The prosthesis works by emg signals and I am using two channels, I am trying to move 4 servo motors with this 2 channels.
How it should work:
when (ch1>1) and (ch2<1) I move a servo
when (ch1<1) and (ch2>1) I move another servo
I tested this and works good the problem is the last situation when both channels are bigger than 1 volt, I think the processing time is the problem and sometimes it detects a channel above 1 or the other but not both at the same time.
I registered some emg data from users and I am using it on labview to generate voltage to test my circuit, as seen on the image both channels go above 1V on most cases so I don't know what the problem may be.. I tried adding both channels and making a third variable but still it doesn't work
I will add an image of the data and my code, On the code I am using two servo motors and two leds because I only have 2 servomotors
thanks

prueba1motor.ino (2.1 KB)
Please post your sketch in code tags </>.
How do you translate the signals into discrete servo positions?
The servo positions are fixed, for example if ch1>1 and ch2<1 Servo#1 will move 90° using the servo library.
the code:
int ch1;
int ch2;
byte multiplier = 1;
#include <Servo.h>
Servo indice;
//Servo pulgar;
Servo tresd;
//Servo muneca;
int val;
int val2;
int val3;
float v1;
float v2;
float v3;
void setup(){
Serial.begin(9600);
tresd.attach(9);
// muneca.attach(6);
indice.attach(3);
// pulgar.attach(5);
val==0;
val2==0;
val3==0;
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
}
void loop()
{
ch1= analogRead(A0) * multiplier;
ch2 = analogRead(A1)*multiplier;
float v1 = ch1 * (5.0 / 1023.0);
float v2 =ch2 *(5.0/1023.0);
float v3= v1+v3;
Serial.print("Value = ");
Serial.println(v3);
if ((v1 > 1.2)&&(v2 < 1.2)&&(val==0))
{
val = 90;
//muneca.write(val);
digitalWrite(7, HIGH);
delay(1000);
v1=0;
v2=0;
}
if ((v1 > 1.2)&&(v2 < 1.2)&&(val==90))
{
val = 0;
digitalWrite(7, LOW);
//muneca.write(val);
delay(1000);
v1=0;
v2=0;
}
if ((v1 < 1.2)&&(v2 > 1.2)&&(val2==0))
{
val2 = 90;
digitalWrite(8, HIGH);
// pulgar.write(val2);
v1=0;
v2=0;
delay(1000);
v1=0;
v2=0;
}
if ((v1 < 1.2)&&(v2 > 1.2)&&(val2==90))
{
val2 = 0;
digitalWrite(8, LOW);
//pulgar.write(val2);
v1=0;
v2=0;
delay(1000);
v1=0;
v2=0;
}
if ((v3>1.7)&&(val3==0))
{
val3= 90;
indice.write(val3);
tresd.write(val3);
delay(1000);
v3=0;
}
if ((v3>1.7)&&(val3==90))
{
val3= 0;
indice.write(val3);
tresd.write(val3);
delay(1000);
v3=0;
}
}