How to pass signal values stored in a variable (in software) to a Low pass filter in PSOC 5LP?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello Everyone,

   

I stored ADC output in "uint16 adcReading". I did some mathematical operation and save it into same same variable. So my code becomes:

   


        adcReading = ADC_GetResult16();
        adcReading= adcReading*ans_0;

   

Now i want to pass signal stored in " adcReading" through low pass filter block. How i can do this operation?

   

Looking forward for your reply.

   

Regards

   

maknight

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Look into the Datasheet of Filter, APIs.

   

There is a Filter_Write8() and a Filter_Write16() depending on your desired width.

   

 

   

Bob

View solution in original post

0 Likes
20 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Look into the Datasheet of Filter, APIs.

   

There is a Filter_Write8() and a Filter_Write16() depending on your desired width.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thankyou Bob for your reply 🙂 .

0 Likes
Anonymous
Not applicable

Hello Bob,

   

I made a project named "flip flip". I attached the zip file of it with this message.

   

What i want to do is as follows:

   

1. Digitized the input signal (VDAC in this case for test perpose).

   

2. Store D Flip Flop Q out put into a variable.

   

3. Multiply data captured from step 1 and 2 and pass through the low pass filter.

   

I wrote the code and every thing could please have a look on it and correct me.

   

Looking forward for your suggestions.

   

Best Regards

   

maknight

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You did not tell what board you use, so I presume a CY8CKIT-059 Prototyping Kit. This has got a cap buffer at P0_3 and P3_2 to stabilize the reference voltage of the ADC, I would suggest to change the settings of VREF in the ADC properties accordingly. The capacitor on P0_3 may disturb your DAC-output, have a look at the schematics (you'll find them under the programs\Cypress folder.

   

You do not (yet) read the data out of the filter.

   

Your filter sample frequency must match your ADC sample frequency

   

 

   

Bob

0 Likes
Anonymous
Not applicable

its CY8CKIT-050, PSOC 5LP

0 Likes
Anonymous
Not applicable

Yes settings needs to be done.

   

What about the Programming? Is that fine?

   

I am not sure about the status registers.

   

Regards

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

For the -050LP kit use P3_2 there is a 10µF cap connected to.

   

Reading of the status-registers is ok, but you probably want to read them in the loop?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

yes i want to read them in loop.

0 Likes
Anonymous
Not applicable

Hello Bob,

   

I am getting error in my code. I want to find the square root. I am feeling stupid now :(.

   

I attached the pic of my code and error message.

   

Please have a look on it and guide me.

   

Looking forward for your reply.

   

Regards

   

maknight

   

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Did you #include <math.h>?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Good Morning Bob,

   

Thankyou for your reply.

   

Yes I included that.

   

You can see my file (in attachment).

   

Regards

   

maknight

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Additional libraries. You must use mlib, so you just have to enter "m". See attached picture.

   

a typecast has to be set in parentheses, so it is "(double) sqrt"

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Perfect 🙂

   

Thankyou Bob 🙂

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are always welcome, Akhan!

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hello Bob,

   

I have one more problem 😞

   

Please guide me!

   

I have two channel data stored in variables (initialize in main.C) a shown below:

   

Channel 1 :

   

      /*Modulation performed between ninety shifted clock signal and adc output*/
        output1_zeroshifted= adc_output*zero_shiftedvalue;
        
        /*Modulation performed between zero shifted clock signal and adc output*/
        output1_ninetyshifted=adc_output*ninety_shiftedvalue;

   

Channel 2 :

   

      /*Modulation performed between ninety shifted clock signal and adc output*/
        output2_zeroshifted= adc_output*zero_shiftedvalue;
        
        /*Modulation performed between zero shifted clock signal and adc output*/
        output2_ninetyshifted=adc_output*ninety_shiftedvalue;

   

Now i want to pass each of these data through my digital filter but the problem is that, i can only use one filter block (due to psoc limit). The only way i can think of is to use a digital mux. But, then how i can write the software values into mux?

   

My Second idea is to write values in VDAC via DMA, i dont know if it is possible but if yes, then how i can do this?

   

If you have any other idea then please suggest me.

   

 

   

Looking forward for your sugestions.

   

 

   

Regards

   

makhan

0 Likes
Anonymous
Not applicable

Thx for remembering me Bob 🙂

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You can only send the three sequences one after the other to the filter block. Do you need the three filtered signals at the same time?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Three sequences? I didn't get it.

   

What i am thinking is that, We have Two channels in filter (A and B).

   

I want to use channel A as band pass filter and channel B as low pass filter. Output of adc will pass through Channel A (means Channel 1 and 2 will pass through BPF). So the two channels output that i shown above will be the result of multiplication stuff after band pass filter. This result i need to pass through Low pass filter (Channel B of filter).

   

 

   

makhan

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A digital mux will not do it, you are writing directly (with CPU or DMA) data into the filter. Switching from one series of data to another will be disturbed because in the filter component some intermediate results are kept and will get mixed. So you will have to reset the filter when using another series of data (the multiplication stuff)

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Ok Thankyou Bob for your reply.

0 Likes