0
$\begingroup$

The timer in my micro-controller is running at 25Mhz. I need to program the hardware timer such that it counts for 6400 rpm. This means 6400 times on bit '1' in 60 seconds. So in 1 seconds it is 1 seconds 6400/60 rotations. Now, I want to achieve this so that hardware timer has 6400/60 times bit 1 in 1 seconds. Thus, the timer should count till 6400/60 if the timer was running at 1 Hz. However, the timer is running at 25 * 10^6 Hz .How can I count 6400/60 here. If I calculate it comes to 6400 * 25 * 10^6 /60 which is a very high value. I cannot program this value on to my hardware timer register. Is my logic correct? Can you please help me on the reasoning here.

$\endgroup$
0
$\begingroup$

You have $6400\frac{round}{minute}=6400\frac{round}{60\ seconds}$. These has to be produced by $25\cdot 10^6\frac{round}{second}$. Then you must divide the micro-controller $\frac{round}{second}$ figure into $\frac{6400}{60}\frac{round}{second}$ equal parts. This makes $$ \text{tick-interval}=\frac{60\cdot 25\cdot 10^6}{6400}=234,375 $$ That's it.


To verify the answer, we have found that the micro-controller runs $$ 60\cdot 25\cdot 10^6=1,500,000,000\text{ cycles pr. minute} $$ and in steps of $234,375\text{ cycles}$ we see that $6400$ counts make $$ 6400\cdot 234,375=1,500,000,000\text{ cycles} $$ thus lasting exactly one minute.

$\endgroup$
  • $\begingroup$ See required is 6400, but it is running at 25 10^6 *60.Thus, divide the running one with 25 10^6 and multiply by 6400. Am I correct? $\endgroup$ – dexterous_stranger May 14 '14 at 9:51
  • $\begingroup$ @SHREYASJOSHI: It is not correct to multiply by $6400$ when you want $6400$ parts. The word parts is italic here to underpin that you divide into parts. Thus division by $6400$ must be involved in any rendering of the solution. $\endgroup$ – String May 14 '14 at 9:56
  • $\begingroup$ Hey it is running as in 1 seconds there are 25 * 10 ^6 counts. However, I want 6400 / 60 counts in 1 seconds. How can I do so. The answer should be divide the current running tick with the same value to get unity and then multiply by 6400 / 60. Thus,it should be 6400/60 * 1/25 * 10^6. Isn't it? $\endgroup$ – dexterous_stranger May 14 '14 at 10:00
  • $\begingroup$ @SHREYASJOSHI:There is somehow a brain teaser about the concept of division and multiplication here. See my last edit. If you line up the $1,500,000,000$ cycles that the micro-controller runs pr. minute and divide those into $6400$ equal parts of length $234,375$ it all adds up. I hope this helps, after all! I am not trying to confuse you, but merely trying to do my best at explaining it. Which is hard when my image of it seems so clear to me, yet I can perfectly see how your wording of it is misleading you ... $\endgroup$ – String May 14 '14 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.