Author Topic: Keyboard Input Negative (-) Value.  (Read 3193 times)

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Keyboard Input Negative (-) Value.
« on: October 24, 2019, 04:22:42 AM »
Hi All,

I've read this thread:
https://www.advancedhmi.com/forum/index.php?topic=136.msg268#msg268

Seems that there is no solution to input the negative value (if i don't miss anything there).

I'm setting up a page where i can always change the minimum and maximum value from the HMI.
The problem is i cannot enter negative numbers. I will get this warning: Failed to write value-Arithmetic operation resulted in an overflow.

Is there any way i can solve this problem?
« Last Edit: October 24, 2019, 04:51:40 AM by joko markono »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5272
    • View Profile
    • AdvancedHMI
Re: Keyboard Input Negative (-) Value.
« Reply #1 on: October 24, 2019, 06:55:20 AM »
Are you using version 3.99x or 3.99y ?

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: Keyboard Input Negative (-) Value.
« Reply #2 on: October 24, 2019, 08:17:08 PM »
It's 3.99y

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5272
    • View Profile
    • AdvancedHMI
Re: Keyboard Input Negative (-) Value.
« Reply #3 on: October 24, 2019, 08:40:39 PM »
What negative number are you trying?

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: Keyboard Input Negative (-) Value.
« Reply #4 on: October 24, 2019, 08:45:38 PM »
Any none decimal negative value. For example -6237

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5272
    • View Profile
    • AdvancedHMI
Re: Keyboard Input Negative (-) Value.
« Reply #5 on: October 24, 2019, 08:52:46 PM »
I will have to setup an Omron PLC and test this. The only reason I can see that you would get that error is if you exceeded the limits of a 16 bit integer. For example -32800

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: Keyboard Input Negative (-) Value.
« Reply #6 on: October 24, 2019, 08:56:24 PM »
i appreciate that. my number will not reach -XXXXX.
FYI, I got the error even before i connect to PLC.
« Last Edit: October 24, 2019, 09:00:11 PM by joko markono »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5272
    • View Profile
    • AdvancedHMI
Re: Keyboard Input Negative (-) Value.
« Reply #7 on: October 24, 2019, 09:06:19 PM »
Does this also happen if you use a BasicLabel and set the PLCAddressKeypad ?

Do you have anything in the ScaleFactor property?

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: Keyboard Input Negative (-) Value.
« Reply #8 on: October 24, 2019, 09:31:03 PM »
Yes, same thing. The scale value for the basic label is 1.

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: Keyboard Input Negative (-) Value.
« Reply #9 on: November 01, 2019, 04:31:27 AM »
I'm just following up if there is any update on this?

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Keyboard Input Negative (-) Value.
« Reply #10 on: November 01, 2019, 02:29:44 PM »
Can you explain what driver you are using, what are those controls in the first picture you posted (more details)?

What does this mean:

I got the error even before i connect to PLC.

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: Keyboard Input Negative (-) Value.
« Reply #11 on: November 03, 2019, 09:55:06 PM »
I'm using Omron serial hostlink protocol.
that statement means, before I connect the serial port to my PLC, there's already an error warning when I enter -ve value.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5272
    • View Profile
    • AdvancedHMI
Re: Keyboard Input Negative (-) Value.
« Reply #12 on: November 03, 2019, 11:10:26 PM »
The problem comes from this code:
Code: [Select]
        '**************************************
        '* Convert an integer value to Hexadecimal
        '**************************************
        Public Shared Function IntToHex(ByVal data As Integer) As String
            If data < 16 Then
                Return "000" & String.Format("{0:X}", data)
            ElseIf data < 256 Then
                Return "00" & String.Format("{0:X}", data)
            ElseIf data < 4096 Then
                Return "0" & String.Format("{0:X}", data)
            Else
                Return String.Format("{0:X}", data)
            End If
        End Function

It is supposed to return 4 characters representing the hex value, but a negative value doesn't work.

I'll try to look for a fix later, but if anyone can suggest a fix in the mean time, I'll give it a go.

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Keyboard Input Negative (-) Value.
« Reply #13 on: November 04, 2019, 01:10:49 AM »
Maybe this:

Code: [Select]
    '**************************************
    '* Convert an integer value to Hexadecimal
    '**************************************
    Public Shared Function IntToHex(ByVal data As Integer) As String
        If data < 0 Then
            Return Hex(data).Substring(4) 'or Hex(data).TrimStart("F").PadLeft(4, "F"c)
        Else
            Return Hex(data).PadLeft(4, "0"c)
        End If
    End Function

« Last Edit: November 04, 2019, 01:55:20 AM by Godra »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5272
    • View Profile
    • AdvancedHMI
Re: Keyboard Input Negative (-) Value.
« Reply #14 on: November 04, 2019, 08:09:07 PM »
I'm getting an error about the function Hex

Do you know where that is coming from?