89c51 32-bit Math calculation

1. 32bit div 32bit for 8051

Hi friends,
please, help me for a math problem, i need to calculate:-

(55299539) / ((a*100 + b)*61375 +c)

where a = 0 to 8
b= 0 to 100
c = 0 to 61375

using 89c51 assembly progrmming. what algorithm should i use?
can anyone please provide me a code?

thank you.

2. bit math

http://www.8052.com/codelib.phtml

Has some very nice code snippits. In your case I'd examine this library a bit closer:

http://www.8052.com/codelib/math8051.asm

It has 8, 16 and 32 bit subtraction, multiplication, and division (signed and unsigned). Has good comments, should be worthwile...

Happy coding!

•

3. rpm 60 pulses per revolution 8052

Hi
It's very simple.
Copy your function into new project in C compiler as Keil, IAR...
Unassembly for code.

4. 89c51 basic registers

As all numbers in your eqasion are decimal and the microcontroller will perform calculations on HEX numbers you will have to convert these numbers from decimal to HEX.
With numbers up to 255d there is no problem ( a and b).
With big costance such as 55299539 you can use windows calculator and convert them to HEX:
55299539 d = 03h 4Bh 0CDh 0D3h
61375 d = 0EFh 0BFh
But for c you will need DEC to HEX converter subroutine. Try to find it somewhere, if not I did it some time before and you can have it..
Having these numbers converted try to find 40-bit/24bit division, but first you will have to calculate the value in brackets using 32-bit MUL and SUM subroutines..
Little bit long but not impossible..

•

5. 32 bit math routine for 8051

"Ianp" i think i need routines for 32-bit division also. actually i want to design a rpm meter (tachometer) ranging from 1 rpm to 10000 rpm. i'm planning to use 11.0592mhz xtal, and a disc mounted on motor shaft having one hole with IR encoder-decoder . for this if i run counter between two succesive pulses i obtain maximum readibilty of 843.4 rpm, any speed slower than this will make the counter overflow. so for 1 rpm i plan to make cascading with two more registers (R1, R0 one upto 100 and other upto 8 ) , which increments after each overflow then second register increments. so,
60 * 1000000 * 1000
------------------------------------------------------------- = rpm
[(R0*100 + R1) * 61444 + Counter0] * 1085

Thanking You in Anticipation.

6. math functions for 89c51

For motor RPM you don't need very complicated calculatons..
First you need 60sec time base and I don't want to repeat this issue once more; you will find it in this forum under "1 second Interrupt from 8051?" (search "1s AND 8051")
Once you have the 1s time base multiply it by 60 for 1min. For 1rpm you will need at least 1m time base..
And now just count pulses from the motor shaft..
The count of pulses over 1m is the RPM.
You will need 2 registers to obtain the 10000 mark..
So the mathematical operations involved are:
SUM to calculate Time Base
SUM to count pulses.

7. calculation of timer for 89c51

An option (more expensive):

Pulse from encoder -> frequency to voltage (IC, e.g.VFC320 from TI/BurrBrown) -> ADC -> 8051

8. bit revolution calculation

Thanks a lot for replying. "Ianp" i think the method you told is no doubt very correct, but i think the refreshing rate would be 1 minute which would be to slow. right? and the error could increase upto 1 rpm !!!

•

9. code 89c51 calculator

You can do it every 0.1s, 1s etc. and mulitply result by 600, 60 ....

Insread o having only 1 hole in your encoder you can have 2,3,4,.. holes and this will give you several pulses per revolution.
Of-the-shelf rotary encoders have 100, 200, .. , 1000+ ppr so the error is reduced to acceptable minimum..

--[[ ]]--