Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx


Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | Piclist | Timing with the 18F458


Advertise Here

A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.

Timing with the 18F458 - Author Unknown - Jul 14 20:37:00 2004

Hey, I'm using an Accelerometer to measure velocity, so timing is
critical. Any ideas on how to keep accurate track of how long each
cycle of a loop runs? I would like to be as accurate as humanly
possible. I am using CCS and my code is as follows:

while( input(PIN_C2) ); // wait until low
while( !input(PIN_C2) ); // wait until high
while( input(PIN_C2) ) { // count high-time
high++;
}
while( !input(PIN_C2) ) { // count low-time
low++;
}

I want to know how much time has elapsed while it was doing those
counts.

Thanks for ANY help.
Shamoon



______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )


Re: Timing with the 18F458 - Robert Rolf - Jul 14 21:15:00 2004



wrote:
>
> Hey, I'm using an Accelerometer to measure velocity, so timing is
> critical. Any ideas on how to keep accurate track of how long each
> cycle of a loop runs? I would like to be as accurate as humanly
> possible. I am using CCS and my code is as follows:
>
> while( input(PIN_C2) ); // wait until low
> while( !input(PIN_C2) ); // wait until high
> while( input(PIN_C2) ) { // count high-time
> high++;
> }
> while( !input(PIN_C2) ) { // count low-time
> low++;
> }
>
> I want to know how much time has elapsed while it was doing those
> counts.
>
> Thanks for ANY help.

Having been there, you MUST use interrupts and CCP capture if you
want any kind of accuracy. Anything else will have too much
jitter to be usable. Change the interrupt edge to get
accurate rising and falling times off the freerunning counter,
and compute your width and period and then do the duty cycle.
If you're using the ADXLs
you MUST do full duty cycle computation. e.g. width over Period
since these sensors have significant temperature drift.

If absolute value is not important, PW is suffient, but it
will drift with temp. Absolute timing is not important
because every channel and device has a different zero point.

Robert






(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Timing with the 18F458 - Author Unknown - Jul 14 21:47:00 2004

Hello,
I am using the ADXL, and I am using the full period, by adding high
and low. How do I change the interrupt edge? Absolute timing will
help me calculate the velocity based on the acceleration. Do you
have any C code that could be useful?

Shamoon

--- In , Robert Rolf <robert.rolf@u...> wrote: > honamos@y... wrote:
> >
> > Hey, I'm using an Accelerometer to measure velocity, so timing is
> > critical. Any ideas on how to keep accurate track of how long
each
> > cycle of a loop runs? I would like to be as accurate as humanly
> > possible. I am using CCS and my code is as follows:
> >
> > while( input(PIN_C2) ); // wait until low
> > while( !input(PIN_C2) ); // wait until high
> > while( input(PIN_C2) ) { // count high-time
> > high++;
> > }
> > while( !input(PIN_C2) ) { // count low-time
> > low++;
> > }
> >
> > I want to know how much time has elapsed while it was doing those
> > counts.
> >
> > Thanks for ANY help.
>
> Having been there, you MUST use interrupts and CCP capture if you
> want any kind of accuracy. Anything else will have too much
> jitter to be usable. Change the interrupt edge to get
> accurate rising and falling times off the freerunning counter,
> and compute your width and period and then do the duty cycle.
> If you're using the ADXLs
> you MUST do full duty cycle computation. e.g. width over Period
> since these sensors have significant temperature drift.
>
> If absolute value is not important, PW is suffient, but it
> will drift with temp. Absolute timing is not important
> because every channel and device has a different zero point.
>
> Robert




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Timing with the 18F458 - Author Unknown - Jul 16 13:20:00 2004

How can I use interrupts with this to accurately gauge time so that
I can integrate with respect to time?

Shamoon

--- In , Robert Rolf <robert.rolf@u...> wrote: > honamos@y... wrote:
> >
> > Hey, I'm using an Accelerometer to measure velocity, so timing is
> > critical. Any ideas on how to keep accurate track of how long
each
> > cycle of a loop runs? I would like to be as accurate as humanly
> > possible. I am using CCS and my code is as follows:
> >
> > while( input(PIN_C2) ); // wait until low
> > while( !input(PIN_C2) ); // wait until high
> > while( input(PIN_C2) ) { // count high-time
> > high++;
> > }
> > while( !input(PIN_C2) ) { // count low-time
> > low++;
> > }
> >
> > I want to know how much time has elapsed while it was doing those
> > counts.
> >
> > Thanks for ANY help.
>
> Having been there, you MUST use interrupts and CCP capture if you
> want any kind of accuracy. Anything else will have too much
> jitter to be usable. Change the interrupt edge to get
> accurate rising and falling times off the freerunning counter,
> and compute your width and period and then do the duty cycle.
> If you're using the ADXLs
> you MUST do full duty cycle computation. e.g. width over Period
> since these sensors have significant temperature drift.
>
> If absolute value is not important, PW is suffient, but it
> will drift with temp. Absolute timing is not important
> because every channel and device has a different zero point.
>
> Robert


______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )