# Genie E18 calculation problem

#### wildnwackywill10

Oct 30, 2011
2
I am currently doing A - Level technology and i am using a genie microcontroller (Genie E18), i am building a bottle sorter which will sort different coloured bottles into their specific bins; part of the code required for the sensor to detect different bottle colours is

VBCC = (VoC - VoB) / (VoW - VoB) * 255
VOC being a variable reading for a specific bottle
and VOB and VOW being constant calibrations

an example of this code is

VBCC =(125 - 50)/(180 - 50)*255
which gives
VBCC= 147.11

the problem arises whenever the genie attempts to do this equation, the only two answers it ever provides is VBCC= 255 or VBCC= 0
This is due to the genie rounding the part of the equation (VoC - VoB) / (VoW - VoB) to either 1 or 0.
To overcome this i came up with a modification to this equation which ended up with the same number but it meant that i didnt have to rely on long decimal places to ensure an an accurate answer, instead this included the equation going a lot over 255 and then dividing it down, as of now the exact equation eludes me but the point is that the genie uses 8 bit registers and to go over 255 is not possible, i have been informed by an electronic engineer that in the industry registers can be combined to form 16 bit registers, as of now i can't see how i would do this, can anyone please advise?

Replies
10
Views
208
Replies
0
Views
718
Replies
1
Views
2K
Replies
1
Views
1K
Replies
1
Views
1K