No real help, just a bit of smartassing... ;-)

On certain chips like PIC18fxxk22 or PIC18Fxxk42 (and probably some more) the 
timer can run on the full Fosc speed. That is up to 64MHz. So a resolution of 
around 16 nanoseconds is possible.  Of course the 16 bit timer then overflows 
after about one millisecond. You can reduce the resolution by prescaling, or 
catch the overflows using the timer interrupt to increase an additional 
counter. As JAL allows variables of up to 256 bytes, you can capture times of 
about 2.5*10^607 years, even at the full resolution. The universe exists since 
about 5*10^9 years, so that should suffice all needs.
Greets,Kiste
    Am Samstag, 5. September 2020, 09:55:03 MESZ hat Jesito's μFabLab 
<[email protected]> Folgendes geschrieben:  
 
 Many thanks Rob. I have to figure out how to do it. Is the timer working at 
the MCU clock speed?. If so the 16 bit value might be too small to hold the 
pulse length for i.e. a 5 sec pulse, isn't it?. I suppose some prescaling 
should be done there... Have to investigate and read more on that.Kind 
regards.Jes.


El jueves, 3 de septiembre de 2020 a las 18:51:51 UTC+2, [email protected] 
escribió:

Hi Jes,
I just checked but I was mistaken, there is a procedure that calculates a value 
for the timer based on a frequency.
If you want to measure the length of a pulse you can use the capture mode of a 
timer which is available in many PICs, for example the 16F1823.From the 
datasheet:Capture mode makes use of the 16-bit Timer1resource. When an event 
occurs on the CCP1 pin, the16-bit CCPR1H:CCPR1L register pair captures 
andstores the 16-bit value of the TMR1H:TMR1L registerpair, respectively. An 
event is defined as one of thefollowing and is configured by the CCP1M<3:0> 
bits ofthe CCP1CON register:• Every falling edge• Every rising edge• Every 4th 
rising edge• Every 16th rising edgeWhen a capture is made, the Interrupt 
Request Flag bitCCP1IF of the PIR1 register is set. The interrupt flagmust be 
cleared in software. If another capture occursbefore the value in the CCPR1H, 
CCPR1L register pairis read, the old captured value is overwritten by the 
newcaptured value.

Kind regards,
Rob
Van: [email protected] <[email protected]> namens Jes 
<[email protected]>
Verzonden: donderdag 3 september 2020 13:45
Aan: [email protected] <[email protected]>
Onderwerp: Re: [jallib] Some help needed to measure pulse length Thanks Rob, I 
look for it, just what I needed to know :0)
El jue., 3 sept. 2020 12:01, Rob CJ <[email protected]> escribió:

Hi Jes,I thought there is already a Jal library to measure the width of a pulse 
created by Matt. Would that do the job?
Met vriendelijke groet,Rob Jansen From:[email protected] 
<[email protected]> on behalf of Jesito's μFabLab <[email protected]>
Sent: Thursday, September 3, 2020 10:49:48 AM
To: jallib <[email protected]>
Subject: [jallib] Some help needed to measure pulse length Hello,I'm new to JAL 
and I would like to measure the length of some pulses that can be as long as 5 
sec and as short as 1/8000 of second.I have a handful of different pics, but 
ideally I would like to use a small one, I just need one pin for the pulse, two 
more to interface to an I2C small display and one more to reset and restart the 
measure.Could anyone point me to an example that could guide me through this?.I 
love the cleanless and simplicity of JAL.Thanks in advance.Jes.

-- 
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 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/29ca65ab-4f67-4e77-a321-9162fd396026n%40googlegroups.com.


-- 
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 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/AM0PR07MB62419C76A4D0F51F787AE7F5E62C0%40AM0PR07MB6241.eurprd07.prod.outlook.com.



-- 
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 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/CAJSrQ%3Df1Lm6tHoKCfC4LW68OcQgsKw5FUeGQgaKaiag5oKV8EA%40mail.gmail.com.



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/a079e103-5ea2-463a-b57d-53ad94caa730n%40googlegroups.com.
  

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/252643382.3502892.1599293709605%40mail.yahoo.com.

Reply via email to