| ??? 03/29/03 19:44 Read: times |
#42519 - RE: AD-conv. and averages, tricks needed... Responding to: ???'s previous message |
Hello Kari, although your English is not perfect, it is perfectly understandable.
Yes, the code should work fine on a standard 8052. What it does is this: there is a buffer of 16 bytes, starting from BUFSTART. Every time you call MAIN with a new value in the accu (Well... if you would turn it into a subroutine by adding RET just before END), the oldest byte in the buffer is replaced with the value in the accu. Then the average of all sixteen numbers is calculated by adding all bytes in the buffer, and then dividing it by 16. The adding is not done byte-by-byte but with with a 'trick', called a running sum. (do a google or something to learn more about running statistics). The division is also done with a trick (implementing a four bit shift using SWAP). Also note, tha I use XCH a lot. This instruction is perfect to avoid PUSHing and POPping (which is slow) all the time. The ability to use 'tricks' and the direct control you have over the controller is what makes assembler so much more interesting than a higher level language. There is also a disadvantage: it takes longer to write (usually). The lines starting with $ are only to tell my assembler to use certain external files. I use the free MetaLink assembler. When you are measuring a value over time, you are dealing with a SIGNAL. I suggest you do some studying on this subject. There is a very good e-book about this on the website of Analog Devices (www.analog.com), technical support section, Data converters, seminar materials, Mixed Signal and DSP Design Techniques. There is more there than you will ever want to know ;-) Good luck. |
| 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 |



