Author Topic: Have a Keypad write to any PLCAddress  (Read 10232 times)

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Have a Keypad write to any PLCAddress
« on: March 29, 2015, 03:38:13 PM »
It would be like "on the fly" change of the controls PLCAddressKeypad field.

Could be useful only to those who know their PLC tags by heart.

Just an idea.
« Last Edit: April 05, 2015, 03:49:15 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #1 on: March 29, 2015, 06:32:40 PM »
Here is a Keypad control I created using mostly Archie's code. It is sufficient just to add it to PurchasedControls folder as existing item.

This control is in the form of a button and a combobox which allows either direct input of a PLCAddress or displaying available PLCAddresses from a collection of string PLCAddressKeypad addresses, that needs to be populated by a user at DesignTime. If identical PLC addresses are entered by mistake into collection they will be displayed as one entry but will not be removed, so it's up to user to organize the collection.
Those manually entered addresses at Runtime, will be used by a keypad but will not be saved into collection.

The collection also allows string separator so descriptive comments could be entered along with a PLCAddress (see the attached picture). The same PLCAddress with and without descriptive comment, if entered, will be displayed and point to exactly the same address.
Current separator is space + 2 forward slashes (" //") but can be changed since there is a public property created.

The control appears to be working fine as it is.
« Last Edit: April 05, 2015, 03:49:33 PM by Godra »

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #2 on: May 09, 2015, 11:36:26 AM »
Good stuff Godra , I've used this on a few of my HMI's and I must say , it's a  useful component that I added to my toolbox and continue to use. and its nice to see a keypad location was added

A few additions would be nice

- When key pad pops up,  the option of also seeing the comment would be good
- Limits on what can be entered
- Possibly the collection could be read from a spreadsheet or something like that

Darrell

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #3 on: May 09, 2015, 01:54:19 PM »
Thank you Darrell, it is nice to see that somebody is using this control.

Here are my answers to your questions:

- To see a comment just change the following line in the cbPLCAddressKeypad_SelectedValueChanged sub:

Code: [Select]
Me.KeypadText = Me.PLCAddressKeypad.ToString
to

Code: [Select]
Me.KeypadText = Me.cbPLCAddressKeypad.SelectedItem.ToString
- Limitation of any kind is not really what this control is all about (check my initial post). Since the control could be used with different PLCs, addresses or tags would be different and the user really needs to know what they are entering (while observing the current string separators).

- As I stated in my previous post, it is really up to a user to organize the collection. If a spreadsheet or any other file is already organized with addresses and comments then it is just a simple matter of copy/paste into the collection at Design Time <-- all the organizing is done at Design Time while at Runtime the control only displays it.

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #4 on: May 10, 2015, 06:01:09 PM »
Darrell here is some additional information:

- When it comes to limiting what can be entered, you can decide whether to disable that feature completely by commenting out or removing the following sub:

Code: [Select]
Private Sub cbPLCAddressKeypad_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbPLCAddressKeypad.TextChanged
        Dim stringAddress() As String
        stringAddress = Me.cbPLCAddressKeypad.Text.Split(stringSeparators, StringSplitOptions.None)
        Me.PLCAddressKeypad = stringAddress(0)
        Me.KeypadText = Me.PLCAddressKeypad.ToString
    End Sub

Also change the following line in Keypad_Click sub from:

Code: [Select]
If Me.cbPLCAddressKeypad.SelectedItem = "Select or Enter PLCAddress" Then Exit Sub

to:

Code: [Select]
If (Me.cbPLCAddressKeypad.SelectedItem = "Select or Enter PLCAddress" OrElse Me.PLCAddressKeypad = "Select or Enter PLCAddress") Then Exit Sub

This will still allow users to select from available addresses and since you might be organizing the collection that could implement additional limitation for users to see only addresses you want them to see.

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #5 on: May 10, 2015, 08:30:56 PM »
Here is a new version of this control now with Admin and User features (Darrell asked for limitations so here are some).

