Dan Kohn's Automation Direct Field Point Module Project Page

Automation Direct Field Point Module Project


Project Overview:

Thanks to ebay, I got a nice set of Field Point I/O Modules sold by Automation Direct for about 1/3 the price. I love the idea of control over the internet and these modules seem like they would be fun to play with (and maybe be useful for home automation or other control application via the internet). Below is a blog of what I have done so far with them and what I have learned. Hope you find it useful and feel free to email me if you have any questions. I am NO expert, but I would be glad to help if I can.


Current Module Configurations:

Module #1

t1k-01dc t1h-ebc100 t1k-16nd3 t1k-08trs t1f-8ad4da2 t1k-16td2

Module #2

t1k-01dc t1h-ebc t1f-08ad1
Click on image or module type for spec sheet

Manuals:

Installation Manual
Ethernet Base Controller Manual


OPC Server:

First I wanted to establish communication with the Field I/O. After a setup process (see Ethernet Base Controller Manual for details) using the NetEdit3 software. After that, I found that I needed to use an OPC (OLE For Process Control) Server. On Automation Direct's Demo Software Website I found "KEPDirect Servers Download". The installation and setup went according to the Docs. Follow the steps from page 19 on to set up the program. In Step 6 on page 20, select "Automation Direct EBC" for the device driver and for Step 3 on page 27 select "Terminator I/O". On page 28 Step #4 make sure you use the IP address you defined using the NetEdit3 software. For Step 6 on page 31, I set "Startup" to "Always Generate On Startup" wich will define the I/O modules you have connected automatically each time you start the OPC server (Saves times if you are an experimentor like me). Remember to save the project so you dont have to do this over again.

To manipulate the I/O data points, see the section in the documentation "Use OPC Quick Client to Test Device Setup" to see how to look at and change data points via the OPC Quick Client.

