Go Down

Topic: how to measure the Differential of EMG signal input (Read 68 times) previous topic - next topic

jbanayo

i am trying to measure EMG signal using MYOWARE and its Differential input to determine whenever the difference is high, the program triggers a certain command. will this code works?

basically i want to have the MCU detect whenever the muscle flexes, and extends

void loop() {

emg = analogRead(emgPin);

delay(100);
emg2= analogRead(emgPin);

change = emg2 - emg;    // differential value

if (change > 200){
  //insert command
}

Paul_KD7HB

If you are afraid to test it, have a friend do it.

Paul

MarkT

It would be good practice to name and define the threshold value at the top of the file, since the
number 200 in the middle of the code is pretty obscure.

Code: [Select]

#define THRESHOLD_VOLTAGE_DIFF 0.97   // or whatever voltage is correct...
#define THRESHOLD (1024 * THRESHOLD_VOLTAGE_DIFF)

....

if (change > THRESHOLD){
 ....
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up