2 collections of addresses can be individually set, 1 for User and 1 for Admin, and at Runtime only the User will be visible while the Admin is password protected and can be accessed by holding Ctrl + Alt keys and clicking KeypadPopUp Button. The same combination of keys is used to switch back to User.

3 incorrect attempts to enter the password and the button will be disabled but the password box can still be accessed by using the keyword, entered under Unlock public property, typed directly inside the combobox and followed by the Enter key (default keyword is "!Unlock!").

Password is created as Public Property and is not masked (default password is 4 zeroes = "0000"), is set at Design Time and can be seen by anyone who can open the project in Visual Studio. So be careful of who has access to the project.

Currently the User cannot manually input the address since the sub mentioned in the previous post is commented out (change it if you need different and also change "Select PLCAddress" strings back to "Select or Enter PLCAddress"). This doesn't apply for the Unlock keyword, it can still be entered.

There is now KeypadShowComments public property to enable/disable showing comments along with the address on the KeypadPopUp.
« Last Edit: May 18, 2015, 01:46:37 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #6 on: May 12, 2015, 09:52:40 PM »
For those who downloaded this new version, a few bugs were corrected and a new "Unlock" public property was added and the attached file was replaced.

The text in the previous post was also edited so read it again.

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #7 on: May 18, 2015, 10:34:16 AM »
For some reason I cant get it to show the comment on the key like your previous version ,

what would be nice is to have the option in the properties window , show comment  true / false
also disable entering a plc address that is not in the collection  true / false
Also have a problem getting the tool tip to show. keep up the good work I really like this component.

Darrell
« Last Edit: May 18, 2015, 10:38:56 AM by Darrell »

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #8 on: May 18, 2015, 01:41:27 PM »
Darrell,

A file was replaced and now with KeypadShowComments property.

User is already prevented from entering any PLC address and only Admin can do such thing. I am not sure how else to prevent it.

Can you remind me of what tooltips were showing before?

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #9 on: June 09, 2015, 06:57:51 AM »
I was able to add this to purchased controls in V398m but get this error in the latest ver.

Darrell

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #10 on: June 09, 2015, 07:48:26 PM »
I couldn't see that line in the files that were posted.

Can you attach the file that you are currently using?

You can always try downloading and adding one of the files posted in this topic.
« Last Edit: June 09, 2015, 08:10:00 PM by Godra »

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #11 on: June 09, 2015, 08:43:20 PM »
my apologies , I had a couple of different versions and tried to use the wrong one , downloaded the lasted one and works fine.

Thanks


Darrell

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #12 on: June 12, 2015, 11:10:20 PM »
Attached is the latest version which should be used with AHMI post 3.98n versions (should work fine with prior versions as well but not with OpcDaCom driver).

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #13 on: June 30, 2015, 02:13:52 PM »
Archie,

How would you go about setting a different driver from within control itself (or just enumerating available drivers)?

For example, if the control's CommComponent shows (none), OpcDaCom1 and ModbusTCPCom1 as available drivers in the property window, I would kind of like to include a combobox in the control that would show all these drivers exactly as they appear in the property and then select one of them.

I have attached BasicIndicator properties window as an example.

Edit: I did figure out one solution for KeypadHMI control itself. The other simpler solution is to put a button or combobox on the MainForm and have it change the driver for the control.
« Last Edit: July 02, 2015, 01:22:01 AM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: Have a Keypad write to any PLCAddress
« Reply #14 on: July 04, 2015, 02:30:20 PM »
I have modified the control to be able to change drivers on-the-fly.

There is one catch, if drivers are added or removed after the control has been placed on the form then the form will have to be closed and re-opened, so the control can refresh its list, and then in the control's property window click CollectionOfDrivers and then click OK. This should add/remove the driver from combobox at Runtime.

The following combinations of keys are used to switch back and forth:

SHIFT + Click --> switch between Keypad and Drivers buttons/combobox

CTRL + ALT + Click --> switch between User and Admin combobox


An exception might be thrown if incorrect tags are used with incorrect drivers so try to keep your tags organized and remember what driver is currently selected (I might try to place that indication somewhere on the control).
« Last Edit: July 06, 2015, 01:23:45 AM by Godra »