Hello Guest it is March 29, 2024, 06:58:09 AM

Author Topic: Interface with Industrial PLC (Ethernet or other options)  (Read 2848 times)

0 Members and 1 Guest are viewing this topic.

Offline bcoop

*
  •  61 61
    • View Profile
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #10 on: April 29, 2020, 06:46:57 PM »
Mike,  so if your poll interval for modbus is set for 100ms,  and the denominator for a MB function is set to "4"  then the scan rate for that function would be 100/4 =25ms.

16/32bit data show up as registers, and can be used just like any register accessible from the register plugin. viewable in diagnostics.
Bits don't show up there, but they do show up were you assign your I/O signals - see snapshot


Bob
Bob

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #11 on: May 12, 2020, 01:41:04 AM »
Coils and discrete inputs (outputs and inputs) show up as output and input objects in Mach.  And can be operated on via the mcIo*() API calls. 

I should have called the scan denominator a multiplier or "read every n cycles".  I have to change that!   If your scan time is 100ms, and scan denominator is 4, then the function is performed every 4 cycles (every 400ms) milliseconds.  Is is a way to SLOW the function.

All modbus devices implement things differently.  Sometimes, you may be reading a version or the like that comes from SLOW NVRAM.  If you have to read something like this, it can slow you whole scan!  So if you separate the slow read into its' own function, then you can read it less often via the multiplier (what is now called the denominator).

Also, in the later modubs plugins (4458 and up) you can control the plugin via its command register called mbcntl.  Look for it in the regfile plugin diag window.  You can actually test the commands in that interface.

mcRegSendCommand() will send the command and receive the response and it is a nice robust way to control a plugin that provides such a command register.

Anyway, the commands you write to the register are:
stop
start
restart

By themselves, they will operate on the plugin as a whole. But now you can operate on the device and function levels as well! Do this with the name of the device as seen in the modbus diag window.

start modbus0
stop modbus0
restart modubus0

Next, you can drill down to the function level.

start modbus0/fucntion1
stop modbus0/fucntion1
restart modubus0/function1

:) Total control now. So for your slow NVRAM read, just create another function and stop it when you don't need to read it anymore.

Here is the example in code:
Code: [Select]
hReg, rc = mc.mcRegGetHandle(inst, 'mbcntl/command');
response, rc = mc.mcRegSendCommand(hReg, 'stop modbus0') -- response will be OK or FAIL.
response, rc = mc.mcRegSendCommand(hReg, 'start modbus0')
response, rc = mc.mcRegSendCommand(hReg, 'stop modbus0/function1')
response, rc = mc.mcRegSendCommand(hReg, 'start modbus0/function1')

There is an Initial State that is defined at the function level too.  So you can control what is started at startup time.  In case you need to start a function up late with the command register.

Steve
« Last Edit: May 12, 2020, 01:57:41 AM by smurph »
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #12 on: May 17, 2021, 03:50:59 AM »
Thanks for the topic! You gave me a great idea!
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #13 on: May 17, 2021, 03:18:10 PM »
Thanks for the topic!
You realy give me a great idea for my project. How well I paused while working. Although I am waiting for my order and the courier anyway. In theory, he was supposed to deliver my order yesterday, it's strange ... I hope my modules  will come without damage. Honestly, next time I'd better order directly from the companies. However, I still have points that I could have done without modules, while I am doing my project. Thanks again for the topic and for giving me the idea! And yes, I think this is a pretty topical topic, so up topic.
« Last Edit: May 18, 2021, 05:56:07 AM by Tweakie.CNC »
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #14 on: May 20, 2021, 12:23:06 PM »
Steve,
So the command doesn't like two words in a name.  Click PLC doesn't work.  Click does.
So... I guess I'll just redo the entire modbus setup for the Click.  You guys should make a way to just rename a Modbus connection ;) 
Is there a way to start, stop, and restart the entire modbus?  Like hitting the stop and play button on the modbus diagnostics screen?
Chad Byrd

Offline jbuehn

*
  •  101 101
    • View Profile
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #15 on: May 20, 2021, 03:40:59 PM »
Using stop, start, and restart commands without specifying a device and function should act the same as hitting the stop/start button in the Modbus diagnostics screen.
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #16 on: May 20, 2021, 03:51:52 PM »
That'll do it!  HAHA  Why didn't I think of that!?!? Thanks Jbuehn!
Chad Byrd