Connect with us

Genie E18 calculation problem

Discussion in 'Microcontrollers, Programming and IoT' started by wildnwackywill10, Oct 31, 2011.

Scroll to continue with content
  1. wildnwackywill10


    Oct 30, 2011
    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?
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day