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

Discussion Groups | Piclist | PLEASE HELP ME WITH CLOCK CALCULATIONS IN PIC12F675

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.

Re: PLEASE HELP ME WITH CLOCK CALCULATIONS IN PIC12F675 - Paul James E. - Feb 18 23:57:00 2004


vaishnavi236,

Well first, the 12F675 does not have hardware PWM. It does have a Timer1
and Comparators, but no PWM. I can explain the functions of the bits in
T1CON, but that won't help the PWM situation, or more precisely, the lack
of it.

Secondly, you say you want TON = 10% and TOFF = 90%. What exactly is 'T'?

Lastly, what exactly are you trying to accomplish with this program?

Let me know what you want to do from here.

Regards,

Jim

> hello,
> i have selected the internal clock of 4 MHZ but i don't know
> how to calculate the word in T1CON in my program for pwm.
> PLEASE CAN U BRIEF ME WITH THE INSTRUCTION CYCLES,TIME ELAPSED AND
> DUTY CYCLE? i have to write a value into T1CON BUT I AM NOT ABLE TO
> CALCULATE......TON=10% AND TOFF=90% OF T, FOR LOW BATTERY CONDITION
> AND VICE VERSA FOR HIGH BATTERY CONDITION.PLEASE TEACH ME THE WHOLE
> CONCEPT BECAUSE ITS NOT VERY CLEAR >
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~--> Buy Ink Cartridges or Refill Kits for your
> HP, Epson, Canon or Lexmark Printer at MyInks.com. Free s/h on orders
> $50 or more to the US & Canada.
> http://www.c1tracking.com/l.asp?cid=5511
> http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/dN_tlB/TM
> ---------------------------------------------------------------------~->
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions Yahoo! Groups Links





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


PLEASE HELP ME WITH CLOCK CALCULATIONS IN PIC12F675 - vaishnavi236 - Feb 19 9:41:00 2004

hello,
i have selected the internal clock of 4 MHZ but i don't know
how to calculate the word in T1CON in my program for pwm.
PLEASE CAN U BRIEF ME WITH THE INSTRUCTION CYCLES,TIME ELAPSED AND
DUTY CYCLE? i have to write a value into T1CON BUT I AM NOT ABLE TO
CALCULATE......TON=10% AND TOFF=90% OF T, FOR LOW BATTERY CONDITION
AND VICE VERSA FOR HIGH BATTERY CONDITION.PLEASE TEACH ME THE WHOLE
CONCEPT BECAUSE ITS NOT VERY CLEAR





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

Re: PLEASE HELP ME WITH CLOCK CALCULATIONS IN PIC12F675 - Patrick Reitelbach - Feb 24 10:40:00 2004

The clock fed to the timers can be the system clock divided by four.
So with a 4MHz system clock the timers are clocked with a 1MHz
clock. This gives 1 microsecond per count.

What is the sum of TON and TOFF you are trying for (in time not
percentages)? One second total? Two seconds total??

You stated:
TMR1 will control the on time and TMR0 will control the off time.
HIGH BATTERY, TON = 90% and TOFF = 10%.
LOW BATTERY, TON = 10% and TOFF = 90%.

TMR1 is 16 bits wide. TMR0 is 8 bits wide.

Assume a 1 second display cycle rate then:

HIGH BATTERY = TON = 90% = 900,000 microseconds and TOFF = 10% =
100,000 us.
LOW BATTERY = TON = 10% = 100,000 us and TOFF = 90% =900,000 us.

Both of these values are out of the timers ranges.

You could use the prescalers to get the times closer but not exactly
what would be needed for a 1 second display cycle. Extending the
timers in software would provide a better fit.

Or just extend the counters in software and not use the prescalers.
Your choice.

AN863 has an example of exending timers. TMR0 is extended to a 16
bit timer.

You can see that the LED display cycle rate you want really drives
what you need to do to accomplish your goal.

