Discussion in "8051 Discussion Forum" started by    Una    Mar 16, 2010.
Tue Mar 16 2010, 03:21 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, 05:00 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, 05:16 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, 05:25 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, 01:44 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?
Thu Mar 18 2010, 07:37 PM
#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, 01:25 AM
#7
Im using assembly
Mon Mar 22 2010, 10:44 AM
#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

Conversation

No messages yet.

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 80, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123