Author Topic: decimal point on HMI  (Read 4553 times)

Smurf

  • Guest
decimal point on HMI
« on: June 04, 2005, 09:43:32 AM »
Hello,

Reading a temperature via ADC(5) and converted it to value A in ?C.
A gives from -300 till 2500 or -30?C till 250?C
Can someone help me with a short routine that can display on the HMI e.g. -12.3 ?C or 123.5?

Kind regards

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3170
    • View Profile
    • Internet Programmable PLCs
Re:decimal point on HMI
« Reply #1 on: June 04, 2005, 11:27:12 AM »
To display an integer value A in 1 decimal place, use:


  SETLCD 1,1, "value="+STR$(A/10)+"."+STR$(A MOD 10)


Email: support@triplc.com
Tel: 1-877-TRI-PLCS

EDGAR

  • Jr. Member
  • Posts: 60
  • Automating concepts around the world!
    • View Profile
    • Kinemics
Re:decimal point on HMI
« Reply #2 on: June 22, 2005, 06:50:51 PM »
Hi this is what i do to show the Temperature from a Sensor on AI # 1 will show you the decimal point from 0 to 9 at real time, try it and see if it work.Simply Multiply it by 1000

lets say that the sensor is from 30?F to 250?F ;4-20ma
4ma/30?F = 814Cnt and 20ma/250?F = 4073 Cnt that's with a Resistor of 249 ohms 0.01%
If ADC(1) = 814 it give you a value of 299 wich we convert to 29.9 as String Data Type and a Count of  4073 is a value of 2500 wich is 250.0

Code:

T = (ADC(1) * 2000) / 4073
A = ((T - 400) * 2200) /1600 + 300 'Temperature scale of 1000

IF LEN(STR$(A)) <= 3 THEN
 A$ = "RM TEMP: " +  MID$(STR$(A),1,LEN(STR$(A))-1)+"."+ MID$(STR$(A),LEN(STR$(A)),1)
 ENDIF

IF LEN(STR$(A)) >= 4 THEN
 A$ = "RM TEMP: " +  MID$(STR$(A),1,LEN(STR$(A))-1)+"."+ MID$(STR$(A),LEN(STR$(A)),1)
 ENDIF

SETLCD 1,1, A$ + CHR$(176)+"F" 'Show it on the display like 75.3 ?F

Find the maximum and minimum Count of the sensor and change the Equation...
I hope that helps too
« Last Edit: June 22, 2005, 07:02:42 PM by EDGAR »
Low cost Modbus OPC DA Server, supporting Modbus RTU, ASCII, and TCP. Download your demo today! Go to www.kinemics.com/modbus.