Menu

Float operations with GCB

Help
SP7DQR
2016-05-07
2016-05-09
  • SP7DQR

    SP7DQR - 2016-05-07

    Hi all,
    my name is Marek. I would like to migrate project for ATmega 32 from BASCOM to GCB, but I cannot see any float procedures.
    I want to calculate output power using voltage from ADC :
    Power_out = V * V 'P=(kU)(kU)/50=UUk*k/50
    Power_out = Power_out * Wspolczynnik ' wspolczynnik = 66.74
    Power_out = Power_out * Wspolczynnik
    Power_out = Power_out / 50

    I have the same problem with V calculation :
    V = Vac * 0.004883 , where Vac is a value from ADC register

    Is any way to make this calculations in GCB? I found float.h file, but it doesn't work with ATmega32.

    Thanks,
    Marek

     
  • Anobium

    Anobium - 2016-05-07

    Hello and welcome,

    Great Cow BASIC does not support floats currently.

    However, this can be worked around. If you factor up your calcualtions and then factor back down after your long divisions (these after factoring up will be integer) you will get the results you require.

    There are many examples of factoring integers to decimals - the DS18B20 is a great example.

     
  • SP7DQR

    SP7DQR - 2016-05-07

    Thanks for the explanation. I must analize this example.

     
  • William Roth

    William Roth - 2016-05-09

    How this is finally inplemented depends upon the application. I cannot tell from your code what the final application is. It is to display "power" or is to control the power to a certain device? -- Possibly a porportional control?

    What is the source of the voltage to the ADC?
    Is the ADC implmented as 8-bit or 10-bit ?
    What is the final application?
    How much accuracy is required?
    How much resoluition is required?

    Answer these questions and you can get more detailed help.

    William

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.