Timer Calculator Application Released!

Timer Calculator is a free software development tool used for easier calculation of timer interrupts.
Author
Message
User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: Timer Calculator Application Released!

#61 Post by marina.petrovic » 13 Sep 2013 13:33

Hi,

You can choose ATXMEGA microcontrolers in Timer Calculator software.

Please, download the latest version of Timer Calculator from LibStock Website:
http://www.libstock.com/projects/view/3 ... calculator

Best regards,
Marina

tyzanu
Posts: 182
Joined: 21 Aug 2011 17:27
Contact:

Re: Timer Calculator Application Released!

#62 Post by tyzanu » 16 Sep 2013 07:55

This version I used above.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Timer Calculator Application Released!

#63 Post by Dany » 23 Sep 2013 12:03

Solved in version 2.6.0.

Hi, I have a question about the results presented by the Timer calculator:

Following is a calculation for a PIC18, 40 Mhz clock frequency, timer0 and 100 ns time (I know, extreme case).
The tool shows the following:

Code: Select all

//Timer0
//Prescaler 1:1; TMR0 Preload = 254; Actual Interrupt Time : 100 ns
 
//Place/Copy this part in declaration section
void InitTimer0(){
  T0CON	 = 0xC8;
  TMR0L	 = 0xFE;
  GIE_bit	 = 1;
  TMR0IE_bit	 = 1;
}
 
void Interrupt(){
  if (TMR0IF_bit){ 
    TMR0IF_bit = 0;
    TMR0L	 = 0xFE;
    //Enter your code here
  }
} 
Since the prescaler ia 1:1 the timer input frequency is 10 Mhz (40/4), which makes a timer steptime of 100 ns, so for 100 ns total time only 1 step is needed.

However, the calculated value (0xFE) shows 2 timer steps to interrupt:
0xFE to 0xFF and 0xFF to 0x00, giving a total time of 200 ns in stead of 100 ns.

Since the interrupt occurs on reaching the value 0x00 (overflow of the timer) I would expect a re-load value of 0xFF, which would produce 1 step to interrupt:
0xFF to 0x00, obtaining a total time to interrupt of 100 ns.

Can you have a look at this or explain please?
Thanks in advance! :D :D

By the way: great and versatile tool!
Last edited by Dany on 09 Oct 2013 17:03, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: Timer Calculator Application Released!

#64 Post by aCkO » 28 Sep 2013 16:44

Hi Dany,

Timer Calculator is still using the wrong formula for interrupt time calculation:

Code: Select all

                 f * t
TMR0 = 255  -  ---------
                4 * PS

TMR0 = 255 - 40 * 0.1 / 4 = 254
This is wrong in many ways:

1. Mathematically - because f, t and PS cannot be zero, hence the minimum value for f * t / (4 * PS) is 1:

Code: Select all

min(f * t / (4 * PS)) = 1   =>   max(TMR0) = 255 - 1 = 254
which is the result you got and we all know that max(TMR0) should be 255.

2. Logically - because the interrupt event occurs on 255-0 transition


The correct formula is:

Code: Select all

                 f * t
TMR0 = 256  -  ---------
                4 * PS
Regards

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Timer Calculator Application Released!

#65 Post by filip » 30 Sep 2013 14:58

Hi,

Thank you for this analysis, I have passed this to our developers.

Regards,
Filip.

ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

Re: Timer Calculator Application Released!

#66 Post by ISL_Dave » 09 Oct 2013 11:13

Thanks, have downloaded it but still find the data sheet more useful in calculating times because every time I enter a value I wish to calculate, I get an error telling me it is not possible to calculate it.

I used to have another timer calculator that was really useful because it told me the nearest it could get to the value I wanted and allowed me to change parameters and see the effects real time.

I am looking to have a delay between 1 and 2 second and if I select my micro, clock and a timer, entering 1.6 tells me the value for interrupt time is too low? Entering 1.7 tells me there is no solution.
How can the value be too low when I actually know it is too high.

It seems that virtually every value I try produces an error rather than telling me how close it can get to my desired value.

Oh well, back to the data sheet for me.

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: Timer Calculator Application Released!

#67 Post by corado » 09 Oct 2013 11:34

this it it, how it should work!

ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

Re: Timer Calculator Application Released!

#68 Post by ISL_Dave » 09 Oct 2013 11:42

just saying if I wanted a 60mS timer, it would be nice for the program to tell me it cannot do it and the highest it can give me is 53mS rather than telling me the value I have entered for the interrupt time is too LOW, especially when it I have actually entered a value that is too HIGH for it.

