Searching \ for '[PIC] newbie question on timing' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/begin.htm?key=pic
Search entire site for: 'newbie question on timing'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] newbie question on timing'
2005\11\28@144349 by R. I. Nelson

picon face
part 0 44 bytes
his is a multi-part message in MIME format.
part 1 253 bytes content-type:text/plain; charset=ISO-8859-1; format=flowed (decoded 7bit)

Using a basic compiled program using a for-next loop,  a flash PICchip.  
can I expect toget a pulse every 55 ms. or about 18pulses per second?

I know a lot of it will depend on what speed I am running the chip at.



part 2 391 bytes content-type:text/x-vcard; charset=utf-8;
(decoded 7bit)

begin:vcard
fn:Robert I. Nelson
n:Nelson;Robert I.
org:RIN Designs
adr:;;P.O. BOX 373;RIPON;WI;54971;USA
email;internet:spam_OUTrindesignsTakeThisOuTspamcharter.net
tel;work:1-(920)-229-7152
tel;home:1-(920)-748-7443
note;quoted-printable:Custom design and building of small electro mechanical devices.=0D=0A=
       AUTOCAD work ver2002
x-mozilla-html:FALSE
version:2.1
end:vcard



part 3 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

2005\11\28@145952 by James Humes

picon face
There is a lot more to think about than just the oscillator speed.  How
precise do you need this pulse?  Can you post the for loop?  Do you have its
disassembly listing?  What is your oscillator frequency?
What PIC part are you using?

James


On 11/28/05, R. I. Nelson <.....rindesignsKILLspamspam@spam@charter.net> wrote:
>
> Using a basic compiled program using a for-next loop,  a flash PICchip.
> can I expect toget a pulse every 55 ms. or about 18pulses per second?
>
> I know a lot of it will depend on what speed I am running the chip at.
>
>
>
>

2005\11\28@150401 by John J. McDonough

flavicon
face
Even more than the speed you run the PIC at, the compiler makes a big
difference.

Some BASIC implementations compile the program to a bytecode that is stored
in the EEPROM and interpreted by code running in the PIC.  This is obviously
orders of magnitude slower than true compiled code.

Once you have figured out that you have actual compiled code, you can still
change the performance by orders of magnitude depending on how competent the
compiler is.  However, if the PIC were running in the megahertz range, and
the compiler was 'pretty good', I would expect you could flash the LED at a
kilohertz kind of rate.  If your PIC had a 4 MHz or igher clock, and you did
nothing in the loop besides turn the LED on and off, I would not expect you
could see the LED flash unless the compiler was very poor.

Obviously, you could choose to clock the PIC at 32 kHz instead of 20 MHz,
and that would make a huge difference.  And the compiler could be lame,
and .... and .... and ...

--McD

{Original Message removed}

2005\11\28@150743 by Maarten Hofman

face picon face
> Using a basic compiled program using a for-next loop,  a flash PICchip.
> can I expect toget a pulse every 55 ms. or about 18pulses per second?
>
> I know a lot of it will depend on what speed I am running the chip at.

Yes, and on the BASIC compiler.

Let me see, hypothetically (non working code, just counting a bit):

FOR A = 0 TO 255
PORTC = PORTC & 254
PORTC = PORTC | 1
NEXT A

; FOR A = 0 TO 255
 movlw 0
 movwf A
 goto NEXT1002
NEXT1001
 movlw 255
 xorwf A,w
 btfsc STATUS,Z
 goto NEXT1003
 incf A,f
NEXT1002
; PORTC = PORTC & 254
 movlw 254
 andwf PORTC,f
; PORTC = PORTC | 1
 movlw 1
 iorwf PORTC,f
; NEXT A
 goto NEXT1001
NEXT1003

Which indicates there are 4 cycles of setup and 11 cycles per loop.
Given a not unreasonable clock frequency of 4 MHz, that means you get
a pulse every 11us, so about 90909 pulses per second.

As said, this highly depends on the clock frequency, but also on the
BASIC compiler (the code could be further optimized using
incfsz/decfsz, which would make it faster. Or the BASIC compiler
outputs more generic code, allowing values greater than 255, which
would make things slower... Also if it would allow full expressions in
the FOR loop this might add superfluous dummy variables, slowing
things down).

But 90909 pulses per second seems a lot closer to reality than 18. If
you DO want 18 pulses per second, you might need to add a suitable
PAUSE command, of known duration.

Greetings,
Maarten Hofman.

2005\11\28@161626 by Mike Hord

picon face
> Using a basic compiled program using a for-next loop,  a flash PICchip.
> can I expect toget a pulse every 55 ms. or about 18pulses per second?
>
> I know a lot of it will depend on what speed I am running the chip at.

Wow.  As open ended a question as I've ever seen.

There are literally hundreds of ways to solve this.  In Basic, though, you
will have a much harder time than just sussing out how to do it in
assembler.  Best is if your Basic compiler lets you drop inline assembly
into your code (see the Asm/EndAsm directives in PicBasic).

Have you considered setting up an interrupt to occur?  55 ms should be
well within the grasp of most timer based interrupts, and then you don't
need to worry about timing once you've started it up.

What do you need to do?

Mike H.

2005\11\28@165507 by James Newton, Host

face picon face
That has got to be one of the finest, most detailed, accurate and complete
answers to an open ended newbie question that I have ever seen.

---
James Newton: PICList webmaster/Admin
jamesnewtonspamKILLspampiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com

> {Original Message removed}

