Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 26, 2024, 04:35:54 16:35


Login with username, password and session length


Pages: [1]
Print
Author Topic: [Q] About Signal Processing  (Read 3378 times)
0 Members and 1 Guest are viewing this topic.
biomed12
Junior Member
**
Offline Offline

Posts: 94

Thank You
-Given: 67
-Receive: 5


« on: September 23, 2016, 01:54:54 13:54 »

Hello dear members,

I have a concept trouble in my brain nowadays. I am a last class an EEE student in a college. I have finished almost all of my classes and I need to start a project to graduate. I selected band pass digital filter design for an electrocardiogram device. Because, I like signal processing topics and I want to be an expert in this field.

BUT, I could not understand the concept of implementation of digital signal algorithms. I will use a dsPIC, because a real dsp is a expensive hardware as you know. dsPIC is about 10-15 dolars, DSP is about 80-90 dolars...

I finished these classes about signals and signal processing,

      -Signals and Systems
      -Digital Signal Processing
      -Biomedical Signal Processing(focused on matlab)

As I said, I finished these classes but, we did not implement a real time application in no of these classes. Also there was not any topic about it. We always studied on recorded signals, algorithms and equations. 

I will use XC16 language or CCS C language to implemetation. My question is that(maybe so simple, sorry):

      will I embed these equations directly in dsPIC?

for example: a filter equation is supposed like-> y[n]=x[n]-x[n-1]
   
      if I write codes which define this equation, does x[n] comes from adc?

briefly, does these codes works for that equation?
     
Code:

     void filter(int *xn,*xn_1,*yn);
    {
      unsigned int yn;
      *yn=*xn-*xn_1;
    }

main()
   { //...
     //.....

     unsigned int *xn,*xn_1,*yn;
     while(1)
     {
     *xn_1=read_adc();
     *xn=read_adc();
     delay_ms(1);
     filter(&xn,&xn_1,&yn);
     //send yn to some terminal such as serial,usb or internet..
      }
    }




Maybe, there were some syntax or logic errors. I writed these codes immediately just for asking and to be an example.

Thanks.


 
Logged
Signal
Active Member
***
Offline Offline

Posts: 197

Thank You
-Given: 111
-Receive: 81



« Reply #1 on: September 23, 2016, 04:47:40 16:47 »

Do not use delay_ms() to set sampling rate.  You need to use more strict jitter-free hardware source for sampling.

Even if you use delay for draft your code is incorrect
Code:
/*filter context*/
static int previous_sample;

void Filter_Init(void){
  previous_sample = 0;
}

int Filter(int sample){
  int y;
  y = sample - previous_sample;
  previous_sample = sample;
  return y;
}

void main(void){
  int result;
  Filter_Init();
  for(;;){ /*eternal loop. One iteration consists of one ADC reading, processing it and one delay */
    result = Filter(read_adc());     /*each sample is passed through filter*/
    /*TODO: send/store result somewere*/
    delay_ms(1); /*the same delay between samples*/
  }
}



Posted on: September 23, 2016, 06:38:00 18:38 - Automerged

dsPIC is about 10-15 dolars, DSP is about 80-90 dolars...
Have you calculated computational load of expected processing? In numbers of operations (at least multiplications) per second for beginning.
Logged

Give a right name to a right game and play it right
biomed12
Junior Member
**
Offline Offline

Posts: 94

Thank You
-Given: 67
-Receive: 5


« Reply #2 on: September 23, 2016, 05:56:08 17:56 »

(*up to 80-90 dolars)

Obviously, I have never experienced how dsp using so, I can say something wrong with dsp.   Roll Eyes

As a result of your correcting(thanks), I realized that I thougt the correct thing.

Consequently, Do I implement filtering by that way on every platform?

 For example,

signal source-->ad convertor--(via spi or serial modul)-->RASPBERRY PI 3-->Filtering process(in a C program)-->>..send it other terminal to use, like lcd panel, ethernet or usb port or database

OR

signal source-->ad convertor--(via serial or usb port)-->MATLAB-->Filtering process(in a matlab script)-->>..send it other terminal to use, like ethernet or database..


Does these scenes work for me?



Logged
Signal
Active Member
***
Offline Offline

Posts: 197

Thank You
-Given: 111
-Receive: 81



« Reply #3 on: September 23, 2016, 07:22:26 19:22 »

OR
signal source-->ad convertor--(via serial or usb port)-->MATLAB-->Filtering process(in a matlab script)-->>..send it other terminal to use, like ethernet or database..
OR
Signal source -> Transducer (Sensor) -> analog conditioner (LPF, level, ...) -> Sound Card Line In (or MIC) -> PC software application (console) -> ...

Quote
Does these scenes work for me?
They work, but do they work for you - nobody knows ;)
You have to start from list of requirements. If you have some and still have variants of implementation then it means that there are not enough requirements - add some more until there could be only one implementation that complies with them. Nice way even if you add arbitrary conditions to your taste or sense of beauty.
Logged

