Show filter values by UART

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

cross mob
lock attach
Attachments are accessible only for community members.
OsFe_2822791
Level 3
Level 3
25 replies posted 10 replies posted 10 questions asked

Hello,

I create a signal using WaveDac and use an ADC_DelSig to make the digital conversion and a Filter to filter DC componente (because after this test I´m gonna use an external source with DC componente). When I display the signal after the digital conversion step I can see the signal which I created in WaveDac but when I filter the signal I can´t see the expected result, I see another signal.

I´ve tried two ways to filter the signal, using ISR and DMA. I attache the file with both projects. Is any parameter incorrect?

Thank you.

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

OsFe,

Please check DelSig-ADC - Filter - VDAC project:

DelSig_ADC - Filter - VDAC8 streaming demo using DMA

The Signal.rar archive you provided is corrupted. Please make an Archived project and attach it for review: File -> Create Archive Bundle -> Minimal.

/odissey1

ADC-Filter-VDAC_01b_A.png

View solution in original post

0 Likes
15 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

OsFe,

Check out this link:

ADC_SAR - Filter - VDAC8 streaming demo using DMA

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi,

thank you for your response, I looked the project and I think mine is quite similar because I based on that, in adition, I tested a new way with isr but I don´t know what is wrong.

Thank you,

Regards.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

OsFe,

Please check DelSig-ADC - Filter - VDAC project:

DelSig_ADC - Filter - VDAC8 streaming demo using DMA

The Signal.rar archive you provided is corrupted. Please make an Archived project and attach it for review: File -> Create Archive Bundle -> Minimal.

/odissey1

ADC-Filter-VDAC_01b_A.png

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

thank you for your response, I looked the project and I based on that to make mine. I attach the new file, I hope you can see now.

Regards.

0 Likes
lock attach
Attachments are accessible only for community members.
OsFe_2822791
Level 3
Level 3
25 replies posted 10 replies posted 10 questions asked

Hello ,

I make an update. Originally I generate a 100Hz frequency sine wave, if I plot the signal after ADC and before Filter I can see the signal "Before_Filter" but if I plot the signal after the filter I see another signal "After_Filter". Also, I add the configuration of filter. Does anyone have any idea?. Thank you in advance.

PD: I put the values in UART by an interrupt generated with a 1.44MHz and has configurated 115200 bps, 8 bits, none parity and 1 stop bit.

Regards.

0 Likes

OsFe,

The filter output is signed (2's complement), and that is what you see after the Filter, configured for High pass. It is likely that the sign was lost when you plot the output (something like assigning int32 to uint32, etc.).

You can post your project for review here: File->Create workspace bundle->minimal.

Also, it is always helpful to describe what is the goal of the project.

/odissey1

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

thank you for your response. I think you´re right and the error might be some assigment or something like that but I cannot find the error. I read the filter´s values and I save into a char and then I put the values in the UART. I attach my project, do you see anything? Thank you.

Regards.

0 Likes

OsFe,

I see several issues with your project.

First of all, the ADC sampling rate is 48kHz, so UART will not be able to handle stream throughoutput. At  115k UART can send about 12k bytes/sec,  so UART will clog PSoC5 processor and will send only some (random data), skipping most data.

Please describe what do you want to accomplish with this project. Take a look on Cypress demo Filter-ADC-VDAC (File->Code example...).

/odissey1

ADC-Filter-UART_01a_A.png

Other comments:

1. The DelSig-ADC is fully capable of 16-bit resolution a 48kHz, no need to sacrifice it to 8-bit. There is no performance loss if 16-bit ADC is used.

2. Iisr_BeforeFilter comments:

    Do not put any lengthy procedures in the interrupt body! Never use sprintf() or UART calls in side the interrupt!

    Also, no need to check for ADC End Of Conversion, as "eoc" is fired after conversion is completed.

before:

...

int output;

...

CY_ISR(Before_Filter_ISR)

{

    if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS))

        {

            output = ADC_DelSig_1_GetResult8();

            //output = ADC_DelSig_1_CountsTo_Volts(output) ;

            output = ADC_DelSig_1_CountsTo_mVolts(output) ;

            //sprintf(str, "%d\r\n", output);

            //UART_1_PutString(str);

            Filter_1_Write8(Filter_1_CHANNEL_A,output);

        }

}

After:

CY_ISR(Before_Filter_ISR)

{

          uint8 result;                                                           // use local variable (unsigned)

          result = ADC_DelSig_1_GetResult8();                 // ADC result is unsigned in single-ended mode 0-2V

          Filter_1_Write8(Filter_1_CHANNEL_A, output);  // Filter accepts uint8      

}

