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.

[PIC] EEPROM data storage in pic18f45k22

Status
Not open for further replies.

usualkaiser

Newbie level 4
Joined
Apr 9, 2014
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
60
i have a problem storing data in the EEPROM of pic18f45k22. the data is stored alright, but whenever a new loop begins, the old data is automatically overwritten. i want to store the data in pic till the storage capacity is saturated. can it be done? and also when i try using different ports to acquire input signal, it only responds to one port,i.e., port A, port C,D,E etc doesn't work as input together with port A. they only work separately. can we make them work together?
 

the data is stored alright, but whenever a new loop begins, the old data is automatically overwritten.
You said data..and data means,RAM.RAM memory is supposed to be updated continuously,so no,you cannot retain data in memory as you think.If you intend,to store the data in PIC,then you need to pass data from RAM to EEPROM units...that is the _only_ way you can retain data.
ADC is connected to port A..thats why when you say....
when i try using different ports to acquire input signal, it only responds to one port,i.e., port A, port C,D,E etc doesn't work as input together with port A.
only port A works.
Maybe if you would upload your code...I would understand better.
 
here is my code where i tried to input data through all the ports except port B.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;
 
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
 
char txt1[5],v[5],txt2[5] ;
unsigned int a1,i,j,b1,k,c1,val;
 
void main()
  {
           ANSELA  = 0xFF;              // Configure PORT A pin as analog i/p
           ANSELB  = 0x00;
           ANSELC  = 0XFF;             // Configure PORT C pin as analog i/p
 
           ANSELD  = 0xFF;
 
           C1ON_bit = 0;               // Disable comparators
           C2ON_bit = 0;
 
           TRISA  = 0xFF;              // PORTA is input
           TRISB  = 0x00;
           TRISC  = 0XFF;              // PORTA is input
 
           TRISD  = 0xFF;              // PORTD is i/p
 
           Lcd_Init();                        // Initialize Lcd
 
            Lcd_Cmd(_LCD_CLEAR);              // Clear display
            Lcd_Cmd(_LCD_CURSOR_OFF);         // Cursor off
 
             while(1)
               {
                Lcd_Cmd(_LCD_CLEAR);
                for(i=0;i<8;i++)
               {
              /*for(j=0;j<8 ;j++)
                 {*/
                a1 = ADC_read(i);
                //EEPROM_Write(j,a1);
               //jj=j+1;
               EEPROM_Write(i,a1);
 
                Delay_ms(1000);
                }
                for(i=0;i<8;i++)
                {
                Lcd_Cmd(_LCD_CLEAR);               // Clear display
            Lcd_Cmd(_LCD_CURSOR_OFF);
                   val=EEPROM_Read(i);
                  Delay_ms(1000);
                  //LATD=val;
                  floatTostr(val,v);
                Lcd_Out(1,1,v);
                  Delay_ms(1000);
                }
               Lcd_Cmd(_LCD_CLEAR);
               for(j=14;j<20;j++)
                {
              /*for(j=0;j<8 ;j++)
                 {*/
                jj = ADC_read(j);
 
                //EEPROM_Write(j,a1);
               //jj=j+1;
               EEPROM_Write(j,b1);
 
                Delay_ms(1000);
                }
                 for(j=14;j<20;j++)
                {
                Lcd_Cmd(_LCD_CLEAR);               // Clear display
            Lcd_Cmd(_LCD_CURSOR_OFF);
                   val=EEPROM_Read(j);
                  Delay_ms(1000);
                  //latd=val;
                  floatTostr(val,txt1);
                Lcd_Out(2,1,txt1);
                  Delay_ms(1000);
                }
               Lcd_Cmd(_LCD_CLEAR);
               for(k=20;k<27;k++)
                {
              /*for(j=0;j<8 ;j++)
                 {*/
                c1 = ADC_read(k);
                //EEPROM_Write(j,a1);
               //jj=j+1;
               EEPROM_Write(k,c1);
                Delay_ms(1000);
                }
                 for(k=20;k<27;k++)
                {
                Lcd_Cmd(_LCD_CLEAR);               // Clear display
            Lcd_Cmd(_LCD_CURSOR_OFF);
                   val=EEPROM_Read(k);
                  Delay_ms(1000);
                  //latd=val;
                  floatTostr(val,txt2);
                Lcd_Out(2,6,txt2);
                  Delay_ms(1000);
                }
         }
  }



it only works for port A only. can you help me to store the data in EEPROM as well as use all the ports as input?
 
Last edited by a moderator:

i've uploaded my code.is it visible to you?please check it out
 

Post code in syntax tags. syntax tags =

Code C - [expand]
1
2
3
4
your code here [/syntax ]  Remove the space before the closing square bracket. Zip and post your mikroC project files.
 
 
All the arrays should have 23 elements for using with FloatToStr() function.

 
Last edited:

ok..that was unintentional..did not know the rule about that..apologies...now if anyone has thoroughly gone through my code, can anyone help me with it? will appreciate it..
 

Its will be better if you Zip and post the complete mikroC project files and mention how exactly the code should work.
 
I read the code....and it looks like what the code does, is get an analog value from a sensor attached at port A....send it EEPROM,and display it on an LCD.Now if you would post the mikroC project files,like milan.rajik said, and explain how the code is _supposed_ to work,and how it is actually working....It would be helpful.
 
i've attached the .rar file with this reply. i want to read analog data from ports A,C,D, total 19 analog inputs..then store them in EEPROM and after that display them on LCD.

Problems i am facing: analog signals are only acquired from port A, port C,D analog inputs are not working, EEPROM data is stored for only one cycle, if possible i would like to overflow the EEPROM with data to check how much data it can contain and in how much time it will be saturated with data.(though i know these can be calculated, i would like to practically do it)

further aim: would like to expand the number of analog inputs to 48 using MUX. is it possible?
 

Attachments

  • 19ipACD.rar
    802 bytes · Views: 100

How frequently does the ADC values change? If it changes every 1 sec say then you need 96 bytes of eeprom to store data of 48 analog inputs. You should also consider the max write/erase cycle of eeprom (eeprom byte). If adc value changes too frequently then it is better to use SD card to store the adc values.
 

eeprom storage is on temporary halt now. i want to know how can i incorporate a 16x1 mux to get 48 analog inputs to pic18f45k22, i mean hardware wise and program wise. i am quite a newbee here.
 

How frequently does the ADC values change? If it changes every 1 sec say then you need 96 bytes of eeprom to store data of 48 analog inputs.
Can you explain how did you get 96 bytes as the minimum amount of memory needed for 48 analog input(s)...assuming the signal changes(or it is sampled) every one second..?
how can i incorporate a 16x1 mux to get 48 analog inputs to pic18f45k22
You can connect the mux output pin to single input pin of the PIC18F45K22 ADC..although how the 16 analog signals would be sampled on a single ADC input pin...that looks like a tough one.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top