Need help on AN66444

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

cross mob
JiLi_874441
Level 1
Level 1
Welcome! First question asked First reply posted

I am trying to implement application note AN66444 in my project that require an accurate voltmeter.

   

Following is the code segment from main.c downloaded with AN66444:-

   

     { ...................

   

    /*perform CDS*/
        iVcds = iVout1 - iVout2;
        
        /* IIR Filter*/
        iVcds_curr = iVcds;
        iVcds_acc += (iVcds_curr - iVcds_acc) >> 4;
        }
    
    /*Display output in desired format on UART*/
    fVcds = ADC_DelSig_1_CountsTo_Volts(iVout1);
    UART_1_PutChar('\r');
    UART_1_PutChar('\n');
    sprintf(caVcds_decimal_str,"%f",(float)fVcds);
    UART_1_PutString((uint8*)caVcds_decimal_str);

   

The display routine is displaying "iVout1".

   

I could not find any link between the "IIR routine" and the "display routine".

   

Would greatly appreciate if someone can help me on how the IIR Filter is being used here ?

0 Likes
1 Solution
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi,    

could you please check IIR filter implementation appnote AN2099 (http://www.cypress.com/file/127091/download ). Please check the psuedo code under "PSoC 4 and PSoC 5LP Filter Implementation" for low pass implementation.

Best Regards,
VSRS

View solution in original post

9 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum!

   

Change some settings:

   

In system view set the heap size to 0x0200

   

in Project->Build settings->Arm GCC...->Linker set both "Use newlib nano" and "Use newlib nano float formatting" to true.

   

 

   

Bob

0 Likes
JiLi_874441
Level 1
Level 1
Welcome! First question asked First reply posted

Hi, thank you thequick reply.

   

Sorry, i did not make my problem clear.

   

The IIR Filter code are not being utilized. I would like help on how to make use of the IIR Filter code to perform the low pass filter.

   

The "iVcds_acc" value does not correspond to the actual input value. I think additional code are needed to implement the filter.

   

I can understand the correlated double sampling (CDS) but am at a total lost on the IIR Filter portion.

   

Jim

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

Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted
        jimbies, Look on this output conversion code (counts to volt): fVcds = ADC_DelSig_1_CountsTo_Volts(iVout1); If you replace "iVout1" with "iVcds_acc", the output to terminal will show averaged value. (well, it is my guess without seeing all code)   
0 Likes
lock attach
Attachments are accessible only for community members.
JiLi_874441
Level 1
Level 1
Welcome! First question asked First reply posted

Thank you all for the reply.

   

I did replace "iVout1" with "iVcds_acc" but the value is much lower that my actual input. It looks like something is missing in the "/* IIR Filter*/" code segment.

   

I have attached the project file, which is actually the example file from AN66444, The only change that I have made is the output code - from UART to LCD Display.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted
        jimbies, I am not at computer right now. My guess is that you not need correlated data sampling (CDS), so following code modification should work: { ......... /* IIR Filter*/ iVcds_curr = iVout1; iVcds_acc += (iVcds_curr - iVcds_acc) >> 4; } /*Display output in desired format on UART*/ fVcds = ADC_DelSig_1_CountsTo_Volts(iVcds_acc);   
0 Likes
JiLi_874441
Level 1
Level 1
Welcome! First question asked First reply posted

iVcds_acc += (iVcds_curr - iVcds_acc) >> 4; is giving an output = 7.573.

   

iVcds gives an output = 4.622 which I have verified with a multimeter to be correct.

   

Being bad at filter equations, I am not able to figure out what is wrong. Any tips would be most helpful.

0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi,    

could you please check IIR filter implementation appnote AN2099 (http://www.cypress.com/file/127091/download ). Please check the psuedo code under "PSoC 4 and PSoC 5LP Filter Implementation" for low pass implementation.

Best Regards,
VSRS

JiLi_874441
Level 1
Level 1
Welcome! First question asked First reply posted

Hi VSRS,

Thank you.

0 Likes