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.

Equally timed readings for frequency measurement

Status
Not open for further replies.

eng.7oka

Newbie level 3
Joined
Jun 4, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
I'm using the ADC of PIC18F452 to read a sound signal of freq around 70 Hz. My goal is to take the readings with a rate of at least 10 times and store them on an SD card for later use of data. I'm using a 20MHz OSC.

My problem is that I need to get the readings with a uniform (and known) sampling to be able to process the data later. I thought of using a timer and interrupt but that will make the readings slow.. any idea how to do that (know the exact timing between readings and insure it's at least 700Hz) ??

Thanks in advance
 

Hi,

If you look into the datasheet Chapter 17.5 Use of the CCP2 Trigger (at least in my copy) , you see that you can let the Timer trigger the conversion directly without invoking an interrupt. That would ensure a stable timing (as stable as your Oscillator permits) and save the overhead of calling the interrupt. Since the processor has no DMA you still have to copy the AD conversion results after the conversion finished.

Regards,
Andreas
 

I'm not sure I understand exactly what you mean. do you mean I should let CCP2 trigger the ADC every known time period? and wouldn't saving the results before starting a new conversion affect the uniformity of time??

Thanks for your reply
 

Yes, that was the idea. The timer in CCP2 can provide the timing for equally spaced samples. Since the sampling itself is triggered by the timer you don't have delays coming from the software (for triggering). After the value is sampled you have to copy it to another location though. That has to happen before the next conversion...

Why should the copying of the value affect the uniformity of time? If the ADC samples at times e.g. 0ms, 14.2ms, 18.4ms it does not matter when you copy the values inbetween these timeslots. The values are sampled and won't change till the next sampling is triggered.
 
Ok.. Check this simple logic for the problem:

loop for n samples:
set ccp2 trigger
store A/D result in an array
end loop

Now the time between samples is the time required to fill timer1 or 3 completely?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top