Electronics > Microcontrollers
Fast software signal filtering
Psi:
Hey guys,
Can anyone think of a good approach to convert the yellow ADC input waveform into the green signal using software on an AVR.
(The green signal will then be converted to a digital stream of bits)
I've tried a running average but i'd prefer something a bit more advanced that's able to keep the edges as sharp as possible.
It's important that the top part of the waveform is used to create the new signal because the signal can also look like this.
IanB:
I'm not clear about your requirements. Is the AVR sampling the data and you want to process it in real time--and the oscilloscope pictures are just for illustration?
Assuming the above to be true, you can write any software you like to do the job. Is it the algorithm you are asking for suggestions about?
If you are asking about the algorithm, that could be easy or hard depending on the details. How many possible levels can the green trace have? Assuming it is a small number like 16 I would write code that detects the height of each peak in the yellow signal and then maps this to the nearest valid level of the green signal. However, your first and second illustrations are contradictory. If the upper trace were processed according to the parameters of the lower trace, then your step signal would become a staircase signal.
With this kind of question the answers are all in the details, and the details are complex.
Psi:
--- Quote from: IanB on January 25, 2012, 02:32:26 am ---I'm not clear about your requirements. Is the AVR sampling the data and you want to process it in real time--and the oscilloscope pictures are just for illustration?
--- End quote ---
Sorry, yes, the adc is sampling the yellow data on the scope and i want to process it in real time on the AVR.
--- Quote from: IanB on January 25, 2012, 02:32:26 am ---Is it the algorithm you are asking for suggestions about?
--- End quote ---
Yes
--- Quote from: IanB on January 25, 2012, 02:32:26 am ---If you are asking about the algorithm, that could be easy or hard depending on the details. How many possible levels can the green trace have? Assuming it is a small number like 16 I would write code that detects the height of each peak in the yellow signal and then maps this to the nearest valid level of the green signal. However, your first and second illustrations are contradictory. If the upper trace were processed according to the parameters of the lower trace, then your step signal would become a staircase signal.
--- End quote ---
The green will eventually be turned into straight digital, i was just trying to break down the steps needed and focus on cleaning up the signal first.
--- Quote from: IanB on January 25, 2012, 02:32:26 am ---With this kind of question the answers are all in the details, and the details are complex.
--- End quote ---
Yeah, i'm not after example code. Just ideas.
Since posting i've had the idea of a running average that then averages the answer with the center value of the average range.
This would make it quicker to respond to changes on the edges each pulses. but i've not tried it yet.
Zad:
Use the maximum value of the last (n) samples? Very fast to do and only needs a small circular buffer.
Psi:
--- Quote from: Zad on January 25, 2012, 02:44:48 am ---Use the maximum value of the last (n) samples? Very fast to do and only needs a small circular buffer.
--- End quote ---
That's so simple there has to be some reason i didn't think of it ???
But i can't think of one :)
I will try that asap
Thanks
EDIT: Ok, i think i see why that might not be the best plan.
It's fine for when the buffer first encounters a pulse. (it responds instantly with the new max value)
But when it exist the end of a pulse its going to use the max value until the buffer clears.
So the pulses are all going to end up longer than they should be by the length of the buffer.
Navigation
[0] Message Index
[#] Next page
Go to full version