embedded program to store the value continuously

Status
Not open for further replies.

fan174

Member
I want to determine time at every zero crossing for 5V AC input signal using the PIC micro-controller.

How to write embedded program to store the value continuously like below table

Value time
T1 2
T2 2.5
T3 2.1
T4 1.9
.
.
Tn Tn
 
I want to store in variable T1, T2.. Tn in 8 bit data reading like the table I shown
Normally you'd store in an array as you can reference each entry by a number. What you're trying to do is reference differently-named variables. Ok if you have a small finite number of variables, but will rapidly get out of hand. Use an array:
T[index]=data;
Otherwise, you're looking at:
switch(index)
when 1: T1=data; break;
when 2: T2=data; break;
when 3: T3=data; break;
when 4: cow=data; break;
when 5: chicken=data; break;
etc. forever
 
I want to determine time at every zero crossing for 5V AC input signal using the PIC micro-controller.

How to write embedded program to store the value continuously like below table
To fan174,
Your question seems like a course work assignment.

Could you be a bit more descriptive what you mean by time?

For example:
Is it the current time of day?
Is it the time since I had lunch?
Is it the time since the last zero crossing?​
 
To fan174,
Your question seems like a course work assignment.

Is it the time since the last zero crossing?​
I want to determine and store time at every zero crossing for 5V AC input signal with PIC16f877a

T1 2
T2 2.5
T3 2.1
T4 1.9
.
.
Tn Tn

I am also confuse with interrupt which interrupt should i use external or interrupt on change
 
You keep saying you want to store time - this is meaningless - In my time zone the last crossing was at approximately 18:29:45.24 - is this what you want to store?

Where are you going to store these times?
How many times do you need to store?
What is your level of experience with code?
What language will this use?

I hope you're better at coding than asking questions.

Mike.
 
You need to answer the (4) questions rather than just repeat the same meaningless statement.

Mike.
 
Where are you going to store these times?
How many times do you need to store?
What is your level of experience with code?
What language will this use?
I want to store value in variable like
I want to count continousely
I have basic knowledge of c Programming
I know the c programming
 
You will need a pic with terrabytes of memory and they don't exist.

Mike.
 
You will need a pic with terrabytes of memory and they don't exist.

Mike.
It would be possible to just measure first time interval then display on screen for 2 second and
then again measure second time interval then display on screen for 2 second just repeat the process continousely
 
You've finally given some information that means something.
Two seconds equals 100/120 periods. If you store them in microseconds then 16 bits per variable will work.
That means you need 200 or 240 bytes of ram.
You will probably need twice that so you can double buffer the data.

Mike.
 
I found in my search that I can use capture mode i to capture the value of Timer 1 when a signal at the CCP pin goes high or low depending on how the CCP is set up. The CCP can accurately capture the arrival time of a signal at the CCP pin. Can I use CCP module to measure time at input signal ?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…