Page 1 of 1

float

Posted: Thu Aug 23, 2012 4:08 pm
by Tony Brown
Can anyone please tell me if I can use the float function in flowcode 5 for pic?

It will not let me select it, maybe im doing something wrong.

Thanks

Tony

Re: float

Posted: Thu Aug 23, 2012 4:19 pm
by Jordy101091
what do you mean by
It will not let me select it, maybe im doing something wrong.
maybe the variable that your are using is not a floating point type.

Regards Jordy

Re: float

Posted: Thu Aug 23, 2012 8:07 pm
by Enamul
Hi
Can you please give an example which float function you tried but can't use as we can use any float function in fcv5

Re: float

Posted: Thu Aug 23, 2012 9:39 pm
by Tony Brown
Basically I'm trying to read the values from the ADC as volts, but I want two places after a decimal point, and looking at other examples on the forum decided to try using the float command, but I cant work out how to select the float command from the list that appears when you select what format (I think this is the correct word) you want the values in.

Re: float

Posted: Thu Aug 23, 2012 9:49 pm
by dazz
Hi Tony

have you set your variable to a float

Regards
Dazz
Untitled.jpg
Untitled.jpg (70.89 KiB) Viewed 7344 times

Re: float

Posted: Thu Aug 23, 2012 10:28 pm
by Enamul
Hi Tony,
Here is a simplest example of using ADC as volt read where ADC is declared as FLOAT variable. But the float variable can't be displayed in LCD as it is as LCD can display BYTE or INT variables. That's why using float to string function I have converted the float variable to string (i.e., DISP_STR). Float variable has precision up to 6 decimal points but the voltage is just up to 2 decimal points that's why I have taken only 2 decimal places using Left string function.
Hope this will help to start. :)

Re: float

Posted: Thu Aug 23, 2012 11:18 pm
by Tony Brown
Thanks Enamul thats brilliant, how would I make it so that instead of the numbers after the decimal point going up in steps of 5 it would go up in increments of 1?

Re: float

Posted: Thu Aug 23, 2012 11:36 pm
by Enamul
Hi Tony,
Are you looking for 5V range or higher? Number in first decimal place is going up by 1 and in second decimal place by 5 seems in simulation...So do you want to have 2nd decimal point change by 1 as well?

I have changed the Vref =1.25V, You have much finer resolution now..

Re: float

Posted: Fri Aug 24, 2012 9:36 am
by Tony Brown
Hi Enamul I am wanting to read the voltage of a board under test, its voltage is 24V, I am passing this through several potential divider to drop the voltage to 3V = 24V.

This is what I am wanting to read from the ADC and print on my GLCD. This test is quite critical so IO am using 0.1% resistors.

Thanks by the way for the extra flowcode file.

Regards

Tony

Re: float

Posted: Fri Aug 24, 2012 11:08 am
by Enamul
Hi Tony,
This version is with Vref=5V and I have modified the program so that it can read 0-5v in ADC input but produces output 0 to 40V which represents 3V equal to 24V as you have mentioned. You can test in hardware with normal LCD and adjust the resistor network. I think in hardware you will get finer resolution than simulation.
Hope this will help.

Re: float

Posted: Fri Aug 24, 2012 11:36 am
by Tony Brown
Hi Enamul

That's BRILLIANT thankyou very much

Regards

Tony