Author Topic: EthernetIPforSLCMicroCom  (Read 6386 times)

dhananjay.j@outlook.com

  • Newbie
  • *
  • Posts: 16
    • View Profile
EthernetIPforSLCMicroCom
« on: May 04, 2018, 06:58:28 AM »
I am using AdvancedHMIv399x. I am not using any UI Controls, I am just using EthernetIPforSLCMicroCom.Read and Write.
Recently I came across the Subscribe Event where PLC Polls Data after a Declare Time Interval. This will save me a Lot of Time for updating Values from PLC as 1by1 fetching Tags takes 10 ms (Specified on some other discussion). I can Fetch all Real bits normally with subscription but unable to work with Boolean Tags like B3:10/0-1-2-3 etc. and Timer valueslike T4:9.PRE, ACC, EN,DN values of all T4 tags list. Either this gives me error saying too small or too large value. or Event is not called entirely. Can you provide me a solution to subscribe ti Polling of Counters, timers and boolean values? I am using C# for programming.

I just need 2 Lines of code for reference to correct my logic.
I need correct
var Timers = Connection.Subscribe("Timertag", 50,100ms, Subscribedevent);
var Counters= Connection.Subscribe("CounterTag", 50,100ms, Subscribedevent);
var BooleanBits = Connection.Subscribe("BooleanBitTag(eg. B3:0/1)", 50,100ms, Subscribedevent);

I also use this

EthernetIPforSLCMicroCom  Connection = new EthernetIPforSLCMicroCom  ();
Connection.IP = "MyIP";
Connection.SubscriptionDataReceived += Connection_SubscriptionDataReceived;

To read values

If you can give me that My problems will be fixed. Nothing more to discuss. I am on a clock.

dhananjay.j@outlook.com

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: EthernetIPforSLCMicroCom
« Reply #1 on: May 04, 2018, 07:31:34 AM »
Hi, I am on a clock here so any help is good. The connection either causes an error(in case of timers,) or dont call event handler at all.(in case of Counter Tags). in case of booleans it returns next tag values instead of bit values true false.

Update
 Counters and Timers go to oveflow Exception after subscription. while Booleans go to next Tag instead of Bit (B3:1, B3:2 instead of B3:1/0, B3:1/1).
« Last Edit: May 04, 2018, 07:55:29 AM by dhananjay.j@outlook.com »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforSLCMicroCom
« Reply #2 on: May 09, 2018, 04:50:23 PM »
I just tested this out and it works as expected for me:
Code: [Select]
    Private SubID As Integer
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SubID = EthernetIPforSLCMicroCom1.Subscribe("T4:0.PRE", 1, 0, AddressOf DataReturned)
    End Sub

    Private Sub DataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
        If e.PlcAddress = "T4:0.PRE" Then
            Me.Text = e.Values(0)
        End If
    End Sub

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforSLCMicroCom
« Reply #3 on: May 09, 2018, 04:52:43 PM »
I see the difference now. You are using SubscriptionDataReturned which doesn't seem to work. Use the DataReturned event.

This can be fixed by modifying EthernetIPforSLCMicroCom at line 304:
Code: [Select]
    Private Sub DataRecSync(ByVal e As Object)
        Dim e1 As MfgControl.AdvancedHMI.Drivers.Common.SubscriptionEventArgs = DirectCast(e, MfgControl.AdvancedHMI.Drivers.Common.SubscriptionEventArgs)
        e1.dlgCallBack(Me, e1)
        MyBase.OnSubscriptionDataReceived(e1)
    End Sub
« Last Edit: May 09, 2018, 04:59:16 PM by Archie »

dhananjay.j@outlook.com

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: EthernetIPforSLCMicroCom
« Reply #4 on: May 12, 2018, 01:02:48 AM »
Hi Archie,
I am fetching singular values directly by Read method. My requirement here is I want to fetch Timers, Counters & "B" tag values in bulk. I am doing this using subscription for "F" type floating values. eg. I am fetching F20:0 to F20:89 values in a single subscription. Like this If I want to fetch Timer values (like T4:0.ACC to T4:89.ACC, From  T4:0.PRE to T4:89.PRE etc)
Counter values (like C5:0 to C5:89) and boolean bits(B3:0/0 to B3:0/15 etc).
out of these Boolean seems to be giving me error. and returning Numbers like 2,16189 etc if I suscribe to (B3:0,100,100,eventHandler). Do I need to Convert These Values to Binary and then use Bits as true false?.

We work mostly on very complex logical HMI softwares where automation is required and Human interactions are very less. So we don't directly use advanceHMIcontrols but this driver is doing the Magic! Currently my application is working but its very slow due to use of Read and writes which take approx 10ms each (as suggested by you in some other post I read), Following will solve all my issues for all my clients.