That way I could decide that I would set the interrupt time to 30mS and look for the ISR being serviced twice.

SUGGESTION: How about an additional feature which gives you the interrupt time period range that is possible for the selected parameters. I used to always calculate this and scribble it on the data book (back in the days of paper data books).

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: Timer Calculator Application Released!

#69 Post by corado » 09 Oct 2013 13:24

I know there is a freeware that can do this in this way!! But I don't know where it ist :-(
This has exactly what you and I want!
But i hope Microe can do it the same way...

irenepeter99
Posts: 2
Joined: 20 Nov 2013 00:59

Re: Timer Calculator Application Released!

#70 Post by irenepeter99 » 20 Nov 2013 01:29

:D
I use AVR atmega128, and the timer calculator is a good tool, but I have discovered that TimerCounter0 uses prescaler values up to 7 (for divide by 1024). Shown here are times to counter overflow :

Hz time
' CK0_STOP = 0
' CK0_DIV1 = 1 ' 62500 16 us
' CK0_DIV8 = 2 ' 7812 128 us
' CK0_DIV32 = 3 ' 1953 512 us
' CK0_DIV64 = 4 ' 976 1 ms
' CK0_DIV128 = 5 ' 488 2 ms
' CK0_DIV256 = 6 ' 244 4.1 ms
' CK0_DIV1024 = 7 ' 61 16.4 ms

Because timer calculator uses wrong pre-scale values, the code generated must be changed to get wanted times.

Just for everybodies information

Keep up the great work

Thanks, Peter

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Timer Calculator Application Released!

#71 Post by filip » 20 Nov 2013 14:00

Hi,

Thank you for this observation, I will notify our developers.

Regards,
Filip.

irenepeter99
Posts: 2
Joined: 20 Nov 2013 00:59

Re: Timer Calculator Application Released!

#72 Post by irenepeter99 » 20 Nov 2013 23:55

:(
To update my last, I was using generic ATMEGA x Timers, and this is where my problems happened, missing 6 and 7 prescaler values.

I now find ATMEGA64(A)(L)/128(A), and with this the prescalers is correct.

Was a bit confusing to find, but my fault, and you're GOOD !

Thanks to the developers

Peter

MARIO
Posts: 978
Joined: 18 Aug 2008 22:13
Location: Brasil

Re: Timer Calculator Application Released!

#73 Post by MARIO » 11 Mar 2014 01:30

There is a minor bug on Timer Calculator 2.7.0.0.
I know the use of such low clock frequencies is unusual, but I discovered it when I was testing a project where power saving is important.

The MCU clock frequency values less than 1MHz has a dot as a decimal separator and it causes error. It should be a comma.

Incorrect:
Timer calculator 2.7.0.0 error.PNG
Timer calculator 2.7.0.0 error.PNG (42.33 KiB) Viewed 138308 times
Correct:
Timer calculator 2.7.0.0.PNG
Timer calculator 2.7.0.0.PNG (39.67 KiB) Viewed 138308 times
BR
EasyPic6 and registered mkC PRO FOR PIC since 2011
You're never too old to learn something stupid.(PARAPROSDOKIAN)

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Timer Calculator Application Released!

#74 Post by filip » 11 Mar 2014 09:24

Hi,

Well, the comma or dot using convention differs from language to language.
The English-speaking world uses comma to separate a group of three digits and dot as a decimal point, while the others use this in reverse.

This is why you will get an error if you use comma as a decimal point.

Regards,
Filip.

MARIO
Posts: 978
Joined: 18 Aug 2008 22:13
Location: Brasil

Re: Timer Calculator Application Released!

#75 Post by MARIO » 11 Mar 2014 13:26

Hi filip.

I agree and I know that.
filip wrote:This is why you will get an error if you use comma as a decimal point.
No, I'm getting an error if I use a dot (default) not comma(typed). See the pictures again.

But we have to consider 3 things:

1. Or the program is independent of the OS language or
2. It should adapt itself to the OS language, or
3. Some way to inform it which language will be used, independent of the OS language.

But it does not do any of them. At least that's what I think. Maybe I'm wrong.

I am only trying to help, not to complain, as it is a very nice tool and this is a very small issue. :)
BR
EasyPic6 and registered mkC PRO FOR PIC since 2011
You're never too old to learn something stupid.(PARAPROSDOKIAN)

Post Reply

Return to “Timer Calculator”