ADC Problems with FloatToString and Float To Integer with LC

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Taurus
Flowcode V4 User
Posts: 46
Joined: Tue Feb 23, 2010 3:58 pm
Has thanked: 3 times

ADC Problems with FloatToString and Float To Integer with LC

Postby Taurus » Fri Feb 26, 2010 1:09 pm

Because I can’t find good information how to use the VREF+ with Flowcode V4, I do it this way: I am looking for more information about the VREF+ or a good sample, also for the VREF-spanning?

I want to use the Lm35 as a temperature sensor.
When I understand it right, the temperature should range from 0 to 100 degrees Celsius. The sensor is 10mV/C. Let us say 10mV = 1degree Celsius and 1000mV is 100 degrees Celsius.

For the Lm35 I take ADC0 and set the VREF+ option to VREF+ in the properties.
The ADC3 I use as reference and set in the properties the VREF+ option as VDD and put 1 volt on this input.

To get the temperature on the display, I calculate this in the following way:
RefSpan=1000/255
Temperature = RefSpan * ADC0.

Question 1
Is it correct that now the voltage from 0 to 1 V (Lm35) on ADC0 are equal pieces from 0 to 255 steps.

Question 2
Can I use ReadAsInt also instead of ReadAsByte when using as VREF+.
How should I use it in this case.

Question 3 (See program StringLCD.fcf)
Why doesn’t the FloatToString work with the ADC and LCD when using the PIC;
with the simulation it works.

Question 4 (see program FloatLCD.fcf)
Here I try to change Float in an integer for the LCD when using the PIC,
with the simulation it works.

With the PIC, both programs don’t give the right information on the display.

I did ask Ben Rowland before and he thought it belongs on the forum.
I think it belongs in a good help file.

In a similar question on the forum he gives as an answer:
“If it is a calculation then maybe you can simply store the result in a float variable. Then convert the float to a string and send the string to the LCD.”

This is what I tried to do, but it didn’t work

Another thing I don’t understand is:
When I need for example (see StringLCD.fcf) two ADC inputs, in the properties at the ADC’s I select then ADC0 and ADC3. But when I look in the properties of the macro then it is called ADC0 and ADC1, why not ADC0 and ADC3.
Has this to do with my problems.

Can someone help me with these problems please.
Attachments
FloatLCD.fcf
(8 KiB) Downloaded 160 times
StringLCD.fcf
(7.5 KiB) Downloaded 143 times
Taurus

User avatar
Benj
Matrix Staff
Posts: 14219
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4361 times
Been thanked: 4096 times
Contact:

Re: ADC Problems with FloatToString and Float To Integer with LC

Postby Benj » Fri Feb 26, 2010 3:09 pm

Hello

Here is an updated version of your programs that should now work correctly on the hardware. The problem was due to the fact that BoostC requires all float manipulations to be done via functions.
Attachments
StringLCD.fcf
(6.5 KiB) Downloaded 212 times
FloatLCD.fcf
(7 KiB) Downloaded 234 times

User avatar
Benj
Matrix Staff
Posts: 14219
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4361 times
Been thanked: 4096 times
Contact:

Re: ADC Problems with FloatToString and Float To Integer with LC

Postby Benj » Fri Feb 26, 2010 3:10 pm

Read as int would require an initial divide of

100 / 1023

instead of

100 / 255

Taurus
Flowcode V4 User
Posts: 46
Joined: Tue Feb 23, 2010 3:58 pm
Has thanked: 3 times

Re: ADC Problems with FloatToString and Float To Integer with LC

Postby Taurus » Sun Feb 28, 2010 9:55 pm

Hi Benj,

Thanks for your response.
Taurus