Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Averaging adc reading

Status
Not open for further replies.

bjay

Newbie level 4
Joined
Sep 15, 2010
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Australia
Activity points
1,311
I am looking for help on averaging a adc reading in assembly language
Just not sure how to do it ,,I had a go at adding 4 values together then rotate right but it didnt work correct
If anyone knows of a good tutorial or code snippets i would be very thankfull :)
cheers
bjay
 

Hi,
you are very close. It is shifting right though, not rotating. Rotating right brings the least significant bits back into the game a most significant bits. Shifting right by 2 just discards of the 2 LSBs

hth, Bob
 
  • Like
Reactions: kender

    kender

    Points: 2
    Helpful Answer Positive Rating
Thanks bob

I will try shifting right ,, When i can get to it again

cheers
Bjay
 

hi,
in C language
unsigned int16 xin[5] ;
{
xin[4]=xin[3];
xin[3]=xin[2];
xin[2]=xin[1];
xin[1]=xin[0];
xin[0]=read_adc();
volt=(xin[0]+xin[1]+xin[2]+xin[3]+xin[4])/5;


}
 

Thanks oh_jani

But i am coding this in assembly
I am not using C at the moment

bjay
 

in C language

you can greatly simplify and speed up the calculation if you use rolling average (aka exponential smoothing).
 

The adc works well at the moment
I was just trying to make it a little better by taking a few readings then divide
I have read a little about rolling averages but i wanted to keep it simple
I have been looking at c code of late, but you go back to what you are comfortable in
Thanks for the reply millwood

bjay
 

for beter result of adc
very simple u some change in hardware

mcu pin--------||-------GND
+ -
capcitor value 47uf

for avr and pic project vist my site avr2pic

WELCOME TO---> AVR2PIC
 
Last edited:

Thanks Jani

I did that its pretty good now

Interesting website a few good projects on there

not being picky but a few spelling mistakes on the avr page

Running,Temperature,Digital,Thermometer

bjay
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top