Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Dmelnyk on July 01, 2013, 02:25:28 PM

Title: Math & String Print for logarithmic scaling in exponential form
Post by: Dmelnyk on July 01, 2013, 02:25:28 PM
I am looking to do 0-10vdc logarithmic scaling.
Output signal (measuring signal) 0 … +10 V
Measuring range 0.774 V (5×10-10 mbar)
… +10 V (1000 mbar)
Relationship voltage-pressure logarithmic, 0.75 V/decade
(→ Appendix A)
p = 10(U - 7.75) / 0.75 + c
where U        p            c

     [V]     [Torr]       -0.125


I have the PLC program as:

Math:
Result:            D0
Epression:  WX0-7.75

Math:
Result:            D1
Expression: (D0/0.75)-0.125

Math:
Result:            D2
Expression: 10**D1

STRPRINT
Print to:          SS0
Print Script: FmtReal(D2,2,2,exp)


From what I can tell this should be correct to display in exponential form. If "U" is 7.00 then after the math and STRPRINT I should see ( 7.5x10-2Torr). 

Any help would be appreciated.  Thanks



Title: Re: Math & String Print for logarithmic scaling in exponential form
Post by: franji1 on July 01, 2013, 02:36:40 PM
WX0 is not in volts, it is usually 12 bit or 16 bit integer, with ranges of 0-4095 or 0-65535.  I would use SCALE WX0 from 0.0 to 10.0 to R0 (use the decimal point), then use R0 in place of D0, and R1 for D1, R2, for D2, etc.  D0 is just 32 bit signed integer, so you won't get any fractional values like you do with R (REAL or IEEE 32 bit floating point).