| ??? 03/29/03 00:12 Read: times |
#42479 - RE: AD-conv. and averages, tricks needed... Responding to: ???'s previous message |
This is an example of a 16 byte averager. Most problems with jittery a/d conversion are due to power supply ripple and bad ground layout. Pay attention to that before you try to stabilize (read: throw away data) in software.
;16 sample average $mod552 $debug(middel.abs) bufsize equ 16 dseg org 040h pointer: ds 1 totallsb: ds 1 ;16-bits 'running' total totalmsb: ds 1 bufstart: ds 16 ;newest first, oldest last cseg org 0 ljmp init org 00400h init: mov pointer,#bufstart ;pointer MUST be in lower 128 RAM mov r0,#totallsb clr a mov b,bufsize+2 initloop: mov @r0,a inc r0 djnz b,initloop main: mov r0,#totallsb ;totaal + new value xch a,@r0 add a,@r0 xch a,@r0 inc r0 xch a,@r0 addc a,#0 xch a,@r0 mov r0,pointer ;New value in bufstart, oldest out xch a,@r0 xch a,pointer ;update bufstart pointer inc a cjne a,#bufstart+bufsize,nowrap mov a,#bufstart nowrap: xch a,pointer mov r0,#totallsb ;totaal - oldest xch a,@r0 clr c subb a,@r0 mov @r0,a inc r0 mov a,@r0 subb a,#0 mov @r0,a dec r0 mov a,@r0 ;total / 16 anl a,#0f0h inc r0 orl a,@r0 swap a ;average now in a end |
| Topic | Author | Date |
| AD-conv. and averages, tricks needed... | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed... | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed... | 01/01/70 00:00 | |
| Read data reliably | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed... | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed... | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed... | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed... | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed... | 01/01/70 00:00 | |
| Is the code for 8052? | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed... | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed | 01/01/70 00:00 | |
| RE: AD-conv. and averages, tricks needed | 01/01/70 00:00 | |
| RE: AD-conv. _ Steve | 01/01/70 00:00 | |
| RE: AD-conv. _ Steve | 01/01/70 00:00 | |
RE: AD-conv. _ Steve | 01/01/70 00:00 |



