Author Topic: Display minutes on PanelMeter but write milliseconds to PLC  (Read 1947 times)

EE_Kraig

  • Newbie
  • *
  • Posts: 37
    • View Profile
Display minutes on PanelMeter but write milliseconds to PLC
« on: March 14, 2017, 01:51:54 PM »
I get errors whenever I try to get this to work. I want to be able to enter (and display) minutes on a DPM keypad but write milliseconds to the PLC. So if I type in 1, I need to write 60000 to the PLC. If 60000 is in the PLC, display 1 on the DPM. Can I do this with the DPM settings?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #1 on: March 14, 2017, 02:30:23 PM »
What did you try and what errors are you getting?

You should be able to just put 0.00001677 in both ValueScaleFactor and KeypadScaleFactor

EE_Kraig

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #2 on: March 14, 2017, 02:37:26 PM »
What did you try and what errors are you getting?

You should be able to just put 0.00001677 in both ValueScaleFactor and KeypadScaleFactor

OK did that and I get "Failed to write value. Input string was not in a correct format." One thing I noticed, whatever I enter into the keypad has to be a factor of the scale value. Example, If I put 0.6 and enter 5, 7, 10, etc I get the above error.

Why do the scale factors appear to be backwards? If I put 0.1 in KeypadScaleFactor, and enter a 1, I get 10 in PLC. Maybe there is a good reason for this.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #3 on: March 14, 2017, 03:00:42 PM »
I just tried this out in the latest version and I'm not getting any error.

In most cases ValueScaleFactor and KeypadScaleFactor are going to be the same because the value from the PLC is multiplied by the ValueScaleFactor. When writing through the keypad, the entered value is divided by the KaypadScaleFactor.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #4 on: March 14, 2017, 03:13:46 PM »
Visual Studio 2013 shows the error that EE_Kraig mentioned.

It is possible to switch "/" with "*" and use 60000 as KeypadScaleFactor, then it works (approximately line 368 inside the DigitalPanelMeter.vb):

m_ComComponent.Write(m_PLCAddressKeypad, CDbl(KeypadPopUp.Value) * m_KeypadScaleFactor)
« Last Edit: March 14, 2017, 03:18:06 PM by Godra »

EE_Kraig

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #5 on: March 14, 2017, 03:18:26 PM »
Visual Studio 2013 shows the error that EE_Kraig mentioned.

It is possible to switch "/" with "*" and use 60000 as KeypadScaleFactor, then it works (approximately line 368 inside the DigitalPanelMeter.vb):

m_ComComponent.Write(m_PLCAddressKeypad, CDbl(KeypadPopUp.Value) * m_KeypadScaleFactor

I'll try that, may work better for me. Thanks!

EE_Kraig

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #6 on: March 14, 2017, 03:19:06 PM »
Just unzipped latest version, dropped a DPM and used the same settings as you, error.

EE_Kraig

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #7 on: March 14, 2017, 03:36:20 PM »
Visual Studio 2013 shows the error that EE_Kraig mentioned.

It is possible to switch "/" with "*" and use 60000 as KeypadScaleFactor, then it works (approximately line 368 inside the DigitalPanelMeter.vb):

m_ComComponent.Write(m_PLCAddressKeypad, CDbl(KeypadPopUp.Value) * m_KeypadScaleFactor)

Thanks again! KeypadScaleFactor = 60000 and ValueScaleFactor = 0.0001667 works perfectly.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #8 on: March 14, 2017, 06:18:07 PM »
I have been able to replicate, but only by writing to a 16 bit integer. When it converted 1 to 60000, it overflowed the integer and threw that exception. Are you writing to a DINT or INT?

EE_Kraig

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #9 on: March 15, 2017, 11:47:43 AM »
I have been able to replicate, but only by writing to a 16 bit integer. When it converted 1 to 60000, it overflowed the integer and threw that exception. Are you writing to a DINT or INT?

The register in my PLC is a UDINT but if I try to enter anything in the DPM larger than 2147483647 (scale factor = 1) I get this error:

"Failed to write value. Value is either too large or too small for an Int32."

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #10 on: March 15, 2017, 12:02:36 PM »
When it comes to writing, the driver does not distinguish a UDINT from a DINT, so when you exceed the limit of a DINT value, that is causing the error.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #11 on: March 15, 2017, 12:13:39 PM »
I made a driver patch for V3.99w that you can try:

https://sourceforge.net/projects/advancedhmi/files/advancedhmi/3.5/Patches

EE_Kraig

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #12 on: March 15, 2017, 12:46:00 PM »
Archie,

But when I make the modification that Godra suggested in DigitalPanelMeter.vb, it works splendid and I actually prefer it that way I wouldn't mind switching the ValueScaleFactor to a divide. So what does the patch do? It would maybe be handy to be able to do either a divide or multiply scale.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Display minutes on PanelMeter but write milliseconds to PLC
« Reply #13 on: March 15, 2017, 12:47:51 PM »
The patch makes it write a UDINT correctly