3. Filter settings.

     The filter is configured for polling the result. Instead it should be configured for interrupt. Such interrupt fires on each data processed (48 kHz). The Filter configured for High-pass(?), Fc=5 Hz. What is the goal of such strange settings? Do you want to cut-off a DC offset of the WaveDac8? The output of the Filter is signed value, as it set to High-Pass filtering.

4. Interrupt ist_tx.

     The interrupt isr_tx is configured to fire at 2MHz rate, which CPU can't handle. Instead, configure the Filter for interrupt (isr rate will be as input rate, 48kHz), and attach ISR to the Filter isr pin. Then set a flag and handle flag in the main body to process filter output. Again, never put any lengthy procedures in the interrupt body! Never use sprintf() or UART calls in side the interrupt! Again, the UART will not be able to handle 48 kHz stream! Define the goal of your project first!

Before:

....

CY_ISR(After_Filter_ISR)

{

    //salida_filtro=Filter_1_Read16(Filter_1_CHANNEL_B);

    sprintf(str,"%d\r\n",Filter_1_Read8(Filter_1_CHANNEL_A));

    //sprintf(salida, "%d\r\n", output);

    UART_1_PutString(str);

}

After:

volatile uint8 FilterResult=0;                // the Filter output is actually 2's-complement

volatile uint8 isr_FilterDoneFlag = 0;   // semaphore flag

CY_ISR(After_Filter_ISR)

{

     isr_FilterDoneFlag = 1;

     FilterResult = Filter_1_Read8(Filter_1_CHANNEL_A));

}

....

int main() // not void

{

    for(;;)

    {

          if (isr_FilterDoneFlag != 0) // Filter result is ready

          {

               isr_FilterDoneFlag = 0; // reset flag

              

               // do something with Filter data...

              // slow and inefficient->

              //sprintf(str,"%d\r\n", FilterResult); // this is very slow conversion into ASCII

              //UART_1_PutString(str);

             UART_1_PutChar( FilterResult); // faster, 1-byte per result, even this is too slow for 48kHz!

          }

     }

}

Hello,

thank you so much for your reply. First of all, the goal of my project is measure an analog signal, remove DC component and send data to the PC. For this reason I use a 5Hz high pass filter.

I used your advice but I measure a signal which is not yet what is the expected.

Regarding to your comments:

1. I use 8 bit only for testing, when the program can filter the signal and transmit to the PC I will modify it using 16 bits.

2. Thank you for your advice, I am a begginer at this and I really appreciate your help. I change my code for yours.

3. As I said before, I want to remove the DC component, not the DC of WaveDac component but I want to do the same stage and when this works fine I change the input and it already works as well as before. Also, I changed the filter settings for interrupt.

4. As in 2) I improve my code with your tips, thank you so much. But it still not works, I supose is because the UART are not be able to handle 48kHz and a baudrate of 115200bps, what would be a good baud rate or frequency sample to adquire a 500Hz signal?

Thank you for your help.

Regards.

0 Likes

OsFe,

What software do you use to save data on PC side? Let start with receiver side and check what is the max speed of the UART it can handle.

Secondly, do you want to send the data continuously, or, say, 2000 points once per second is enough (like an o-scope).

/odissey1

0 Likes

Hello,

I use Python (I can use Matlab too) to save data on PC. The goal is acquire an analog signal in real time and send data to the PC, I don´t know if I answered your question.

Thank you.

Regards.

0 Likes

OsFe,

So, using your custom Python software, what is the max working data transfer rate? For example 48lk samples/sec at 16 bits, equals to 48000 * 10 * 2 = 960'000 baud. Meaning, that UART speed should be 1Mbd at least. PSoC can provide that UART speed, but can your software handle it?

/odissey1

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

I the Python's script I am working at the same baudrate as I defined in UART (115200 in this case), in fact, if I send data before the filter I can see the signal which I created in WaveDac8 but when I filter the signal, this signal is wrong. I attach the project , in this case I desingned a 5kHz high pass filter so the signal before and after the filter should be the same but is isn´t. Is something wrong?

Regards.

0 Likes
lock attach
Attachments are accessible only for community members.

I make an update in the project, there was an error in the filter, but the final signal is not the same as the original. Can anybody help me please?

Thank you in advance.

Regards.

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

I make a little update, finally I could receive the signal correctly with 8 bits but now I am using 16 bits in the ADC_DelSig and I receive a wrong signal after the filter. I am generating a test 1kHz signal and if I configure a 5kHz low pass filter I receive the correct signal but if I configure a 0.5Hz high pass filter I receive a wrong signal, I attach the workspace, is there anything wrong?

Thank you for all,

regards.

0 Likes