Give a right name to a right game and play it right
Sideshow Bob
Cracking Team
Hero Member
****
Offline Offline

Posts: 985

Thank You
-Given: 230
-Receive: 961



« Reply #4 on: September 23, 2016, 08:52:10 20:52 »

What EXACTLY are you trying to do. Please tell us instead of dripping information now and then. ONLY then will be able to help jeese!
Logged

I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum
biomed12
Junior Member
**
Offline Offline

Posts: 94

Thank You
-Given: 67
-Receive: 5


« Reply #5 on: September 23, 2016, 09:05:20 21:05 »

If you want to give me some more advices(focused on implementation, not focused on hardware details like "sound card line:)") especially about implementation of algorithms at digital side, I will be very pleasure to you. Also some books or documents...

Thanks your invaluable comments.

Posted on: September 23, 2016, 09:54:16 21:54 - Automerged

What EXACTLY are you trying to do. Please tell us instead of dripping information now and then. ONLY then will be able to help jeese!

OK, an instrumentation circuit aquireing ecg signals. There is just analog notch filter and instrumentation amplifier to give it more amplitude, as you know... At the output of this circuit, heart signals are noisy. Before I used a traditional analog band pass filter for filtering it, but now in this scene, I want to remove that structures from my circuit and using a digital low pass filter instead of it. BUT, I asked for that I did not know the concept of the filter implementation. I know MCU coding, I am developing some digital algorithms but how can I embed these matematical equation in the dsPIC... AND other platforms such as raspberry pi or matlab software...

Thanks.
Logged
Sideshow Bob
Cracking Team
Hero Member
****
Offline Offline

Posts: 985

Thank You
-Given: 230
-Receive: 961



« Reply #6 on: September 23, 2016, 09:17:41 21:17 »

Thanks your invaluable comments.

Posted on: September 23, 2016, 09:54:16 21:54 -
That was quite rude and uncalled for, manners please. Remember that non of us are sitting beside you at your workbench with the full view of the project like you do. However no offence taken from my side at this point. But people are trying to help here just saying, do not push your luck
Logged

I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum
biomed12
Junior Member
**
Offline Offline

Posts: 94

Thank You
-Given: 67
-Receive: 5


« Reply #7 on: September 23, 2016, 09:27:11 21:27 »

That was quite rude and uncalled for, manners please. Remember that non of us are sitting beside you at your workbench with the full view of the project like you do. However no offence taken from my side at this point. But people are trying to help here just saying, do not push your luck
*Thanks for your priceless comments

Dear Sideshow, I think you understand my answer wrong. I did not want to imply a rude thing. Howewer, If Member Signal wants, I apologize.

Thanks...
Logged
Signal
Active Member
***
Offline Offline

Posts: 197

Thank You
-Given: 111
-Receive: 81



« Reply #8 on: September 23, 2016, 10:31:24 22:31 »

Hey, it was a collision of posts and lost in translation! Wink

biomed12, I did not understand at the moment that it was exactly me who you ask about additional points. Nick of addressee helps.



Posted on: September 24, 2016, 12:04:06 00:04 - Automerged

If you want to give me some more advices<...> I will be very pleasure to you.
If you want to take some more advice why not to follow previous ones? I know almost nothing about ECG signal, and parameters of required notch filter or what other processing it requires. Why do I have to search this information to help you? So give us a pleasure - tell us more about your beloved project. We all here for such talks.

More exactly -  what filtering and other processing you assume? Required parameters of notch filters? FIR or IIR? Order? Sampling rate? How many channels? Have you calculated expected MAC per second already? Why do you need online processing instead of processing captured data? Implementation as portable compiled C or Matlab script or tight coded to little controller with restricted resources? And more and more that I can not expect that your project depends on. More specifics - more precise aid. In common - you already got your classes.
« Last Edit: September 23, 2016, 10:38:11 22:38 by Signal » Logged

Give a right name to a right game and play it right
Parmin
Hero Member
*****
Offline Offline

Posts: 582

Thank You
-Given: 494
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #9 on: September 23, 2016, 11:20:39 23:20 »

LOL, swords down Sideshow Bob.

invaluable
[in-val-yoo-uh-buh l]
Spell  Syllables
adjective
1.
beyond calculable or appraisable value; of inestimable worth; priceless:
Examples of use
an invaluable art collection; her invaluable assistance.
Logged

If I have said something that offends you, please let me know, so I can say it again later.
Signal
Active Member
***
Offline Offline

Posts: 197

Thank You
-Given: 111
-Receive: 81



« Reply #10 on: September 24, 2016, 01:02:01 01:02 »

