AdvancedHMI Software
General Category => Open Discussion => Topic started by: Tazmahal on March 31, 2018, 08:45:17 AM
-
Hi everyone !
Is there any way to do global object like in view studio ? The plc is a Clx, so I would like to put control and info in a groupbox , start stop jog interlock condition etc..
All motor have the same data type, so can we read the tag from example a label in the group box ?
I'm not very good with VB.. just wanna know if it's possible and maybe if someone can give me a starting point on how i can get this working !
Many thanks !!
-
There absolutely is, look into creating controls. Take the basic button for example, that is a global object. I'm not sure I included them, but I have posted several example apps before. Take a look at the multiple monitor example, look for popups for FVR, FVNR, etc. This will show how to do popups as global objects compared to FTView.
https://www.advancedhmi.com/forum/index.php?topic=1896.msg10810#msg10810 (https://www.advancedhmi.com/forum/index.php?topic=1896.msg10810#msg10810)
James
-
I never used global objects in View Studio, so based on your description I made a rough version of how I interpret it to work.
- Download the attached file
- In Solution Explorer expand down the AdvancedHMIControls project
- Right click the PurchasedControls folder
- Browse to and select the GroupedObject.vb file downloaded here
- Double click the GroupedObject.vb file and it will open in design view
- From the Toolbox, add a control such as a BasicLabel
- Set PLCAddressValue to the sub-element of a UDT
- Build the solution
- In Solution Explorer, Double click MainForm.vb to open in design view
- From the Toolbox, add a GroupedObject to the form
- Set PLCAddressUDT to the UDT name that contains the sub-element specified above
- Run the application
This control still has a quirk that I did not get resolved where it will try to connect to a PLC in design view.
-
Wow !! Thank you for the quick response :), I'll give a try this Pm !!
-
I'm very impressed !! Works like a charm , Archie you're the man !!
-
Archie, global objects in FTView is just RA way of doing reusable objects, graphics, controls, etc.
-
Archie, global objects in FTView is just RA way of doing reusable objects, graphics, controls, etc.
That's what I was kind of thinking. How does it handle addressing if the object is re-used multiple times?
-
I've added 5 motor and no issues ! Works very nicely :)
Phrog I've used your build and i'm struggling a little bit , the header alarm keep telling me No plc communication and i've changed all the adress in the Main_plc to my clx address.. any clues ?!
Thanks again !!
-
Archie, global objects in FTView is just RA way of doing reusable objects, graphics, controls, etc.
That's what I was kind of thinking. How does it handle addressing if the object is re-used multiple times?
You assign placeholders, then those are replaced with PLC addresses. RA uses #1, #2, as placeholders.
-
I've added 5 motor and no issues ! Works very nicely :)
Phrog I've used your build and i'm struggling a little bit , the header alarm keep telling me No plc communication and i've changed all the adress in the Main_plc to my clx address.. any clues ?!
Thanks again !!
I honestly don't remember what I used in the PLC for looking at connections. I'm not in front of my PC right now. I used parents. If you look in the 1st parent, I have a bunch of regions. If you look in the I should have labeled things so you can easily find stuff. For right now you can simply comment out the code that deals with communication lost. If you still need help let me know, I can look later.
-
It's fine Phrog I'll take a look to that !
Archie there's a small bug will I change page and return to my main page I think it reconcate the string ex : my tag is ; In.DriveStatus_Active and PLCAdressUDT is M3110 , so M3110.In.DriveStatus_Active and reconcate to M3310.M3110.In.DriveStatus_Active
-
In Phrog30's version, check MyHMI\Class\Globals.vb and update the IP there as well.
The other way could be to add to MyHMI\Data\App_Config.ini the following line:
[Settings]
IPAddress=192.168.0.22 <-- replace with your IP
and then add a line to the bottom of MyHMI\Displays\Replace\_0000_1st_Parent.vb --> App_Settings() sub:
Globals.PLC_1 = Main_PLC.IPAddress
You might need to make a few more changes if you want the alarms to work. Possibly create an array in your PLC, named HMI_Alarm_Array[20] and set the following line: Private Alarm_Quantity_PLC_Address As String = "HMI_Alarm_Array[1]" (in your PLC set the value of HMI_Alarm_Array[1] to 20). Then try changing the value of HMI_Alarm_Array[0] to see what alarm will turn ON. DINT array worked for me.
The attached picture shows it as working.
-
Thank you Godra, alarm works fine !!
No communication to plc is ok now ! :)
Hmi_Alarm_Array[0].0 to 31 works good ! can we use more than 32 alarm ? And what's the purpose of HMI_Alarm_Array[1] to 20 ?
Many thanks !!
-
I am not sure about everything in this app so try experimenting.
Look for this line in the 1st parent:
Private Alarm_Quantity_PLC_Address As String = "HMI_Alarm_Array[1]"
The value that you set at this address in the PLC should define the Alarm Quantity.
You don't have to use HMI_Alarm_Array[1] and shouldn't use it now that you want more than 32 alarms.
Instead, try using HMI_Alarm_Array[19] and set it to 64 or 128 (make sure to update the above mentioned line of code).
Then try changing HMI_Alarm_Array[0] and HMI_Alarm_Array[1] and HMI_Alarm_Array[2] and ... bits to see if they will trigger alarms.
I did try it and there is no limit of 32 alarms.
Also, look inside MyHMI\Data\Alarm_Desc.ini file, that's where description for each alarm should be (and you can add or remove entries).
You should make sure to have a description for each alarm you want to use.
There a several lines of code marked as "TO DO" so the app might not be complete (unless it was changed and updated since I downloaded it last).
-
Thank you Godra, alarm works fine !!
No communication to plc is ok now ! :)
Hmi_Alarm_Array[0].0 to 31 works good ! can we use more than 32 alarm ? And what's the purpose of HMI_Alarm_Array[1] to 20 ?
Many thanks !!
Glad you figured things out. I tried to bookmark areas with "TODO_x", those aren't necessarily items that still need completed, but items that may need configured for your specific process - I probably could have picked a better term than TODO.
I use arrays because I feel they are more efficient and easier to use. You can use SINT, INT, DINT, etc., as long as you specify the word length (since the driver isn't capable of knowing data type). This app has been tested with MicroLogix and AD Productivity (Modbus) as well. You define length on line 654:
Private Binary_Length As Integer = 32 'TODO_2
If using CpLX/CLX I would always recommend using DINT, which is 32. Since there isn't an alarm number 0, I skip that and start with 1. So, word - bit 1 is alarm #1, word
- bit 31 is alarm #31, word [1] bit 0 is alarm #32, etc. There is no limit. You could have 1000s of alarms. This app is setup to use the descriptions from a user defined INI file within the app, as Godra pointed out, or you can use strings from the PLC, line 706:
AlarmDescArray.PLCAddress = "Alarm[" & i & "].Description_ID" 'TODO_6 '
Hope that clarifies things a little better.
James
-
Thanks James and Godra your help is greatly appreciated ! Everything is clear for the alarm :) And nice work James for this build !! Fire 8)
-
Still having hard time to figured out how to fix that error in the GroupedObject, I'm newbie in vb :-[
So it work great on launch , change page and came back and throw this exeption ;
System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=La collection a été modifiée ; l'opération d'énumération peut ne pas s'exécuter.
Source=mscorlib
StackTrace:
à System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
à System.Collections.Generic.List`1.Enumerator.MoveNextRare()
à System.Collections.Generic.List`1.Enumerator.MoveNext()
à AdvancedHMIControls.SubscriptionHandler.SubscribedDataReturned(Object sender, PlcComEventArgs e) dans C:\Apps\Test\AdvancedHMIControls\SubscriptionHandler.vb:ligne 325
à AdvancedHMIDrivers.EthernetIPforCLXCom.DataRecSync(Object e) dans C:\Apps\Test\AdvancedHMIDrivers\AllenBradley\EthernetIPforCLXCom.vb:ligne 291
InnerException:
???
And sometimes no exeption but Invalid arguement everywhere ..!
-
There are many ways to do this. Personally, I would go the simple route which is create a new user control. Place a basiclabel, then go to the code. All you want to do is be able to define the PLC items, which is what this code should do. This is an example, you will need to use your addressing. Tagname is the base tag. That is the property you will define in design mode. The members are something you will hard code.
Public Class UserControl1
Public Tagname As String
Private Sub UserControl1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BasicLabel1.PLCAddressValue = "" & Tagname & ".something"
End Sub
End Class
I didn't test this, but I don't see why it wouldn't work. It's similar to what I've done for popups, except those are forms.
James
-
Make sure to ignore during design mode, unless you like that feature. Most will want to ignore...
If Not DesignMode Then
BasicLabel1.PLCAddressValue = "" & Tagname & ".something"
End If
-
I tested and it works fine, here's the code I used:
Public Class Global_Objects_Test
Private m_Tagname As String
Public Property Tagname As String
Get
Return m_Tagname
End Get
Set(value As String)
If m_Tagname <> value Then
m_Tagname = value
End If
End Set
End Property
Private Sub Global_Objects_Test_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Not DesignMode AndAlso Tagname IsNot Nothing Then
BasicLabel1.PLCAddressValue = "" & Tagname & ".Item1"
BasicLabel2.PLCAddressValue = "" & Tagname & ".Item2"
BasicLabel3.PLCAddressValue = "" & Tagname & ".Item3"
BasicLabel1.PLCAddressKeypad = "" & Tagname & ".Item1"
BasicLabel2.PLCAddressKeypad = "" & Tagname & ".Item2"
BasicLabel3.PLCAddressKeypad = "" & Tagname & ".Item3"
End If
End Sub
End Class
I created a UDT with 3 strings, Item1, Item2, Item3. Then created 3 different tags of that data type. I was able to read the tags and use keypad to write. Remember that if you don't use full strings (82) you will need to do something a little different. I could have used integers or bools as well.
James
-
Well .. I've tried that with no succes .. like I said i'm new to vb , it gave me a bunch of error :-[
The solution of Archie is exactly what i'm looking for and straight forward ! Easy to change and build ..!
-
Well .. I've tried that with no succes .. like I said i'm new to vb , it gave me a bunch of error :-[
The solution of Archie is exactly what i'm looking for and straight forward ! Easy to change and build ..!
What errors? I'm confused, I thought you said you were getting exceptions from the code Archie gave you. That's why I showed you another way. It's the simplest approach. All you are doing in the code is dynamic plc property setting. You are letting the controls do the rest, which has already been tested thoroughly.
Maybe take screenshots of the errors or post your code, or wait on Archie, assuming you were getting exceptions and I didn't misread your post.
-
Sorry mate ! Finaly I’ve been able..! You’re right that work perfecly !! Thank you so much :)
-
NOTES ON USAGE: Seems you can't put AHMI Controls within a container such as a TableLayoutPanel as part of your GroupObject design.
Doing this breaks the code which concatenates the PLCAddressUDT and the PLCAddressxxx within AHMI Controls placed in the GroupObject.
I other words, seems AHMI Controls need to be "contained" by the Form or GroupObject (class) directly. They cannot be buried deeper into a hierarchy of other containers such as TableLayoutPanel.......I think this is the right terminology to use.
OTHERWISE: to use layout containers in GroupObjects, the AHMI Controls must directly reference the PLCAddress and you forget about using the PLCAddressUDT mechanism.
This renders the GroupObject less usedful - better than Cut&Pasting (at least you can still do global modification by altering just one object) - but not as flexible as RA GlobalObjects with their tag placeholders.
-
I got up to step 10 of Archies instructions but "GroupObject" was not in my toolbox. I tried putting the downloaded file under "Controls" and then it did pop up in my toolbox but it wouldnt let me drag it down to my form.