State Change Detection with EMG signal

Hello everyone,

I have built an EMG controlled prosthetic hand and I want to use a code that can toggle between different functions using the same input (EMG threshold value). Specifically, I want the hand to perform different movements depending on the times I contract my muscle, for example, I contract twice and the servo motors move to make the hand form a fist, I contract once and the hand opens. I contract thrice the hand raises the index finger, I contract once the hand once again goes to its neutral position (open) and so on...Would the State Change Detection be appropriate for that purpose?

EMG = electromyographic (I had to look it up)

I guess you want to count the number of contractions where the EMG value is within tolerance of your threshold value. The counting has to wait for a time out because if it detects one contraction, it cannot respond until it is clear that there is not going to be second contraction with the same EMG value.

If the actions are determined by a simple combination of EMG values and numbers of contractions, start with an if/then/else statement.

Eventually, I did it with State Change Detection using a counter...But it follows the counting loop that way, e.g. 1 contraction for opening, 2 for closing, 3 for pointing e.t.c What if I want to switch from one movement to another without following the sequence?

To abort an existing action and start a new one, You'd probably have to develop an protocol like say:
Long contraction (> x seconds) means abort existing action. This would reset everything so the user could once again select a new action.

Aceed3NT:
Eventually, I did it with State Change Detection using a counter...But it follows the counting loop that way, e.g. 1 contraction for opening, 2 for closing, 3 for pointing e.t.c What if I want to switch from one movement to another without following the sequence?

Are you saying that at the moment it always goes open / close / point but you may want to go straight to point? Then you would probably need to time the intervals and do nothing on the first contraction until either a timeout has elapsed so that it knows there's no 2nd one coming, or it does see the 2nd one. Then ignore that one until it timesout again or the 3rd one arrives.