Arduino calculations

Hi

 

I am trying to calculate LTO COP values in emonglcd and send these to rasp.

I have all the values ok in emonglcd but this calculation wont work...shows zero all the time.

IS the Copin (int or float?) and should I multiply that with something (10000?)

emonglcd.CopIn =((1900 - 1100) / (2500 - 1100))=0,57142857142857142857142857142857 

=Cop 57%

 

emonglcd.TempOut = emontxPH.T13; //this works

   

emonglcd.CopIn =((emontxLTO.T7 - emontxLTO.T3) / (emonglcd.temperature - emonglcd.TempOut)); //does not work

emonglcd.CopOut =((emonglcd.temperature - emontxLTO.T6) / (emonglcd.temperature - emonglcd.TempOut));//does not work

 

Thaks again.

Robert Wall's picture

Re: Arduino calculations

IS the Copin (int or float?)

You must look at the declaration to find that. I don't recognise those lines - which sketch are you looking at?

By convention and to make each input to emonCMS the same so that each does not have to be customised, emonCMS will only accept integer values. Therefore, if the result of your calculation is less than unity and assigned to an integer variable, it will be truncated to zero. Depending on the number of significant decimal places that you want, you probably need to multiply by 10, 100, 1000 etc and divide by the same factor inside emonCMS.

Tomis's picture

Re: Arduino calculations

Hi

I got it working by adding float commands before calculations.

Dont know why but it works.

emonglcd.CopIn = (float)(emontxLTO.T7 - (emonglcd.TempOut))/((float)emontxLTO.T5 - (float)(emonglcd.TempOut))*1000;
    emonglcd.CopOut =(float)(emontxLTO.T5 - (emontxLTO.T6))/((float)emontxLTO.T5 - (float)(emonglcd.TempOut))*1000;

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.