Author Topic: Scientific notation, conversion formulas and ports reading  (Read 1683 times)

clingon_2000

  • Newbie
  • *
  • Posts: 3
    • View Profile
Scientific notation, conversion formulas and ports reading
« on: July 15, 2016, 03:07:13 PM »
Hello there.

I need to display two values taken from analog inputs in the PLC (micrologix 1500, using the DF1 driver), these values come from a vacuum gauge, these has to be converted to vacuum measure (Pascals), one of the formula is like this:

 vacuum=10^(VoltageRead-3.5) 

and the second vacuum gauge has the following formula:

Vacuum=10^(VoltageRead*1.667-9.333

These vacuum reading have to be shown as scientific notation, I.E. 3.55E-03 ....

I would like to use one of the "digital panel meters" of the toolbox.

Also, I could not read straight from the port (i.e. I:3.1), I had to move the value to an N:X.X registers before.

I anybody can help, I will apreciatte.



Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Scientific notation, conversion formulas and ports reading
« Reply #1 on: July 16, 2016, 12:41:39 AM »
Just some of my thoughts:

1) DigitalPanelMeter doesn't seem to be designed to handle scientific values

2) BasicLabel can be used instead and its NumericFormat property should be set to what you need it to show (E2 should show the value as 3.55E+003 but if you need only 2 digits after E+ then you could use: 0.00E+00). More on formats here:
https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

3) Reading I:3.1 straight from the port doesn't seem to be possible, according to Archie in this topic: http://advancedhmi.com/forum/index.php?topic=517.msg2103#msg2103

4) If your formulas are correct then I am currently aware of 2 options that you might have:
    - You can use those formulas within ladder program and have the PLC do the math and provide result (this way you can use the AHMI BasicLabel control's PLCAddressValue property set to read that value)
    - If you are reading a value from PLC that then has to be converted, you would have to write the code that reads the value, uses your formulas to do the math and then sends the converted value to a control. The code could be similar to this (in this example a timer is set to read values from PLC every second and send converted values to 2 Windows Forms labels):

Code: [Select]
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Label2.Text = (10 ^ (CDbl(EthernetIPforSLCMicroCom1.Read("N7:0", 1)(0)) - 3.5)).ToString("0.00E+00")
        Label3.Text = (10 ^ (CDbl(EthernetIPforSLCMicroCom1.Read("N7:1", 1)(0)) * 1.667 - 9.333)).ToString("0.00E+00")
    End Sub
« Last Edit: July 16, 2016, 12:17:17 PM by Godra »

clingon_2000

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Scientific notation, conversion formulas and ports reading
« Reply #2 on: July 17, 2016, 10:21:36 PM »
Thanks Godra, your response is very informative....