ADC Problems with FloatToString and Float To Integer with LC
Posted: 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.
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.