Hello!
I am trying to stable the reading of ADC value, is it possible to put some light if someone has already done in the past, the ADC is of 18Bit how to do the calculation using Moving Average method. I read very few post on this topic, most of them are from V4, it will be great if someone could share a working chart.
Thank you.
Abhi
Moving Average
Moderator: Benj
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Moving Average
Hi Abhi.
I have just put a moving average demo together for you.
Its only going fairly slow because its a demo
You can remove LCD macros and delay from MovingAverage User Macro.
I have just put a moving average demo together for you.
Its only going fairly slow because its a demo
You can remove LCD macros and delay from MovingAverage User Macro.
- Attachments
-
- Moving Average.fcfx
- (15.56 KiB) Downloaded 110 times
Martin
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: Moving Average
Hello! Martin
good morning
So nice of you to post the example, thank you.
May i request you to answer one doubt, i notice the ADC value receiving from the pot is 1023 as the resolution is of 10Bit in the example chip, on contrary i am using the component MCP3421 which has got 18Bit resolution, in that case what are the necessary changes i need to do, is it to change the variable or the calculation will also change.
Honestly, i tried to learn/understand Jan Lichtenbelt chart too regarding the same topic but i did not understand how i can implement that in my case. I notice one thing, kindly correct me if i am wrong, the ADC value which is received from the pot 0-1023 is scaled to 0-32768, calculated and then scale back to 0-1023, but in my case i am using 1/4th part of the ADC count from the MCP3421 (this ADC receives 0-2.048V analog signal and output 0-131071 count) which is 32767 as i am feeding on 512mV as analog signal, this configuration works well for getting the count from the ADC.
My doubt is if i am already receiving 0-32767 count from the ADC then in that case is the scaling necessary, if not then how to remove that, i tried doing but without success.
Thank you, hear you soon.
Abhi
good morning
So nice of you to post the example, thank you.
May i request you to answer one doubt, i notice the ADC value receiving from the pot is 1023 as the resolution is of 10Bit in the example chip, on contrary i am using the component MCP3421 which has got 18Bit resolution, in that case what are the necessary changes i need to do, is it to change the variable or the calculation will also change.
Honestly, i tried to learn/understand Jan Lichtenbelt chart too regarding the same topic but i did not understand how i can implement that in my case. I notice one thing, kindly correct me if i am wrong, the ADC value which is received from the pot 0-1023 is scaled to 0-32768, calculated and then scale back to 0-1023, but in my case i am using 1/4th part of the ADC count from the MCP3421 (this ADC receives 0-2.048V analog signal and output 0-131071 count) which is 32767 as i am feeding on 512mV as analog signal, this configuration works well for getting the count from the ADC.
My doubt is if i am already receiving 0-32767 count from the ADC then in that case is the scaling necessary, if not then how to remove that, i tried doing but without success.
Thank you, hear you soon.
Abhi
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Moving Average
Abhi.but in my case i am using 1/4th part of the ADC count from the MCP3421 (this ADC receives 0-2.048V analog signal and output 0-131071 count) which is 32767 as i am feeding on 512mV as analog signal, this configuration works well for getting the count from the ADC.
if you only use 0-512mV then use a PGA gain of 4(4x512mV = 2.048) and set the Sample rate to 2 (which is 16 bit)then you can use the example directly.if you want to use the 18bit then use a PGA gain again of 4 and use a longs to do the running avaregae 18 bits does not fit in 16 bit variables
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Moving Average
Hi Abhi.
I have made a small adjustment so it should work from 0 to 32767.
On the higher values the count is out slightly
I'm not that great with maths so I used Jan's example and changed it slightly.
I have made a small adjustment so it should work from 0 to 32767.
On the higher values the count is out slightly
I'm not that great with maths so I used Jan's example and changed it slightly.
- Attachments
-
- Moving Average V2.fcfx
- (16.42 KiB) Downloaded 119 times
Martin
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: Moving Average
Hello! Martin Hello! Peter
good afternoon
Kindly excuse to speak my mind but what a profound feeling of friendship, thank you both very much for your answers. I check both the options and keep posted with the result.
Thank you again.
Abhi
good afternoon
Kindly excuse to speak my mind but what a profound feeling of friendship, thank you both very much for your answers. I check both the options and keep posted with the result.
Thank you again.
Abhi
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: Moving Average
Hello! Martin
Once again thank you for your help for the moving average example, but to be honest with you i used your other example again (Analog Filter) it works fantastic for this application, thank you for that example too.
Hello! Peter
As you said i have changed all the variables to Long and now everything works flawless, ranging the count from 0-32767 to 0-131071 gave me a big gap to adjust the error using Martin's Analog filter.
Thank you once again to both of you to help me, cheers...
Abhi
Once again thank you for your help for the moving average example, but to be honest with you i used your other example again (Analog Filter) it works fantastic for this application, thank you for that example too.
Hello! Peter
As you said i have changed all the variables to Long and now everything works flawless, ranging the count from 0-32767 to 0-131071 gave me a big gap to adjust the error using Martin's Analog filter.
Thank you once again to both of you to help me, cheers...
Abhi