BUT, I asked for that I did not know the concept of the filter implementation. I know MCU coding, I am developing some digital algorithms but how can I embed these matematical equation <...>
It is strange to hear such a question from a student that finished several classes about signals and digital signals particularly. That is why I am still confused if I understand your problem correctly. I think that we should talk not about implementation but about theory first. Correct me if I am wrong.

I think we are talking about filters as a linear processing forgetting more complicate cases.

Linear filter is a combination of "linear" operations upon input data and upon results of previous linear operations upon results of previous linear operations ... and so on. Linear operations are - sum, delay and multiplication by constant. Or in other words - a linear combination as a sum with different constant weights of signal and delayed copies of it. In common case - a sum of indefinite number of such copies. You should understand how finite filter can have infinite impulse response, do you? If you are confused that was not my intention.

Digital linear filter - linear filter upon digital signals. Most usual case of digital signal is a quantized values given for regular discrete moments. You should think about word "regular" and how it represents itself in equation y[n]=x[n] - x[n-1]. Yet again - be familiar with connection of meanings "regular" and "iteration".
Then between iterations there is a magic hidden data manipulation that perhaps is the biggest concern for you as I see it.

All these rectangular blocks with T or Z^(-1) inside are delay lines with delay T. Our signal is digital with discretization interval T. So delay line with length "T" has only one value to remember. All other values of continuous analog could be considered as zero so could be not simulated computationally. Remaining part for digital simulation - is to pass values from input to output of delay lines at the end of each iteration (in between). So delay line is a memory of one value. In your simple filter example there is only one memory cell. After completing calculation of linear combination between signal and delayed copy of it you should update this memory by data that is one tact newer - then I wrote: previous_sample = sample; That is a computational procedure required by digital delay line T.

In terms of processors you need to copy value from one memory cell to another. Then think about another magic. Some digital filters allow not to perform this copy operations at all that is quite useful if filter needs thousand of memory cells. You probably know that trick or can understand it yourself being a programmer.


Posted on: September 24, 2016, 02:07:40 02:07 - Automerged

<...> Do I implement filtering by that way on every platform?
What do you call by "that way". Please, explain your doubts.

On every platform digital filter is an updated memory and calculation upon it. Different platforms has different available data types (int of float, 16 bit or 32 bit...). Some "platforms" have special functions that could significantly improve performance if used by algorithm designer or coder. Such functions are: operations on vector data (SIMD, MMX, SSE...), built in saturation mode of arithmetic operations, bit-reversal index addressing, ring buffers, ...

You can make your "processing" as somehow universal portable C-code, or use specific functions that are available as library or use intrinsic functions of given processor. But life of your digital filter remains the same in its space - linear operations upon enumerable number of memory cells.
Logged

Give a right name to a right game and play it right
Sideshow Bob
Cracking Team
Hero Member
****
Offline Offline

Posts: 985

Thank You
-Given: 230
-Receive: 961



« Reply #11 on: September 24, 2016, 10:32:07 10:32 »

Also rember that a filter is no magic wand. If your ECG setup is not working properly, no filter in the world will be able to correct that. You will have many sources of error. One of them are electrodes. They should be proper medical grade. Many ECG electrodes do not take storing well. They tend to dry out very quickly. So why not show some pictures of an ECG recording.
Logged

I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum
biomed12
Junior Member
**
Offline Offline

Posts: 94

Thank You
-Given: 67
-Receive: 5


« Reply #12 on: September 25, 2016, 04:51:26 16:51 »

Also rember that a filter is no magic wand. If your ECG setup is not working properly, no filter in the world will be able to correct that. You will have many sources of error. One of them are electrodes. They should be proper medical grade. Many ECG electrodes do not take storing well. They tend to dry out very quickly. So why not show some pictures of an ECG recording.

You are inspired me to make an analog device which works properly to make a comparison or understand whether the digital system works properly. As you said, I should be sure that correct signals are coming to dsPIC.

Thanks.

Posted on: September 25, 2016, 05:19:14 17:19 - Automerged

Signal,

You consistenly tell me the theory of SP. I said you, I passed these classes which are about SP. I told you we found some equations in these lectures but, what is the corresponding thing in digital system(like dsp or clasical MCU)... Also I gave an example in C program.
Also I asked "x[n] comes from adc???" etc. etc.

Anyway, thanks for your valuable comments.
Logged
Sideshow Bob
Cracking Team
Hero Member
****
Offline Offline

Posts: 985

Thank You
-Given: 230
-Receive: 961



« Reply #13 on: September 25, 2016, 06:49:33 18:49 »

http://www.mediafire.com/download/qq8yjnbjb3rq7mm/ecg_amp.pdf
I uploaded this to my share account, it is a free give away from Analog Devices. You can use the principals for making an ECG amplifier. You do not need to use the exact components. It will do with components that are similar. By the way have you ever used Labview. They have a quite good ECG simulator
http://www.mediafire.com/download/qq8yjnbjb3rq7mm/ecg_amp.pdf
Logged

I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC