Hi all again.

With your ideas and code I'm writing a frequency meter.

From 0hz to 280 Mhz using various "prescalers" in conjunction (variable time of sampling + internal prescaler of TM1 + external prescalers)

The most interesting features is that it "will have" an "auto scale" feature, for make readings with the more exact method for the freq being measured (aka. minimizing the error for that freq)

But... (as always) I have a problem...

I need to BREAK the counting of a running _usec_delay() instruction from a interrupt routine...

I explain (code attached):

I start counting TMR1 pulses on RB6 for 1 sec time lapse, and with interrupts on the overflow of it I detect the need of jump on the "range / scale", then I change any of the sampling period, internal prescaler and/or external prescaler to suit the next scale and then you have a autorange freq. meter...

The problem is found when I measure a freq that is much BIGGER for the initial sampling period of 1s...

Think on it and dive in the code....

7110khz (7110000 pulses in ONE second) is around 108 interrupts in ONE second... so the autorange function goes crazy and get to the top of scale from overloaded interrupts per seconds...

The obvious solution is breaking the _usec_delay() instruction from the interrupt routine... that will require asm which I do not know... or another dirty trick...

But, Hey!... I realize NOW that using another timer for setting the sampling period can be the solution... (GGGGGRRRRR somebody suggest this before and I have not listen to it...)

Yes, forcing the timer of the sampling period to timeout an thereof ending the sampling period will be the way...

I will try that tomorrow, nevertheless, the code is attached, comments, suggestions, etc, will be welcomed...

I have the proteus project if anyone like to try it...

Just ignore the lcd for now and attach a serial console at 38_400 bauds to the PIC and see the debug info...

The code is a work in progress, no optimization or cleaning yet...

Cheers... and enjoy it

PS: Forgive my english if you found an error or two, I'm a spanish speaking person...

El 27/07/13 22:41, Ing. Pavel Milanes Costa escribió:
Hi all.

I'm here reading and searching but I can't find a way of counting
asynchronous TTL pulses with jal/jallib over a given time slot...

It must be done with the timer module of the pic... (I think...)

I explain:

I want to make a frequency counter for zero to 250 Mhz, with 2 external
prescaler, using direct counting for low freq's, med prescaler to about
50 Mhz and a dedicated prescaler for above 50 Mhz - 250 Mhz+

But I have not a clue how to use the timer1 as an asynconous 16 bit
pulse counter of the PIC16F88 I have for the project.

Output will be to a cheap 4bit LCD or UART serial to a PC, click will be
HS 20 Mhz XTAL...

Other candidate is a PIC16F628 in my junkbox.

Math is not a problem when I can say something like:

<pseudo-code>
a = count(pin_b1,100) -- count pulses on pin B1 for 100ms
</pseudo-code>

Any clue, sample code or tip is welcomed.

73 de CO7WT, Pavel in Cuba Island.


--
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/groups/opt_out.


Attachment: feq_counter_16F88_v3.0.jal
Description: application/wine-extension-jal

Reply via email to