Page 5 of 6

Re: Timer Calculator Application Released!

Posted: 13 Sep 2013 13:33
by marina.petrovic
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

Re: Timer Calculator Application Released!

Posted: 16 Sep 2013 07:55
by tyzanu
This version I used above.

Re: Timer Calculator Application Released!

Posted: 23 Sep 2013 12:03
by Dany
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!

Re: Timer Calculator Application Released!

Posted: 28 Sep 2013 16:44
by aCkO
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

Re: Timer Calculator Application Released!

Posted: 30 Sep 2013 14:58
by filip
Hi,

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

Regards,
Filip.

Re: Timer Calculator Application Released!

Posted: 09 Oct 2013 11:13
by ISL_Dave
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.

Re: Timer Calculator Application Released!

Posted: 09 Oct 2013 11:34
by corado
this it it, how it should work!

Re: Timer Calculator Application Released!

Posted: 09 Oct 2013 11:42
by ISL_Dave
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).

Re: Timer Calculator Application Released!

Posted: 09 Oct 2013 13:24
by corado
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...

Re: Timer Calculator Application Released!

Posted: 20 Nov 2013 01:29
by irenepeter99
: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

Re: Timer Calculator Application Released!

Posted: 20 Nov 2013 14:00
by filip
Hi,

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

Regards,
Filip.

Re: Timer Calculator Application Released!

Posted: 20 Nov 2013 23:55
by irenepeter99
:(
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

Re: Timer Calculator Application Released!

Posted: 11 Mar 2014 01:30
by MARIO
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 138423 times
Correct:
Timer calculator 2.7.0.0.PNG
Timer calculator 2.7.0.0.PNG (39.67 KiB) Viewed 138423 times

Re: Timer Calculator Application Released!

Posted: 11 Mar 2014 09:24
by filip
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.

Re: Timer Calculator Application Released!

Posted: 11 Mar 2014 13:26
by MARIO
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. :)