Blob
Joined: 02 Jan 2006 Posts: 75 Location: Neeroeteren, Limburg, Belgium
|
converting RPM to address |
Posted: Thu May 22, 2008 6:02 am |
|
|
hello everyone,
my project is growing bigger and bigger, thanks for all the help so far.
As you may know, I am building a project that reacts on a rotating disc.
I have to measure the RPM of this disc. According to this measurement, I have pass some values to the output.
The user can define some values according to RPM in my own made pc software. then when the pic module is connected to the rotating disc. it measures the RPM and gives out the values that the user defined at the desired rpm. (steps of 50 rpm)
The values are stored in my pic memory.
addresses are linear:
1000
1001
1002
1003
1004
...
I use on pic 18f2520
the rotating disc has a tooth so i use this to capture an interrupt and i use
to calculate the address (rpm)
I have a calculation ready
Code: |
tNow = get_timer1();
tNow = tNow / 16;
adr = (int16)(46875 / tNow)
|
this makes my address going up and down by 1 if rpm goes up or down by 50.
Now i want to make this calculation as short as possible, as i need to do a lot of other things each rotation.
Since i have 2 divisions in my code (in fact only 1, /16 is just shifting the bits) but a division takes a lot of time on a pic and i wish to avoid this.
How many clock cycles will the get_timer3 take? i use this timer too...
thanks in advance,
BLOB |
|