Be sure to save the OSCCAL value as described in the data sheet
section 9.2.5.

pr --- In , "vaishnavi236" <vaishnavi236@y...>
wrote:
> hello,
> i have selected the internal clock of 4 MHZ but i don't know
> how to calculate the word in T1CON in my program for pwm.
> PLEASE CAN U BRIEF ME WITH THE INSTRUCTION CYCLES,TIME ELAPSED AND
> DUTY CYCLE? i have to write a value into T1CON BUT I AM NOT ABLE TO
> CALCULATE......TON=10% AND TOFF=90% OF T, FOR LOW BATTERY CONDITION
> AND VICE VERSA FOR HIGH BATTERY CONDITION.PLEASE TEACH ME THE WHOLE
> CONCEPT BECAUSE ITS NOT VERY CLEAR





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

Re: PLEASE HELP ME WITH CLOCK CALCULATIONS IN PIC12F675 - Phil - Feb 24 11:35:00 2004

it seems to me an easier way to do this is to use a single timer (t0
wold be my choice). Set it up to interrupt at 1 mS intervals and
then just count ticks. for an 8 bit timr (tmr0), you would use 5 as
the start and a prescalar of 4 on a 4 mhz machine. 900 for 90%, 100
for 100%.

I've used the following concepts for timing that work pretty well for
me: timer ISR simply decrements a memory location. The main loop
sets the timer count and then waits for it to go to zero.

You could prescale at higher values to get approximately 10mS
interrupts and thus just do single byte math but you will be slightly
off. For example prescale by 64 (option reg Ps2:Ps0 of 101) and use
99 (255-156) as the tmr0 value to get a 9.984 mS period. For most
apps this would be close enough (.16% off).

--- In , "Patrick Reitelbach"
<preitelbach@y...> wrote:
> The clock fed to the timers can be the system clock divided by
four.
> So with a 4MHz system clock the timers are clocked with a 1MHz
> clock. This gives 1 microsecond per count.
>
> What is the sum of TON and TOFF you are trying for (in time not
> percentages)? One second total? Two seconds total??
>
> You stated:
> TMR1 will control the on time and TMR0 will control the off time.
> HIGH BATTERY, TON = 90% and TOFF = 10%.
> LOW BATTERY, TON = 10% and TOFF = 90%.
>
> TMR1 is 16 bits wide. TMR0 is 8 bits wide.
>
> Assume a 1 second display cycle rate then:
>
> HIGH BATTERY = TON = 90% = 900,000 microseconds and TOFF = 10% =
> 100,000 us.
> LOW BATTERY = TON = 10% = 100,000 us and TOFF = 90% =900,000 us.
>
> Both of these values are out of the timers ranges.
>
> You could use the prescalers to get the times closer but not
exactly
> what would be needed for a 1 second display cycle. Extending the
> timers in software would provide a better fit.
>
> Or just extend the counters in software and not use the
prescalers.
> Your choice.
>
> AN863 has an example of exending timers. TMR0 is extended to a 16
> bit timer.
>
> You can see that the LED display cycle rate you want really drives
> what you need to do to accomplish your goal.
>
> Be sure to save the OSCCAL value as described in the data sheet
> section 9.2.5.
>
> pr > --- In , "vaishnavi236" <vaishnavi236@y...>
> wrote:
> > hello,
> > i have selected the internal clock of 4 MHZ but i don't
know
> > how to calculate the word in T1CON in my program for pwm.
> > PLEASE CAN U BRIEF ME WITH THE INSTRUCTION CYCLES,TIME ELAPSED
AND
> > DUTY CYCLE? i have to write a value into T1CON BUT I AM NOT ABLE
TO
> > CALCULATE......TON=10% AND TOFF=90% OF T, FOR LOW BATTERY
CONDITION
> > AND VICE VERSA FOR HIGH BATTERY CONDITION.PLEASE TEACH ME THE
WHOLE
> > CONCEPT BECAUSE ITS NOT VERY CLEAR




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