Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 07, 2016, 11:18:19 23:18


Login with username, password and session length


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

Posts: 52

Thank You
-Given: 37
-Receive: 3


« on: September 23, 2016, 02:54:54 14: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: 102

Thank You
-Given: 47
-Receive: 33


« Reply #1 on: September 23, 2016, 05:47:40 17: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: 52

Thank You
-Given: 37
-Receive: 3


« Reply #2 on: September 23, 2016, 06:56:08 18: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: 102

Thank You
-Given: 47
-Receive: 33


« Reply #3 on: September 23, 2016, 08:22:26 20: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
Senior Member
****
Offline Offline

Posts: 457

Thank You
-Given: 160
-Receive: 495



« Reply #4 on: September 23, 2016, 09:52:10 21: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 really am ruggedly handsome, aren't I?
biomed12
Junior Member
**
Offline Offline

Posts: 52

Thank You
-Given: 37
-Receive: 3


« Reply #5 on: September 23, 2016, 10:05:20 22: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
Senior Member
****
Offline Offline

Posts: 457

Thank You
-Given: 160
-Receive: 495



« Reply #6 on: September 23, 2016, 10:17:41 22: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 really am ruggedly handsome, aren't I?
biomed12
Junior Member
**
Offline Offline

Posts: 52

Thank You
-Given: 37
-Receive: 3


« Reply #7 on: September 23, 2016, 10:27:11 22: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: 102

Thank You
-Given: 47
-Receive: 33


« Reply #8 on: September 23, 2016, 11:31:24 23: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, 11:38:11 23:38 by Signal » Logged

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

Posts: 544

Thank You
-Given: 357
-Receive: 126


Very Wise (and grouchy) Old Man


« Reply #9 on: September 24, 2016, 12:20:39 00: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: 102

Thank You
-Given: 47
-Receive: 33


« Reply #10 on: September 24, 2016, 02:02:01 02: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
Senior Member
****
Offline Offline

Posts: 457

Thank You
-Given: 160
-Receive: 495



« Reply #11 on: September 24, 2016, 11:32:07 11: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 really am ruggedly handsome, aren't I?
biomed12
Junior Member
**
Offline Offline

Posts: 52

Thank You
-Given: 37
-Receive: 3


« Reply #12 on: September 25, 2016, 05:51:26 17: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
Senior Member
****
Offline Offline

Posts: 457

Thank You
-Given: 160
-Receive: 495



« Reply #13 on: September 25, 2016, 07:49:33 19: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 really am ruggedly handsome, aren't I?
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