Author Topic: String Input?  (Read 6222 times)

Volare76

  • Newbie
  • *
  • Posts: 15
    • View Profile
String Input?
« on: July 22, 2013, 02:48:02 PM »
Does anyone know if there is a way to manipulate string data with a basic label or other control?  Something similar to the way you can do numeric input.  I am currently developing an HMI project where the operator will need to modify data in a "string" format.  The project will communicate with both SLC's and Compactlogix controllers over IP.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: String Input?
« Reply #1 on: July 22, 2013, 02:52:02 PM »
If you have a keyboard on your HMI, the keypad will accept alphanumeric typed in from the keyboard. Although not very graceful, you can also use the on screen keyboard that is built in to XP and Windows 7.

There are plans for a future release to have a pop up alphanumeric keyboard.

Volare76

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: String Input?
« Reply #2 on: July 22, 2013, 03:14:06 PM »
My HMI does have a keyboard.  When I try to input data via the keypad it produces an error "Failed to write value - Conversion from string "CH11058 2146832" to type 'Double' is not valid".  Also this method does not allow me to use a hyphon.  Example input "CH11058   214-6832"

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: String Input?
« Reply #3 on: July 22, 2013, 03:58:26 PM »
What is your KeypadScaleFactor set to in your BasicLabel properties? Make sure it is 1 or 0

Also make sure your KeypadMinValue and KeypadMaxValue are both 0
« Last Edit: July 22, 2013, 04:00:09 PM by Archie »

Volare76

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: String Input?
« Reply #4 on: July 22, 2013, 04:10:56 PM »
ScaleFActor was set to 1.  I tried with 0 but that just makes the value display as 0.  When inputing text it does not error out though, but it won't update the register in the PLC.  As far as the Min and Max values they are both 0.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: String Input?
« Reply #5 on: July 22, 2013, 04:35:17 PM »
This is the code in the BasicLabel that writes from the keypad:

Code: [Select]
                  Try
                        '* 29-JAN-13 - reduced code and checked for divide by 0
                        If KeypadScaleFactor = 1 Or KeypadScaleFactor = 0 Then
 ->>>>>               _CommComponent.WriteData(m_PLCAddressKeypad, KeypadPopUp.Value)
                        Else
                            _CommComponent.WriteData(m_PLCAddressKeypad, CDbl(KeypadPopUp.Value) / m_KeypadScaleFactor)
                        End If
                    Catch ex As Exception
                        MsgBox("Failed to write value - " & ex.Message)
                    End Try
                End If

You can try to put a breakpoint at the line I have marked with the arrow. Then run the program and put in a value. When it stops at the breakpoint, hover over m-PLCAddressKeyapd and KeypadPopUp.value to see what the values are.

Volare76

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: String Input?
« Reply #6 on: July 22, 2013, 05:03:37 PM »
m-PLCAddressKeypad  value is "Test_Text"  the tag in my CompactLogix controller.   KeypadPopUp.Value is "M077210"  the text that I inputted via the keyboard.  At that point in the code I see that you divide by the ScaleFactor  perhaps it is trying to convert the string to a number for the arithmatic.

Volare76

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: String Input?
« Reply #7 on: July 22, 2013, 05:11:08 PM »
I removed the divide by ScaleFactor in that line of code and am able to get it to work.  Is there an easy way to copy and paste the controls to create a new control with the modified line so I can continue to use both types?

Volare76

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: String Input?
« Reply #8 on: July 22, 2013, 05:24:27 PM »
Ok I answered my own question.  For anyone looking to do the same thing from the solution explorer copy the control then paste it back into the same area with a new name.  After you do that then rename the PublicClass to something different and rebuild the solution.  Thank you Archie for your help on this issue.

Volare76

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: String Input?
« Reply #9 on: July 22, 2013, 05:45:33 PM »
Archie,

Any idea why the Keypad won't accept a hyphon?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: String Input?
« Reply #10 on: July 23, 2013, 07:44:29 AM »
The "-" is interpreted by the keypad as a negative sign, so it toggles the value between a negative and positive number. I don't think there is an easy work around for that one.

Volare76

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: String Input?
« Reply #11 on: July 23, 2013, 12:29:06 PM »
Any other ideas to write a string to the PLC?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: String Input?
« Reply #12 on: July 23, 2013, 01:03:18 PM »
You could put a TextBox on your form and a button. Double click the button to get back to the code and write the contents of the TextBox like this:

EthernetIPforCLXComm1.WriteData("MyTag",TextBox1.Text)

Volare76

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: String Input?
« Reply #13 on: July 23, 2013, 03:44:23 PM »
Excellent that is exactly what I was looking for.  Thank you again for your help.