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...

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?

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.

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...

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...

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

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.

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.

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.

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.

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.

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 - AutomergedSignal,

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.