2005\11\29@063026 by Bill & Pookie

picon face
Not sure where you get the 55ms from, but 55ms/18hz is the timer interrupt
frequency of the PC (personal computer) and should not have any effect on
pic except for maybe reading or writing to the pic from the PC.  It is a PC
thing.

Bill

{Original Message removed}

2005\11\29@121641 by William Chops Westfield

face picon face
>> Using a basic compiled program using a for-next loop,  a flash
>> PICchip.
>> can I expect toget a pulse every 55 ms. or about 18pulses per second?
>>
If your question boils down to "can a PIC, programmed with a compiler,
execute a typical program loop at least 18 times per second", the answer
is almost certainly yes.  In general, it's annoying to slow things down
that much; taking several nested empty loops if your loop counters are
only 8 bits.  Something like

       for I = 0 to 255
       next I

PROBABLY takes on the order of 5 mS (assuming: 20 instructions per loop,
1uS per instruction.  A GOOD compiler should do much better.)

Slower if you do floating point, of course :-)

BillW

2005\11\29@152657 by R. I. Nelson

picon face
part 0 44 bytes
his is a multi-part message in MIME format.
part 1 1089 bytes content-type:text/plain; charset=ISO-8859-1; format=flowed (decoded 7bit)

55ms (or 55.55555ms to be more exact)  is about 18 pulses per second.

Bill & Pookie wrote:

> Not sure where you get the 55ms from, but 55ms/18hz is the timer
> interrupt frequency of the PC (personal computer) and should not have
> any effect on pic except for maybe reading or writing to the pic from
> the PC.  It is a PC thing.
>
> Bill
>
> {Original Message removed}

2005\11\30@195137 by Dave Tweed

face
flavicon
face
R. I. Nelson <.....rindesignsKILLspamspam.....charter.net> wrote:
> Bill & Pookie wrote:
> > R. I. Nelson <EraseMErindesignsspam_OUTspamTakeThisOuTcharter.net> wrote:
> > > Using a basic compiled program using a for-next loop, a flash PICchip.
> > > can I expect to get a pulse every 55 ms. or about 18pulses per second?
> >
> > Not sure where you get the 55ms from, but 55ms/18hz is the timer
> > interrupt frequency of the PC (personal computer) and should not have
> > any effect on pic except for maybe reading or writing to the pic from
> > the PC.  It is a PC thing.
>
> 55ms (or 55.55555ms to be more exact)  is about 18 pulses per second.

Actually, if you're trying to emulate a PC, it's 18.2065096768466
pulses/sec, or 54.9254095238095 ms period. Convenient numbers, huh? :-)

It's derived from the original PC CPU clock, which was a standard
14.31818 MHz crystal divided by three to generate 4.772727 MHz.
This was subsequently prescaled by a factor of four and then divided
by 65536 in a timer chip to generate the 18.2 Hz "tick" interrupt.

If you want 55.55555 ms, that's *exactly* 18 pulses/second.

-- Dave Tweed

2005\11\30@202633 by Russell McMahon

face
flavicon
face
>> 55ms (or 55.55555ms to be more exact)  is about 18 pulses per
>> second.

> ... 4.772727 MHz.

which was chosen because that's the NTSc color burst frequency and the
crystals are cheap.

> If you want 55.55555 ms, that's *exactly* 18 pulses/second.

In engineering at least, 'about' includes 'exactly' :-)



               RM

2005\11\30@232954 by Dave Tweed

face
flavicon
face
Russell McMahon <apptechspamspam_OUTparadise.net.nz> wrote:
> I wrote:
> > > 55ms (or 55.55555ms to be more exact)  is about 18 pulses per
> > > second.
>
> > ... 4.772727 MHz.
>
> which was chosen because that's the NTSc color burst frequency and the
> crystals are cheap.

Nope. The NTSC color-burst frequency is 3.579545 MHz, which is
14.31818 MHz divided by four, not three.

The PC used the 14.3 MHz crystal partly because it was cheaply available
as a result of its wide use in the TV industry, and partly because the
early video cards wanted to be compatible with TV monitors. The early
8088s could run at up to 5 MHz, and they figured 4.77 MHz was "close
enough" without requiring a separate oscillator.

> > If you want 55.55555 ms, that's *exactly* 18 pulses/second.
>
> In engineering at least, 'about' includes 'exactly' :-)

Yes, but I was emphasizing the point that this rate is not the PC's rate
of 18.2 Hz. I wasn't sure if that's what the OP was looking for or if he
cared about the difference.

-- Dave Tweed

2005\11\30@235055 by Bill & Pookie

picon face
Coppied the origional posting.  I didn't know where he got the 55ms nor why
he thought it would be important.  So I mentioned the PC's 55ms thing.

Bill

{Original Message removed}


'[PIC] newbie question on timing'
2005\12\01@150615 by James Humes
picon face
oops   PAL is 4.19MHz..

James


On 12/1/05, James Humes <@spam@james.humesKILLspamspamgmail.com> wrote:
{Quote hidden}

>

2005\12\01@150809 by James Humes

picon face
On 11/30/05, Russell McMahon <RemoveMEapptechTakeThisOuTspamparadise.net.nz> wrote:
>
> >> 55ms (or 55.55555ms to be more exact)  is about 18 pulses per
> >> second.
>
> > ... 4.772727 MHz.
>
> which was chosen because that's the NTSc color burst frequency and the
> crystals are cheap.


   I thought that was PAL.

James

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...