Shop OBEX P1 Docs P2 Docs Learn Events
Stamp communicating over serial cable and XBee's to PLC - updated with more wir — Parallax Forums

Stamp communicating over serial cable and XBee's to PLC - updated with more wir

stamptrolstamptrol Posts: 1,731
edited 2014-06-07 08:03 in Robotics
·Hi folks.

·A lot of my projects·are industrial control systems and many of them require communication among different devices.

·In a recent PLC (Programmable Logic Controller) course I taught, the PLC I chose for the trainers was the new KOYO CLICK series. Very inexpensive, free software and extensive hardware features, including two serial ports and commands for moving data around the registers. After the course, I thought it might be a neat exercise to get the Stamp and the PLC to communicate.

·The Stamp runs a small program that sends out 3 address characters, followed by a byte which is tracking a counter that gets updated about once a second. When the PLC· gets the byte, it displays the value in binary on the lights connected to its outputs. Then, the PLC reads its inputs (1 NO pushbutton, 1 NC pushbutton, and a 2-position selector switch) and sends that back to the Stamp. The Stamp displays that value in binary on its low order·byte (OUTL). The Stamp program is attached. Also attached is a pdf of the ladder logic program running in the CLICK PLC.

·I've included a picture of the overall system showing the CLICK PLC trainer connected by a serial cable to the Stamp which is mounted on an EnT general purpose i/o board which I designed several years ago and it is the heart of many of my projects. The only additional parts used are the serial cable with a modular plug on one end to fit the PLC and a MAX233 chip to convert the Stamp serial levels to those expected by the PLC.

· This communication allows easy expansion of the i/o for a Stamp, or can give the PLC some extra processing power not usually available in small PLC's.

· Then, I thought that if it works with a cable, maybe having it work wirelessly would be kind of interesting to try as well.

· I had·a set of XBee 1 mW modules and also had a set of SparKFun breakout boards for the XBee's. There are many variations of breakout boards around and all I can say is that the extra $10 is well worth it. They do the level shifting from 3.3 v to 5 v, they accomodate the tiny spacing of the XBee pins and they also provide some indicator LEDs which make troubleshooting easier by showing data in, data out and also RSSI and Power ON. On mine, I soldered a 4-pin header on one end so the board can plug directly into a breadboard.

·· What I wanted was the ability to unplug the serial cable, plug in the XBee's and have the system function with a minmum of fiddling around with XBee settings. So, each XBee got a MAX233 chip to make all serial signals "real" as opposed to the ttl levels normally spoken by XBee's.
··
·· In looking for an easy way to set the XBee comm parameters (1200/8/N/1 in this case), I loaded the free X-CTU utility from Digi/Maxstream on my laptop and in a short time had clicked my way through the changes. In using X-CTU, just keep reminding yourself that two menus are used: the one labeled "PC Settings" sets the laptop serial port settings and the tab labeled "Modem Configuration" is the XBee settings. They have to match in order to talk to your XBee module over the standard serial cable. Click on "Read" and it will retrieve the current settings, make any changes (like baud rate), then click "Write" to update the XBee.

· Adding a couple of 9-pin connectors to the XBee/Max233 setups allowed plugging in to the Stamp on one side and the PLC on the other.

··Powered on and lights started blinking on both ends to confirm the two-way conversation.

· Haven't tried for maximum distance yet, but with one unit in the basement and the other at the opposite end of the house upstairs, everything keeps on ticking along.

· More pics show the setup running with the XBee's and I've included the connection diagrams as well for both configurations.

· Happy to answer any questions.


· http://www.youtube.com/watch?v=_0tLGrKDyBI···· ---added Mar 11/10


· Cheers,

·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk

http://www.siskconsult.com


Post Edited (stamptrol) : 6/25/2010 5:22:55 PM GMT

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2010-03-11 00:51
    ·Here are the connection diagrams for the previous post.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2010-03-11 13:57
    Tom , a nice project , I would think it opens up possibilities for such things as a wireless HMI or perhaps the equivelent to the AB Dataliner.

    Looks lke programming is through a serial interface , is it possible to do on line edits wirelessly , maybe even have a network of PLC's with on line editing enabled.

    Jeff T.
  • stamptrolstamptrol Posts: 1,731
    edited 2010-03-11 14:18
    Hi Jeff,


    The programming of the PLC is indeed via serial port 1 but I don't think this little guy ( at $69) is set up to deal with the latency of the the wireless link. Also, at this level of PLC, the editing can be done while the process runs, but the download takes it off-line for several seconds. But, its worth a try. I'll report in once I get a chance to try it. There is a small HMI that works off the port, so it just might respond with a wireless link. From what I remember of the Dataliner, it should work.

    I also want to use the XBee's with Quicktrol that we worked on a while ago.

    Now that the building blocks are in place, there are lots of possibilities.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com


    Post Edited (stamptrol) : 3/11/2010 2:23:11 PM GMT
  • stamptrolstamptrol Posts: 1,731
    edited 2010-06-25 17:23
    ·I've just uploaded some additional demo video of using the Stamp, XBee's and operator interface software.

    · http://www.youtube.com/watch?v=JvG6TBVrh8c

    ·




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • davejamesdavejames Posts: 4,047
    edited 2010-06-25 20:07
    ...a very easy-going, informative demo.

    First time I've seen the XBee in use and that's prodded some thoughts.


    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • agus_martuaagus_martua Posts: 6
    edited 2012-08-07 02:59
    Hy everyone, I'm a newbie..
    I want to ask to you, how to connect XBee to PLC?
  • stamptrolstamptrol Posts: 1,731
    edited 2012-08-07 07:37
    I never had the need to get the XBee to program the PLC, but they will work to retrieve data from the serial port. See the drawings in post #2.

    Which PLC do you want to use and what connectivity do you need? (program wirelessly, data, or both).

    Cheers,
  • agus_martuaagus_martua Posts: 6
    edited 2012-09-05 10:18
    I want to use PLC CPM2A.. I need a connectivity program wirelessly and data.
    Can you explain to me? If you have the program, please upload.
    Thank you. :smile:
  • agus_martuaagus_martua Posts: 6
    edited 2014-05-06 03:36
    Can you explain to me pleaseee...
  • stamptrolstamptrol Posts: 1,731
    edited 2014-05-06 05:33
    The basic connections and program are shown in the photos and other docs attached to post #1 and post #2.

    Please let me know what specifically you need.
  • agus_martuaagus_martua Posts: 6
    edited 2014-06-07 08:03
    How to send string data from PLC to RS 232?
    Thanks..
Sign In or Register to comment.