Internet PLC Forum
General => Technical support => Topic started by: Tito on August 20, 2012, 08:56:50 AM
-
Hi I do try out ADC function by using variable resistor 5K.
I just assume this
Temp C Voltage ADC
-20C 0 0
+200C 5 4096
By linear relationship
(T+20)/(200 +20) =(A-0)/(4096-0)
T = (A/4096)*220 - 20
while try with value A=0 , i do get T = -20C and when A=4096 then T = 200C. mathematically correct
In my custom function i do wrote as
B = ADC(1) *220 - 20
When i do adjust the variable to minimum end, do get -20C but in maximum end i do get 900C instead of 220C. May i know what cause the error. Thanks
-
You B formula is incorrect:
B = ADC(1) *220/4096 - 20
-
;) Cheers
-
Hi, I am using 5K variable resistor to simulate height of water level from 0 to 10 m
A = ADC(1)*10/4096
SETLCD 1,1,"Wtr Level = "+STR$(A)+ " m"
my intention is to display in LCD with 2 decimal place. Is that possible? Currently its just display in integer format.
-
Please refer to this thread:
http://www.tri-plc.com/yabbse/index.php?board=2;action=display;threadid=1084
-
Superb, thank you.
A = ADC(1)*1000/4096 'changed from 10 to 1000
SETLCD 1,1,"Wtr Level = "+STR$(A/100) +"."+STR$(A mod 100,2)+ " m"