PDA

View Full Version : PULSIN Resolution



cotang
- 17th November 2005, 03:27
The manual states that at 4Mhz the resolution is 10us. At 20Mhz it is at 2us. How fast do I need the clock to have a resolution of 1us?

Thanks.

Charles Linquis
- 17th November 2005, 06:08
40Mhz .

CocaColaKid
- 17th November 2005, 16:58
Silly question but how is that calculated?

cotang
- 17th November 2005, 19:28
Silly question but how is that calculated?

Actually that is NOT a silly question. I'm kinda carious myself.

Dwayne
- 17th November 2005, 19:39
My first thought would be in the time it takes to do the routine...

For example...The routine takes a certain amount of "Time" in us to execute. Thus your Pulsin resolution will take a certain amount of time to run through its routine before it can receive accurately the next pulse. If the routine takes 1000 us to read a pulse, then the maximum frequency it can read would be 1 pulse every 1 MS. which is 1000 hz. If you double the clock speed, your Pulse statement can read twice as fast, thus be able to read a pulse every 500 us... giving a 2000 hz speed max.



Dwayne

Dave
- 17th November 2005, 19:48
cotang, What statement in the book are you speaking of? If it is something like Pulsin, Rctime the resolution is based on the oscillator frequency and not the instructions being executed.

Dave Purola,
N8NTA

cotang
- 18th November 2005, 03:58
cotang, What statement in the book are you speaking of? If it is something like Pulsin, Rctime the resolution is based on the oscillator frequency and not the instructions being executed.

Dave Purola,
N8NTA

Its under the Picbasic pro manual where it defines Pulsin. Its states that for 4 mhz the pulse width returned is 10us. FOr 20mhz its is 2us. I tested it out and it correct, I just wondering how fast of a clock speed I need to get 1us or 0.5us resolution.

keithdoxey
- 18th November 2005, 08:59
I just wondering how fast of a clock speed I need to get 1us or 0.5us resolution.

I would guess 40MHz and 80MHz respectively.

Guess based on the fact that it must take a minumum number of cycles to execute and the product of Clock in MHz and Resolution in uS seems to remain contant eg

4 * 10 = 40
20 * 2 = 40

therefore

40 / 1 = 40
40 / 0.5 = 80

I also think that 8Mhz would give 5uS resolution

40 / 8 = 5

Dave
- 18th November 2005, 12:13
keithdoxey, 40 Mhz. is correct for getting 1uS resolution. However 80Mhz. would be a stretch for a PIC micro. If you need 1uS resolution why not use the internal timers available in the PIC and use atleast a 4Mhz. crystal? That will give you 1uS. resolution..

Dave Purola,
N8NTA

keithdoxey
- 18th November 2005, 13:09
However 80Mhz. would be a stretch for a PIC micro.

Hi Dave,

I realise that a PIC wont run at that speed....yet, but give them a couple of years and we will probably see devices that will run at 100MHz+.

Look at the way Intel and AMD clock speeds have shot up over the last few years!

Also look at how the available memory is increasing as well. PICs are getting evermore powerful

Regards

Security
- 28th December 2008, 16:36
Is there a way to make pulsin count slower?

Darrel Taylor
- 28th December 2008, 21:47
Athough it might be nice ...

There aren't any defines that would make PulsIn count slower.

A slower OSC freq makes it count slower, or you could create your own define that adds some NOP's to the library routine. (not recommended)

Might just be easier to create a simple subroutine to count the time in a loop, which is all PulsIn does anyway.
<br>