Discussion in "8051 Discussion Forum" started by    Una    Mar 16, 2010.
Tue Mar 16 2010, 08:51 pm
#1
I have made a sound level meter. The output is sent to ADC0804 and then to 8051. Every time, the reading goes above a certain level, I want the reading to be stored in the controller. Also, at the end of the day a graph has to be plotted from the values. Is it possible? Or at least to be able to retrieve the values? please tell me soon.
Tue Mar 16 2010, 10:30 pm
#2
yes i would recommend you using an external EEPROM like 24C256 or 24C128 etc. to store your data and later you can retrieve them. These memories works on I2C protocol.
Tue Mar 16 2010, 10:46 pm
#3
What is 12C protocol? Actually I haven't used an external memory before. Cant the internal RAM of the controller be enough? And what about the graph? Im really short on time, can you please tell me something easy and good. Thankyou
Tue Mar 16 2010, 10:55 pm
#4
data stored in internal ram wont stay if no power but if you are using EEPROM data will still be there if you dont have power connected to device. If you are new to EEPROMs and I2C then it may take long for you to understand the whole but is good to learn new things.
check tutorial section for tutorial on I2C: http://www.8051projects.net/microcontroller-tutorials/

as you said you are short of time then you can use RAM are you using C or assembly?
Wed Mar 17 2010, 07:14 am
#5
ok. But how would I retrieve the values? Please tell me about the graph as well? And how many samples would I be able to store in the RAM?
Fri Mar 19 2010, 01:07 am
#6
i would be glad to tell you how this all be done but i have to know what language are you using. Is it C or assembly?

and number of samples would be limited to amount of RAM you have in controller or on your hardware board.

[Topic moved to 8051 Discussion forum]
Fri Mar 19 2010, 06:55 am
#7
Im using assembly
Mon Mar 22 2010, 04:14 pm
#8
ok.. as i told you storing in RAM is limited to available amount of RAM in your controller.

you can define a memory location that will be used for storing ADC values and after storing on one location your move to next location. just like a queue in C code.

you need to maintain two pointers one for read and one for write.

here is a small example:
Lets say our memory location to store ADC data is 50H in ram and pointers are stored at Readpointer at 4EH and write pointer at 4FH.
you can define them like this in assembly.

StoreLoc equ 50H
RdPtr equ 4EH
WrPtr equ 4FH

You have to initialize your Read and write pointer to same location which is start of your queue in this example its 50H.

mov RdPtr, #50H
mov WrPtr, #50H


Now you can use r0 or r1 to read/write data on memory location pointed by RdPtr or WrPtr. Here is small example of read and write in assembly:

;Writing to location pointed by WrPtr
mov r0, WrPtr ;move write address to R0 pointer
mov @r0, ADC_Data ;move adc data to ram
inc @r0 ;increment write pointer

;Reading data from location pointed by RdPtr
mov r0, RdPtr ;load address from read pointer
mov A, @r0 ;read data from location an store in Accumulator
inc @r0 ;increment read pointer


Now you also have to take care the length of queue. coz you cannot just keep writing you have to limit it in some way. like in this case my queue length is going to be 16 values. so i will keep checking till i reach 5FH when i reach 5FH i will reset pointer to top position.

mov A, WrPtr
cjne A,#5FH, NotFull ;check Write pointer is equal to 5FH if not then we still have space to store more data
;else we have to set WrPtr to start of queue and keep over writing last stored values
mov WrPtr, #50H
;queue is full here we are going to overwrite

NotFull:
;we have come here coz queue is not full yet..
so we can keep writing data


similarly you have to check for read pointer.. there are many ways you can implement queues in controller you need to find out a suitable and easy way to do this.. it all upon choice.
Tags queue in 8051 assemblydata queue using 8051 assembly

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Oariorrca
Wed Oct 16 2024, 01:14 am
Oariorvln
Wed Oct 16 2024, 12:59 am
Jamesrat
Wed Oct 16 2024, 12:56 am
Cazrwam
Tue Oct 15 2024, 04:50 pm
Cazrlby
Tue Oct 15 2024, 04:34 pm
Ameliaror
Tue Oct 15 2024, 03:02 pm
GlendaInvaf
Tue Oct 15 2024, 02:30 pm
Georgepucky
Tue Oct 15 2024, 12:11 am