Hello Guest it is March 29, 2024, 07:07:10 AM

Author Topic: Modbus and Sim  (Read 3047 times)

0 Members and 1 Guest are viewing this topic.

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Modbus and Sim
« on: August 10, 2016, 05:10:24 PM »
Does the Modbus I/O work when using the Sim as the motion controller?
Reason I am asking is I am having no joy with it.
I can open open the diagnostics for the Modbus and watch an output  bit enable/disable but the PLC doesn't see it.
if I send an Input to Mach4  from the PLC, I get nothing in Mach at al, not even in the diagnosticsl.

I have connected to Mach3 and all works as expected so I know the PLC is ok and the very simple ladder is fine.

Hood

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Modbus and Sim
« Reply #1 on: August 11, 2016, 05:29:12 PM »
Ok I have the modbus worked out.
You need to have your start address plus 1, so say an octal address of 2001.0, that would be decimal 1025 but in the plugin you need to set to 1026.
Now here is where it gets weird.
Send 2001.0 from the PLC and Mach thinks it is 2001.15
Send 2001.1 from the PLC and Mach thinks it is 2001.14
............
.........
Send 2001.15 from the PLC and Mach thinks it is 2001.0

So totally backwards.

Outputs from Mach are the same, address needs 1 added and outputs from Mach are backwards,
Tell Mach to send 4000.0 and it sends 4000.15 etc etc.

Hood

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Modbus and Sim
« Reply #2 on: August 17, 2016, 12:41:13 PM »
The modbus spec is leftmost bit is 0.  It is backwards, but that is how it is supposed to be.  The Mach 4 modbus implementations is true to the Modicon spec where it wasn't with Mach 3.  Addresses are base 1 instead of base 0 as well. 

See this:  http://www.modbusdriver.com/doc/libmbusslave/modbus.html

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Modbus and Sim
« Reply #3 on: August 17, 2016, 06:49:33 PM »
Thanks Steve, Brett had already mentioned it to me but that link has a lot of good info, thanks.
Would maybe be an idea to have a short explanation of the numbering in the plugin window for people like me who are used to the way Mach3 does it, would have saved me a couple of days messing about until I worked out what was happening.

Hood

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Modbus and Sim
« Reply #4 on: August 17, 2016, 11:48:11 PM »
Well...  it is funny.  I have never gotten so many complaints about doing something right in my life!!!!  :)  To me, it is the way it is supposed to be, coming from an industrial manufacturing background (we used a lot of modbus devices).  So I had to look a bit cross-eyed to get Mach 3 modbus working.  But Mach 3 people are so used to doing it the wrong way, I guess.  Anyway, funny how we can get used to something.  We could all probably get used to putting our right shoe on our left foot, given enough time!  :)

If you will look at the modbus connection page, you will see a checkbox to use zero based register addressing.  I put that in there because the right way was giving so many so much grief.  But the bits are still numbered backwards.  I don't think I thought about changing that around.  But the correct modbus way should be easier for us to support in the long run.  At least I hope so!

I'm glad you got it all worked out.  I think I did mention that it was base 1 way back when we first did that plugin.  But it is probably buried in annuls of this forum by now.  And for what it is worth, Brian STILL trips up on it!  :)

Steve

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Modbus and Sim
« Reply #5 on: August 18, 2016, 02:29:59 AM »
Steve,
 I saw the zero based box but it didn't seem to make any difference.
Maybe that was before I figured out the reversed sequence and thus didn't see it working in the diagnostics, will have to check.

Hood

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Modbus and Sim
« Reply #6 on: August 18, 2016, 02:35:48 AM »
Ok just checked, it is working so must have just been because I hadn't worked out they were reversed and didn't see it working or maybe that it  requires a restart to take effect.
Going to set it back to the base 1 way   as I am used to it now :D Oh and doesn't everyone put the left shoe on the right in the USA, I know Brett does. is he not normal? ;)

Hood
« Last Edit: August 18, 2016, 02:41:56 AM by Hood »

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Modbus and Sim
« Reply #7 on: August 18, 2016, 11:12:10 AM »
No, Brett is not normal at all.  But then again... neither am I.  :)  Anyone that plays with this stuff can't be normal.  Anyway, have fun with the modbus stuff. 

Steve

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Modbus and Sim
« Reply #8 on: August 18, 2016, 12:14:32 PM »
Steve is right Hood. We are all special (you included) and everyone gets a trophy. But you 2 deserve a bigger one because yall are specialer.  ;D
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Modbus and Sim
« Reply #9 on: August 18, 2016, 06:13:12 PM »
yes, my mum always said I was special :)