# Multiplying two eight bit numbers numbers

cancel
Showing results for
Show  only  | Search instead for
Did you mean:

## Multiplying two eight bit numbers numbers

2,056 Views
Contributor III
I am reading two voltages into the A/D, and I want to multiply them.

For example, 1.5v x 1.5v = 2.25v

2.25 x 255/5 = 115 = \$72

1.5 x 255/5 = 77 = \$4C

\$4C x \$4C = \$1690 = 5776 = 76 x 76

How to get \$72 from \$1690?

Thanks
Labels (1)
• ### General

5 Replies
457 Views
Specialist I
multiply your product by 5, then divide by 255.

457 Views
Contributor III
Kef:

Lots of products, which one?
457 Views
Specialist I
I replied before you send your second post. I meant product \$4C x \$4C = \$1690. You asked how to get ~\$72 from \$1690. Answer is multiply it by 5, then divide by 255.

1.5V
----- * \$FF
5V

Similarily ADcode of 1.5V*1.5V=2.25V, with 5V reference is sort of this

1.5V*1.5V
------------- * \$FF
5V

What if we replace 1.5V in this expression with reverse expression

\$4C
-----*5V ~ 1.5V
\$FF

Full expression becomes

\$4C * 5V    \$4C * 5V         1
-----------  * ------------  *  ------ * \$FF
\$FF          \$FF            5V

or

\$4C * \$4C  * 5V
--------------------
\$FF

Message Edited by kef on 2008-12-25 01:34 AM

Message Edited by kef on 2008-12-25 01:35 AM
457 Views
Contributor III
Wow, that's great. I only worked on it for eight hours. (arg).
457 Views
Contributor III
Hooray, I got it. Tom Almay has a section on fractional scaling in his book that gave me the clue.

I'll post my code later. I ignored a couple of remainders, and maybe it could be simplified, but it's pretty close.

For those that want to work it out, convert the A/D reading into thousands of millivolts.

For an input of 1.5v = \$4D

(\$4D x \$1388)/\$FF = \$05D2 = 1490mv

If the other input is 2.75v = \$8C

(\$8C x \$1388)/\$FF = \$0AB9 = 2745mv

Then (\$05D2 x \$0AB9)/\$03E8 = \$0FFA

Then (\$0FFA x \$33)/\$03E8 = (tadaa)...\$D0...

Note that \$33 is \$FF/5

Takes a lot of EMUL and EDIV's. Good thing the HC08 I was going to use didn't have enough pins for the job.