How to read EMG signal correctly ??

I’m working on project for design emg system to record & measure muscle activity, when I plot the signal on serial plotter the shape of the signal is not good and it seems that some of information lost.

The highest frequency of the system is about 500Hz, so is that mean I have to add a delay of maximum 2ms after analogRead (because 500Hz mean 2ms)? or use external ADC? and also I want to send the data to matlab in real time.
any suggestions…

The attached screenshot is signal plotting without delay.

Thanks in advance.

Your program is already quite slow because of your stone age baud rate. I would expect NO delay to produce better results that ANY delay, so I can't see why you want to add a delay.

Don't post pictures of text. It wastes everyone's time.

9600 bits per second is about 960 characters per second. Assuming the longer lines are four digits plus a newline character the fastest update rate you can get at that baud rate is 192 lines per second. If you want 500 lines per second you will need over 2500 characters per second or over 25000 baud. I think the next higher standard baud rate is 38400. In most cases there is no need to go any slower than 115200 baud.

johnwasser:
9600 bits per second is about 960 characters per second. Assuming the longer lines are four digits plus a newline character the fastest update rate you can get at that baud rate is 192 lines per second. If you want 500 lines per second you will need over 2500 characters per second or over 25000 baud. I think the next higher standard baud rate is 38400. In most cases there is no need to go any slower than 115200 baud.

Thanks john

so the solution is to set higher baud rate like 115200 bps.

Moturki:
so the solution is to set higher baud rate like 115200 bps.

It is certainly a step in the right direction if you are trying to plot a 500 Hz signal. Since I don't know what you mean by "the shape of the signal is not good" I can't tell if the higher baud rate will make the shape good or not.

johnwasser:
It is certainly a step in the right direction if you are trying to plot a 500 Hz signal. Since I don't know what you mean by "the shape of the signal is not good" I can't tell if the higher baud rate will make the shape good or not.

Thanks John

please look at attached screenshot above, is the problem of bad shape of the signal related to ADC of the arduino ??

It looks like whatever you are using to amplify the tiny EMG signal is not doing a good job. What hardware are you using?

johnwasser:
It looks like whatever you are using to amplify the tiny EMG signal is not doing a good job. What hardware are you using?

It did work, the problem was related to the hardware, now I need to plot the signal in real time by interfacing arduino with matlab, do you have any idea??

cheers, Moturki

Moturki:
It did work, the problem was related to the hardware, now I need to plot the signal in real time by interfacing arduino with matlab, do you have any idea??

I would keep the Arduino sketch as it is and have MatLab read the values to plot from the serial port.

johnwasser:
I would keep the Arduino sketch as it is and have MatLab read the values to plot from the serial port.

Thanks John

I’m using matlab 2017b and I installed arduino support package but when I run matlab code, matlab start to upload arduino support code to the arduino and the code that I wrote in arduino IDE is no longer there.

is Arduino support packages have any advantages on the serial communication using Serial command in matlab ??

Moturki:
I installed arduino support package but when I run matlab code, matlab start to upload arduino support code to the arduino and the code that I wrote in arduino IDE is no longer there.

Use the "Arduino support package" if you want MatLab to have direct control over the Arduino pins. Read data over serial if you want your Arduino to pre-process the data.

johnwasser:
Use the "Arduino support package" if you want MatLab to have direct control over the Arduino pins. Read data over serial if you want your Arduino to pre-process the data.

Hello John
please check you massages I sent you a message with details about the project.

Moturki:
Hello John
please check you massages I sent you a message with details about the project.

Sorry, I am not available to work on this project for you.