You can also obtain a version of the KepServer Ex (an OPC server capable of communications with multiple PLC's and Fieldpoint Modules from the links below):

KepServer Ex
Alternate Source
archived version

Note: If you use the EX version (see below) make sure you select the Automation Direct EBC and Automation Direct Suite packages for installation!



Using OPC and Labview with the Fieldpoint Module:

The next thing I wanted to do was control the Fieldpoint module from the PC. I had some experiance with LabView and had read somewhere that LabVIEW could be used with OPC software. I investigated this and found some information that was helpful and was able to develop some very simple VI's to communicate with the Module so long as the OPC server is running. Below are links to download these VI's:
  • 1st
  • 2nd
  • 3rd
  • 4th
  • 5th


    Getting Values to Other Programs:

    Investigating OPC, I also found that there were programs that could get values from an OPC Server and place the data into other windows programs (Like Access and Excel). Once such program can be found Here. They do have a demo program for download (you only need to download the CLIENT ONLY) since I am assuming you have the KEP OPC Server running).


    Programming for Fieldpoint I/O:

    First Attempt

    The first attempt to program the Fieldpoint I/O using the
    Host Engineering SW Development Kit for C was not successfull, but if you want to see my notes on the attempt check the box and press update (uncheck and update to hide):


    Second Attempt

    Since I have had some time away from the project and I knew when I left it I was stuck [since I never could make any sense of what needed to be change to make the Host Engineering library compatible with the T1H-EBC (see above)]. I started looking in the documentation and found the list of protocols differed for the T1H-EBC and the T1H-EBC100. The T1H-EBC100 can use UDP/IP, IPX (just like the TH1-EBC) but it can also use TCP/IP, Modbus TCP. Since I know that ModBus is an industry standard, it might be easier to find libraries for it.

    I started looking for a Modbus TCP PHP library. Did not turn up any direct PHP libraries but, as expected, I did get a lot of hits for Modbus TCP. I found a number of references to ModPoll. It was recommended by a number of people as a very good test utility for Modbus TCP. I ran it, but had very little luck with it. It just didn't seem to jive with the documentation I had for addresses for various I/O. I then found another utility called SimplyModbusTCP1.3.2.zip This program not only worked but the documentation for it gave me a lot of hints. I found the page explaining Modbus TCP very helpful. Between that and the info on Screenshot of the program helped me make a link between the Terminator I/O Ethernet Base Controller Manual (Chp 4) and what I was seeing using an ethernet network analyzer. It also explained the packets more fully than any other document I have found so far. With this I am starting to gain an understanding of the request transmission.

    Knowing how Modbus TCP worked gave me some new insight into how to use ModPoll and giving it another shot I got it to run and give me back data from the I/O module. My hang up was that all the Fieldbus info on Modbus talked about addresses, but yet modpoll used reference values instead. I found that the following commands worked:

    Read Binary Inputs:
        modpoll -m tcp -a 1 -r 1 -c 16 -t 1 192.168.0.53

    Read Binary Outputs:
        modpoll -m tcp -a 1 -r 1 -c 8 -t 0 192.168.0.53

    Read A/D points:
        modpoll -m tcp -a 1 -r 1 -c 16 -t 3:int 192.168.0.53

    Read D/A points:
        modpoll -m tcp -a 1 -r 1 -c 8 -t 4:int 192.168.0.53

    Now that I got ModPoll working and giving me back data, I started to investigate FieldTalk™ which is a set of libraries for ModBus for various languages and platforms. They also allow downloads of trial versions if you register with them. I downloaded the Modbus Master Linux package as well as the documentation which was also available.

    I printed out the documentation for the Master Library, and found it very complete.

    I unziped the file FT-MBMP-EVAL.2.zip that I downloaded and put it on my linux box. The directory structure was exactly what the manual showed:
                 myprj
                   |
                   +-- fieldtalk
                       |
                       +-- doc
                       +-- src
                       +-- include
                       +-+ samples
                       | |
                       | +-- adam
                       | +-- modpoll
                       | +-- sersimple
                       | +-- tcpsimple
           	           |
                       +-+ lib
                         |
                         +-- {platform}    (exact name depends on platform)
    
    I was able to follow the instructions on Compiling and Linking with only minor modifications for directory structure, and within a few minutes had recompiled modpoll.cpp that was included in the sample directory.

    I also found, in the sample directory a program tcpsimple.cpp that was a less complicated program than modpoll, so I started to analyze that code.

    Modpoll.cpp would work for reading data from the fieldpoint module, but I also wanted to manipulate data points (Output and D/A points) so I started looking into this.

    I found the documentation for the MbusTcpMasterFunctions Class. The first functions I experimented with were writeCoil and readCoils. Using these two functions, as well as code segments from the tcpsimple.cpp and modpoll.cpp, I wrote a new program called coil_out.cpp. The program is called by the following:

        coil_out -a 1 -b 1 -v 1 192.168.0.53

    where:
        -a (slave address)
        -b (output point number)
        -v (value to send: 1 = on 0 = off)
        192.168.0.53 (IP of fieldpoint module)

    I do need to explain that the program needs to be run one time for each I/O point change. Since I want to call the program from a PHP script / HTML form to allow a point to be turned on or off from a webpage, this is NOT an issue. Also, the code is NOT very sophisticated and will not check for errors. It just sends the command then reads back the coil status.

    I was also able to create a program to manipulate the D/A output points. I was able to use writeSingleRegister to accomplish this. So the program d2a_cnt.cpp was created. It can be called by:

        d2a_cnt -a 1 -r 1 -v 1 192.168.0.53

    where:
        -a (slave address)
        -r (register address)
        -v (value to send)
        192.168.0.53 (IP of fieldpoint module)

    I did run across some interesting things dealing with the D/A points. First off, I needed to set a bit in a control register to activate the output. Although all my documentation shows that this should be at address 50023, when I use the above program I had to use -r 10023 to write to the control. To write to the D/A points I had to use address values of 1,3,5,7 for points 1,2,3,4 respectively. Not sure why (although it is partially explained by the memory map for the fieldpoint module D/A, it is not fully explained to my satisfaction yet (but it does work!)

    I finally called modpoll, coil_out and d2a_cnt from a php script / webpage form that allows the control fieldpoint module. I used the php instruction exec to call the programs. I think you will understand if I do no link to the control webpage, but here is a view of the WWW page:



    I still have a little more tweaking to do on the page, and I really need to find an application for the work done here (need to find something really neat to control and measure), but I do consider this project a huge success!


    Third Incarnation

    7/19/2013
    Did a new install of Linux (to 64bit Debian Wheezy). Found the FieldTalk libraries would not compile (although their were blogs offering solutions, none seemed to work). Started looking for alternative to recreate the project. Found libmodbus. Actually found it very easy to use and the routines were well documented. Not much sample code available, but was easy to figure out (only took a few hours to get code working).

    Some Notes

    installed packages libmodbus-dev and libmodbus5

    directories of interest:

        /usr/include/modbus
        /usr/share/doc/libmodbus-dev/examples
        /usr/lib/libmodbus.so

    To Compile code

    gcc -I /usr/include/modbus/ filename.c -o filename -lmodbus

    NOTES: Code defaults the TCP port to 1502 but the FieldPoint Module is port 502

          Found this library very easy to use and to get working once I saw the libmodbus routine documentation

    More info

    libmodbus
    GitHub libmodbus


    last update: 7/19/2013