Shop OBEX P1 Docs P2 Docs Learn Events
Modbus TCP — Parallax Forums

Modbus TCP

JordanCClarkJordanCClark Posts: 198
edited 2013-07-17 12:46 in Propeller 1
Hey all,

Has anyone made up a MODBUS/TCP object that they're willing to share? I currently have four program launches going on at the same time, so writing one is on the backest of back-burner projects, but I don't want to necessarily re-invent something that may already exist.

I've been developing our SCADA / HMI / Web applications using Ignition from Inductive Automation. Usually for small process items I'll use a small PLC from EZ-Automation, which I've already integrated well into Ignition. But I got to thinking about how snazzy it would be to integrate a Prop. Sorry to have digressed a moment, but a little background may be useful to you.

This is not going into a resale application, as this is really to help monitor processes out on our plant floor-- and maybe help me bring 'em kickin' and screamin' up to Y2K...:lol:

Thanks!

Comments

  • MicksterMickster Posts: 2,694
    edited 2012-11-06 12:12
    I guess the answer is no! I was kinda hoping for a positive response to this.

    Cheers!

    Mickster
  • JordanCClarkJordanCClark Posts: 198
    edited 2012-11-06 12:28
    I was going to comment on the awkward silence in this thread... the chirping of the crickets... the dropping pin... my feelings would have been really hurt if it wasn't for my overwhelmingly huge ego! =D

    Really, as I said, it's not a big deal. Someone's got to be the first. It just so happens it may be me... just not any time soon.
  • kwinnkwinn Posts: 8,697
    edited 2012-11-06 17:59
    I would like to help and to become familiar with Modbus, but like you I already have too many irons in the fire. There are Modbus to TCP devices out there, and perhaps one of them could be used. Take a look at http://us-mkt.moxa.com/mus-en-dn-fieldbus-gateway/?gclid=CILakIvgu7MCFStgMgod0EkAJg to start.
  • whickerwhicker Posts: 749
    edited 2012-11-06 19:16
    On most of the industrial devices I have seen, modbus tcp is basically sofware-only.
    If it can talk on ethernet using tcp packets, you can do the little bit more work to interpret and send the serial character stream.

    wow, this article is incredibly thorough for being wikipedia:

    http://en.wikipedia.org/wiki/Modbus

    It shows the frame format, and the function code.
    looks like an easy job for the Spinneret, but searches reveal nobody has actually completed such a project yet.
  • JonnyMacJonnyMac Posts: 9,107
    edited 2012-11-07 00:11
    I did a project using MODBUS RTU last year that worked out well. That said, I used two cogs to simplify the code and am working to consolidate to a single cog. Once I do that I will post in ObEx. The code was used for a control board to talk with a remote touch screen. After sorting out some of the touch screen details we got it all working.
  • JordanCClarkJordanCClark Posts: 198
    edited 2012-11-07 02:33
    Thanks for the replies! Jon, I look forward to seeing what you've come up with.

    I found these guys yesterday. They provide a free master and slave simulator, but also supply the source code with it. Perhaps a foray into GCC to port it over may be viable.

    Okay, jumping back into the grind. Send in the search dogs if I'm not back...
  • i8051i8051 Posts: 3
    edited 2012-11-07 09:01
    If you have a code for simple serial RTU, then for turn it over TCP there is simple way :-) take a look here: http://gridconnect.com/industrial-protocols/modbus/modbus-rj45.html

    BTW, I use subset of serial MB RTU in one of my projects as simple state machine in plain vanilla SPIN :-) I has a luxury to deal with only floating points to transfer ;-)
  • JordanCClarkJordanCClark Posts: 198
    edited 2012-11-07 09:39
    i8051 wrote: »
    If you have a code for simple serial RTU, then for turn it over TCP there is simple way :-) take a look here: http://gridconnect.com/industrial-protocols/modbus/modbus-rj45.html

    Gotta say, they look pretty slick. It also appears they have one for Modbus/RTU to Ethernet/IP as well.
  • i8051i8051 Posts: 3
    edited 2012-11-07 13:27
    It should not stop you from creating your control system on Propeller with the MB RTU and just delegate the TCP communication task on this units ;-)
    Any way, TCP connection will be driven by external chip with Propeller.

    Stay inspired !
  • Dave MatthewsDave Matthews Posts: 93
    edited 2013-06-10 11:54
    JonnyMac wrote: »
    The code was used for a control board to talk with a remote touch screen. After sorting out some of the touch screen details we got it all working.

    Hi JonnyMac, I am looking for code similar to what you have prepared. I haven't found it in the ObEx yet, could you post it or direct me to it please?

    Dave
  • JonnyMacJonnyMac Posts: 9,107
    edited 2013-06-10 14:27
    I haven't finished the MODBUS object yet, but have done some work on the underlying half-duplex RS-485 code.
  • Dave MatthewsDave Matthews Posts: 93
    edited 2013-06-11 06:27
    Thanks for the reply. I am working on controls to an Automation Direct 'C-More' touch screen operator interface. I have just gotten started so I was looking to see what prior code was written and available.

    Dave
  • JonnyMacJonnyMac Posts: 9,107
    edited 2013-06-11 08:08
    I have an idea for an article about MODBUS so that gives me reason to button up the code. Like I said before, I have it working in a commercial product using two cogs; just want to distill it down to one. It was fun getting a call from the client during their testing; they loved seeing product settings change on the local display based on inputs from a remote [MODBUS-connected] terminal quite a long way away. For that project we had a cog to spare so I wasn't concerned about distilling the code (a friend frequently reminds me not to optimize too early).
  • pacmanpacman Posts: 327
    edited 2013-06-11 21:07
    There is a modbus RTU object in the Obex.

    Isn't the TCP version - just RTU (minus the checksum) encapsulated in an Ip header?
  • Dave MatthewsDave Matthews Posts: 93
    edited 2013-06-12 05:54
    Hi pacman,

    I have run your example code in the ObEx, and it works perfectly. It allowed me to verify my wiring and addressing. \\\What I need is modbus master code rather than slave. I am trying to determine the feasibility of a project...////

    OOPS! Just checked and the operator interface device is the master, the prop application would have to be the slave. Glad I checked (gulp!).
  • pacmanpacman Posts: 327
    edited 2013-06-12 17:07
    Glad it helped.

    I haven't had the chance to improve any further (life keeps getting in the way) but there are plans ...

    If you encounter any errors/bugs or areas for improvement I would love to hear from you.

    Enjoy
  • Dave MatthewsDave Matthews Posts: 93
    edited 2013-06-21 13:55
    I sure haven't found any bugs! I am slowly evolving my code based heavily on yours and Olivier's. I very much appreciate the fine documentation and the work you did getting the debuging messages and the print buffer. Many thanks for your work and posting it!
  • pacmanpacman Posts: 327
    edited 2013-06-22 15:29
    I sure haven't found any bugs! I am slowly evolving my code based heavily on yours and Olivier's. I very much appreciate the fine documentation and the work you did getting the debuging messages and the print buffer. Many thanks for your work and posting it!

    Excellent news.

    Yeah I work with industrial stuff every day and constantly find the lack of documentation in code a source of annoyance - I made a conscious decision (many years ago) to document better - I'm glad now I did

    When you done and dusted - please share your code so I can extract any really clever bits and incorporate into my "object".
  • Dave MatthewsDave Matthews Posts: 93
    edited 2013-07-17 12:46
    My adaptation of your code is by no means dusted off, and I doubt it will be anytime soon. I would like to send you a copy of what initial mods I made, I needed to address 500 registers so I modified the code to support that. In my application Function code 10 only sends a single register so I didn't improve that at all except to get it to work like Function code 06. If you would PM me an email address to send it to I will get it to you.

    Once again thanks for your work, it was a great benefit!

    Dave
Sign In or Register to comment.