Author Topic: PLC to C#  (Read 11201 times)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: PLC to C#
« Reply #15 on: July 01, 2015, 10:48:32 AM »
That capture is not reads coming from AdvancedHMI. I ran a quick test using address 0.0 and the memory area code is different. The AdvancedHMI driver doesn't have support for a read area code of 0xb0

pe.vallee

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: PLC to C#
« Reply #16 on: July 01, 2015, 11:14:06 AM »
Yet I started the DEBUG Visual Studio. I do not understand why I can see in WireShark
- In Strange Aeons even death may die -

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: PLC to C#
« Reply #17 on: July 01, 2015, 11:17:39 AM »
Do you still have the OPC driver running or CX-Programmer? What ever is communicating is reading every 10ms which is not giving AdvancedHMI a chance to get any communications in.

pe.vallee

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: PLC to C#
« Reply #18 on: July 01, 2015, 11:18:19 AM »
I shut the OPC Server down .. I don't know what is talking... :\
- In Strange Aeons even death may die -

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: PLC to C#
« Reply #19 on: July 01, 2015, 11:19:18 AM »
If you run WireShark without AdvancedHMI running, do you still see all of the Omron packets?

pe.vallee

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: PLC to C#
« Reply #20 on: July 01, 2015, 11:31:42 AM »
yes, even if both, the server and the AdvancedHMI are off, there's still packets. I resolved the question.... I used a switch between my CPU and my PLC, the switch give my PC an internet access..

the Omron packets are between the switch and the PLC..  when I disconnect the plc from the switch and plug it in my PC, the packets stop,

but even if I bypass the switch, I cannot sniff any AdvancecHMI packets from WireShark...

- In Strange Aeons even death may die -

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: PLC to C#
« Reply #21 on: July 01, 2015, 11:34:54 AM »
I'm kind of confused with your 2 IP addresses. They are on 2 completely different subnets, therefore must pass through a router somewhere. Was the switch you bypassed by any chance a router?

Are you now directly connected with an ethernet cable from your PC to your PLC?

pe.vallee

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: PLC to C#
« Reply #22 on: July 01, 2015, 11:38:46 AM »
this is the switch I used : http://ca.dlink.com/products/connect/8-port-gigabit-desktop-switch/

if I bypass it to connect VIA an Ethernet cable my pc to my plc I will no longer connected to the internet but I'll have a direct link to my plc
- In Strange Aeons even death may die -

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: PLC to C#
« Reply #23 on: July 01, 2015, 11:54:04 AM »
You need to get your PC and PLC on the same subnet. For example the PC IP address of 192.168.0.5 and the PLC 192.168.0.10

The 10.xx.xx.xx is another private network but on a different subnet.

pe.vallee

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: PLC to C#
« Reply #24 on: July 01, 2015, 01:45:34 PM »
IT WORKS!!!   AT LAST !!

The IP address 192.168.0.149 is the address of my Network Card  the IP address 10.10.3.40  is the address of my PLC the switch give to it ..    don't know why I haven't thought of it before !!
- In Strange Aeons even death may die -

pe.vallee

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: PLC to C#
« Reply #25 on: July 01, 2015, 01:47:42 PM »
Many thanks for your help and for your time !!

I'll to work with the Advanced HMI :)

Best Regards !!!
- In Strange Aeons even death may die -

pe.vallee

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: PLC to C#
« Reply #26 on: July 02, 2015, 08:15:56 AM »
One last question about that... :P

If, instead of a Form I want to use a console application.

I've create and Driver Object
Code: [Select]
private static AdvancedHMIDrivers.Omron.OmronEthernetFINSCom o_IPAdress = new AdvancedHMIDrivers.Omron.OmronEthernetFINSCom();
and then give him an IP Address
Code: [Select]
   o_IPAdress.IPAddress = s_address;
Then, I got this exception throwed by OmronEthernetFINSCom.vb
Code: [Select]
System.Exception was unhandled
  HResult=-2146233088
  Message=Incomplete Solution
  Source=MfgControl.AdvancedHMI.Drivers
  StackTrace:
       à MfgControl.AdvancedHMI.Drivers.Omron.FinsTcpDataLinkLayer..ctor()
       à MfgControl.AdvancedHMI.Drivers.Omron.FinsTcpDataLinkLayer..ctor(String ipAddress)
       à AdvancedHMIDrivers.Omron.OmronEthernetFINSCom.CreateDLLInstance() dans C:\Users\pe.vallee\Documents\Visual Studio 2013\Projects\PLCToFileThread\AdvancedHMIDrivers\Omron\FINS\OmronEthernetFINSCom.vb:ligne 133
       à AdvancedHMIDrivers.Omron.OmronEthernetFINSCom.set_IPAddress(String value) dans C:\Users\pe.vallee\Documents\Visual Studio 2013\Projects\PLCToFileThread\AdvancedHMIDrivers\Omron\FINS\OmronEthernetFINSCom.vb:ligne 31
       à PLCToFileThread.PLCToFileThread.Main(String[] args) dans c:\Users\pe.vallee\Documents\Visual Studio 2013\Projects\PLCToFileThread\PLCToFileThread\Program.cs:ligne 49
       à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       à System.Threading.ThreadHelper.ThreadStart()
  InnerException:


What did I do wrong ?
- In Strange Aeons even death may die -

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: PLC to C#
« Reply #27 on: July 02, 2015, 08:26:09 AM »
Incomplete Solution means there is something missing from the project. Maybe the controls references or some of the drivers. AdvancedHMI only works as a compete solution with all of its original components and references.

pe.vallee

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: PLC to C#
« Reply #28 on: July 02, 2015, 09:29:22 AM »
I did what you suggest :
  • Create a C# Form project in the solution AdvancedHMI
  • Insert the driver OmronEthernetFINSCom  and give if the IP address
  • Create a basic label and linked it to the address 0.0 of my PLC
While executing the debug, I can see the value of the label change immediately when I toggle the button plug in the PLC address,
what is the
Code: [Select]
basicLabel1 property or method to call to acces the value of the label from the Console ?!
I tried in an
Code: [Select]
while( true )loop the code
Code: [Select]
Console.WriteLine( "basicLabel1 : " + basicLabel1.value);
( and many other properties and method but I can't see the value printed in the console..
even a basicLabel1.Refresh(); before the Console.WriteLine();   but it doesn't work :(
« Last Edit: July 02, 2015, 09:32:35 AM by pe.vallee »
- In Strange Aeons even death may die -

pe.vallee

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: PLC to C#
« Reply #29 on: July 02, 2015, 10:04:52 AM »
at last , I finally found my problem ....
in my Main I wrote
Code: [Select]
            basicLabel1.ValueChanged += basicLabel1_ValueChanged;

and in basicLabel1_ValueChanged() I wrote
Code: [Select]
            Console.WriteLine( "basicLabel1 : " + basicLabel1.Value );

finally!!! :P
- In Strange Aeons even death may die -