- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi to all,
How to get the output of a filter without using a VDAC?
I've started from the code example Filter_ADAC_VDAC_poll on a CY8CKIT-050 kit, removed the VDAC and the OpAmp, using the Potentiometer as ADC input, and added UART to see the results with the help of the RS232 on a PC.
Till the output of the ADC everything is fine.
The issue is with the results at the output of the Filter. I know that they are 2's complement, but I don't know how i can get "normal values" out of them. I just want to be able to get 4V when the Potentiometer is giving 4V.. and so on. It would be great if someone would tell me the solution also for 24 bit resolution.
I wanted to use something like
uint8 After_Filter = Filter_Read8(Filter_CHANNEL_A);
sprintf(fil_string, "After Filter raw : %i", After_Filter);
UART_1_PutString(fil_string);
and get the equation to convert the values into something understandable, but the values were just too messy for me, and dependable on the data type I use (uint8, float, int ... etc) !!
Thanks for any help.
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum.
2's complement are "normal" integers. You might need a sign expand, but usually your potentiometer values are positive.
You should convert (assign to) your 24-bit value to a 32-bit integer.
Your variable "After_Filter" is unsigned, but your selected format %i is for signed. Look here for format specifiers.
What I am not quite sure of: the filter is for filtering frequencies, but your potentiometer does not deliver one, but pure DC.
Wouldn't it be more appropriate to use a (sliding) average?
Bob
PS: Where in Germany are you located? I live near Bremen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum.
2's complement are "normal" integers. You might need a sign expand, but usually your potentiometer values are positive.
You should convert (assign to) your 24-bit value to a 32-bit integer.
Your variable "After_Filter" is unsigned, but your selected format %i is for signed. Look here for format specifiers.
What I am not quite sure of: the filter is for filtering frequencies, but your potentiometer does not deliver one, but pure DC.
Wouldn't it be more appropriate to use a (sliding) average?
Bob
PS: Where in Germany are you located? I live near Bremen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your comment, Bob !
I was trying different kind of input, but moved to the potentiometer in the hope of understanding the Filter output better. I know the input exactly, so I thought I could understand this 2's complement representation... not quite a success yet !
Regarding the output, it ranges from 0 to 255 (I'm starting with 8 bit values), but from 27 (around 2,5 v in potentiometer) it jumps directly to 228 ! This drives me crazy !!!
I noticed this %i after posting and changed it to %u .. no difference in my case.
~A
PS : I live in Thuringia.. in the forest there 🙂
PPS: I follow the forum since couple of weeks now. You do great help here *thump up*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please post your complete project, 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are some hints in the datasheet showing that polling and DMA may not work as expected, reading off the data may clear the data ready flag etc.
You read the filter into an 8bit unsigned but the result is signed which causes the jumps in the output. To reduce noise, use the buffered reference option, afaik the required cap is already on your board at pin P0_3, please check with schematics.
Check if you run your board at 5V as you declared in the system view. This information is taken to calculate the count to mV correctly.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By using the signed data types (int8) or (int8_t) the jump is still at 2.5V , but it becomes to the most negative value (from 27 to -28). So my problems are: the jump, and the overall resolution is still much lower than 8 bit ! all the values I got at the Filter's output are between -28 to +27 !!
Another thing: when I used
ADC_DelSig_GetResult8();
I have a jump from 55 to -56 , but even Potentionsmeter (the result of ADC conversion) is jumping also at 2.5V to -2.5V , while the input range is still from Vssa to Vdda , and reference is still at Internal Vdda/4. I only changed GetResult from 32 to 8, and it doesn't accept the range 0 to 5 anymore .. but takes it as from -2.5V to +2.5V !
It seems that I missed some basics in the ADC, but I simply couldn't find the help in ADC datasheet.. or my head is simply early in the holiday !
Sorry for bothering !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for helping. It was all about the data types.
Beside that, there was a problem with the reference. After deleting the OpAmp from the Code Example, PSoC Creator kept considering it somehow; in one warning it was still showing it. I needed to start a blank project to overcome this.