Author Topic: convert hsc value to a decimal value on hmi  (Read 10414 times)

MIKE

  • Guest
convert hsc value to a decimal value on hmi
« on: April 20, 2004, 02:12:12 PM »
Could you tell me what I'm doing wrong! I keep getting
 1.1  l/min on the hmi?
( I have a pulse - flow meter that produce's 570 pulse's
per litre) I am trying to average the flow in L/Minute, using a 15 second sample, X 4 = 1 min. I need to display the value on the lcd screen as 1.48 L/Min.. or 2.3 L/Min...ect,what ever the actual flow rate is.. the rest of the process is based on  NOT falling below 1.40 L/Min

IF TESTIO(15_MIN_AV) = 0
SETLCD 3,1, STR$(F) + "." + STR$(F MOD 100) + "L/min"
ENDIF
D = HSCPV[1]
E = (D*4)
F = (E/570)
CALL 17




support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:convert hsc value to a decimal value on hmi
« Reply #1 on: April 20, 2004, 07:03:42 PM »
If your intention is to use the integer number F to represent 0.01 unit per digit, then you just need to multiply it by 100:

F = E*100/570
....

SETLCD 3,1, STR$(F/100) + "." + STR$(F MOD 100) + "L/min"

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

PLCstar

  • Newbie
  • Posts: 24
  • I'm a ladder logic fool!
    • View Profile
    • Morningstar Home Page
Re:convert hsc value to a decimal value on hmi
« Reply #2 on: May 04, 2004, 11:41:20 AM »
Maybe you would want to try something overly complicated like I did below.... lol :)

setlcd 4,1,"     "+mid$(str$(gettimersv(4)),1,len(str$(gettimersv(4)))-1)+"."+mid$(str$(gettimersv(4)),len(str$(gettimersv(4))),1)+" seconds    "

It will automatically adjust and display the value as a decimal number.

In my case, one decimal point.

In my example above replace the GETTIMERSV(4) after the STR$ in each of the LEN portions with your calculation for flow or however your set your varibale F.

Looking quickly at your code, you display the variable then add a decimal and then add the 100's.

Will it not be displaying the number twice in a sense? What if the interger variable = 148, would it not display 148.8 or something along those lines?

Anybody, any comments?
« Last Edit: May 04, 2004, 11:48:58 AM by PLCstar »