Is there a way I can subscribe to PLC Polling to receive all Configured Tags like Rockwell RSLinx Does? If yes, is it a Array of Strings like in case of Subscribe()? If yes, How can I subscribe so that I can separate each tag values (like Convert.ToDouble(e.Values["F20:0"]) C#).

If this is available, then forget my original Question.
If not available, do you suggest /is it Fast enough to subscribe to all Tags individually like ("T4:0.PRE",1,0,eventHandler)?
I can not Thank you enough for doing what you do!

(I am from india, and this is like 10:30 AM here... Hence the Post Timing. I hope you understand)
« Last Edit: May 12, 2018, 01:05:20 AM by dhananjay.j@outlook.com »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforSLCMicroCom
« Reply #5 on: May 12, 2018, 02:35:54 AM »
First off... there is a confirmed issue when subscribing to more than 1 consecutive bit. For instance, if you subscribe to 10 bits starting at B3/0 it will only return the first bit. This issue is being addressed and an updated beta version should be available in a few days with the fix.


Before jumping into using all subscriptions, it's important to understand the 3 techniques of reading data with the driver.


Read (Synchronous reading)
Pro - Minimal code required making it very easy to implement.
Con - It is a blocking operation. If called from the UI thread, the UI will be unresponsive until data is returned from the PLC


BeginRead (Asynchronous reading)
Pro - Non-blocking operation that returns immediately after queueing the request, therefore will not freeze the UI thread
Con - Requires more code to implement. Since requests are queued, it is the developer's responsibility to throttle the rate of calling, otherwise a "send que full" exception can occur if requests are sent too fast

Subscription (Continuous refresh at a rate set by PollRateOverride)
Pro - Simplifies the code needed to receive values at a regular interval. The driver will optimize communications by grouping multiple subscriptions into a single packet when possible.
Con - Code can be complex to implement. A large number of subscriptions can put excessive load on the communication link. It is the developers responsibilty to maintain subscription IDs in order to unsubscribe when finished.


It sounds like you want to subscribe to a fairly large amount of data which is not a problem, but can potentially bottleneck your bandwidth and slow all communications.

You can subscribe to as many items as you wish. The callback specified by your subscribe will return an array of values matching the number of elements the subscription specified. For instance, if you peform:

SubID = EthernetIPforSLCMicroCom1.Subscribe("N7:0", 10, 0, AddressOf DataReturned)

then DataReturned subroutine will be called at an interval set by PollRateOverride driver property and e.Values will be an array of 10 values.

« Last Edit: May 12, 2018, 02:39:45 AM by Archie »

dhananjay.j@outlook.com

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: EthernetIPforSLCMicroCom
« Reply #6 on: May 14, 2018, 05:25:45 AM »
I have used subscriptions so many major processes in my application are boosted in speed. But there is still a bug(May be) in subscribing to multiple Tags using same instance of EthernetIPforSLCMicroCom. I am working on creating a solid code example so that it can be reproduced for you to test. The primary observation is
1.
EthernetIPforSLCMicroCom  PLCconnection;
PLCconnection.SubscribeToPlcValues("F20:0", 90, 100, CallBackHandler); (C#)
with or without
PLCconnection.SubscriptionDataReceived += DataReceivedHandler (C#)
In some cases "DataReceivedHandler" is called while in others "CallBackHandler" is called. Again I'll put up a code that can reproduce this.
2. Once a "Read failed:No Response" exception occures (With my current PLC this is more frequent) The Polling is stopped and need to re-initiated. (If we can predict if PLC connection is lost or is too busy to respond we can wait and avoid this. But Currently there seems to be no way of doing this. )
3. If more than 1 subscription with single instance of EthernetIPforSLCMicroCom. Only 1 is called(preferably 1st one). Others are ignored. Again Not Confirmed when, will put up code.

 Now the Question remains,
1. Can we do somthing like check if EthernetIPforSLCMicroCom.IsConnected (available to Read and write)? if there is other way to this, its Most welcome...
2. Can we replicate polling like RSLinks receive from PLC. (All Setup tag(F's N's I's, O's, C's etc) values are polled every 100ms)? Cause we definitly need a lot of tags as we have like 10 different cycles running at a time in single PLC consuming Multiple Timers, Counters, PID's and all sort of hardwares values each.

If these 2 things Happen I think you'll have answered Half the PLC world issues :)

Thanks,
Dhananjay

dhananjay.j@outlook.com

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: EthernetIPforSLCMicroCom
« Reply #7 on: May 15, 2018, 02:44:09 AM »
Also, I usually get "MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException: Read Failed - 240. Error code in EXT STS Byte" and I have implemented a Retry policy for that. I googled alot even got the PLC Exception booklet but there is no specific explaination for this. Can you help me with this as to how to avoid this?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforSLCMicroCom
« Reply #8 on: May 15, 2018, 03:21:44 AM »
Also, I usually get "MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException: Read Failed - 240. Error code in EXT STS Byte" and I have implemented a Retry policy for that. I googled alot even got the PLC Exception booklet but there is no specific explaination for this. Can you help me with this as to how to avoid this?
It means there is an extended status code. The driver is supposed to return the extended code. Since it doesn't the only way to see it is to do a Wireshark capture.

Page 130 of this manual explains the codes:

http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1770-rm516_-en-p.pdf

dhananjay.j@outlook.com

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: EthernetIPforSLCMicroCom
« Reply #9 on: May 15, 2018, 11:58:11 AM »
I have used subscriptions so many major processes in my application are boosted in speed. But there is still a bug(May be) in subscribing to multiple Tags using same instance of EthernetIPforSLCMicroCom. I am working on creating a solid code example so that it can be reproduced for you to test. The primary observation is
1.
EthernetIPforSLCMicroCom  PLCconnection;
PLCconnection.SubscribeToPlcValues("F20:0", 90, 100, CallBackHandler); (C#)
with or without
PLCconnection.SubscriptionDataReceived += DataReceivedHandler (C#)
In some cases "DataReceivedHandler" is called while in others "CallBackHandler" is called. Again I'll put up a code that can reproduce this.
2. Once a "Read failed:No Response" exception occures (With my current PLC this is more frequent) The Polling is stopped and need to re-initiated. (If we can predict if PLC connection is lost or is too busy to respond we can wait and avoid this. But Currently there seems to be no way of doing this. )
3. If more than 1 subscription with single instance of EthernetIPforSLCMicroCom. Only 1 is called(preferably 1st one). Others are ignored. Again Not Confirmed when, will put up code.

 Now the Question remains,
1. Can we do somthing like check if EthernetIPforSLCMicroCom.IsConnected (available to Read and write)? if there is other way to this, its Most welcome...
2. Can we replicate polling like RSLinks receive from PLC. (All Setup tag(F's N's I's, O's, C's etc) values are polled every 100ms)? Cause we definitly need a lot of tags as we have like 10 different cycles running at a time in single PLC consuming Multiple Timers, Counters, PID's and all sort of hardwares values each.

If these 2 things Happen I think you'll have answered Half the PLC world issues :)

Thanks,
Dhananjay

Also anything on this? I thought this is a community forum but all I receive is responses from Archie...
Actually as a user we must have developed many strategies to solve these issues but no one is looking intereseted in sharing one. Thanks Archie.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: EthernetIPforSLCMicroCom
« Reply #10 on: May 15, 2018, 01:00:54 PM »
Archie is the mastermind behind this project, so if anybody can help you then he can.

You should focus on providing the "solid code example so that it can be reproduced for you to test", as you suggested.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforSLCMicroCom
« Reply #11 on: May 15, 2018, 01:30:14 PM »
Also anything on this? I thought this is a community forum but all I receive is responses from Archie...
Actually as a user we must have developed many strategies to solve these issues but no one is looking intereseted in sharing one. Thanks Archie.
I have been waiting on your example code to demonstrate any bugs you found.

dhananjay.j@outlook.com

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: EthernetIPforSLCMicroCom
« Reply #12 on: May 15, 2018, 03:57:12 PM »
Currently we are focusing on completing the project with what works "The Fastest" and fits the BW limitations of PLC. So having a little time to do some Testing, but will definitely post it once I am done here. But those are my observations may be I am right/Wrong.

For the sake of Professionalism, If you (Archie, Team and the viewers) have not found any way to "full scale PLC Tag poll" or "PLC Connection Flags(like Online, Offline, Busy, Available) etc. Please let me know so that I'll stop looking for now...
All our current Indicators are "Read Failed: No Response from PLC" Exceptions (try catch is slowing code like hell), worst case scenario is we do 10 Retries before we give up on a Read Write Operations. That number might have to be increased as complexity increases... And because our client can't afford additional PLCs (We use Micrologix 1400 A...)  right now as we are on tight budget... we have to make due on 1.

Thats the story of a developer... agreed? :D

dhananjay.j@outlook.com

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: EthernetIPforSLCMicroCom
« Reply #13 on: May 15, 2018, 04:04:25 PM »
Archie is the mastermind behind this project, so if anybody can help you then he can.

You should focus on providing the "solid code example so that it can be reproduced for you to test", as you suggested.

All I am currently intersted in 2 things

1.
EthernetIPforSLCMicroCom .SubscribeToAllPLCTags(100sPollrate, CallbackHandler);

void CallbackHandler(obj sender, args e)
{
foreach(var value in e.values)
{
var TagName = value.Address;
var TagValueString = value.Value;
}
}

2. var con = EthernetIPforSLCMicroCom.GetConnection(IPAddress);
if(con.IsConnected)
{}

switch(con.status)
{
case PLCStatus.Offline: con.Connect(); break;
case PLCStatus.Online: return "OK";
case PLCStatus.AvailableToReadWrite: return "Thank God";
.........
}

Is it good enough pseudo code?

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: EthernetIPforSLCMicroCom
« Reply #14 on: May 15, 2018, 04:27:32 PM »
I would say that what you posted looks more like a wishful thinking.

A "solid code example" to me would be an example that I could copy and paste into a project, run it and see what responses come from a PLC.
Minor modifications to that example could be done if necessary.