ethernet to rs-232


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2005
    Posts
    14

    Default ethernet to rs-232

    I would like to control some old electronics over the network.
    has anyone seen a example of a ethernet to rs-232 converter with a pic
    in it.
    I've googled around, but all i find are webservers , but i just need a ethernet to serial (max-232) sample !

    Anybody got any ideas or suggestions ?

  2. #2
    Join Date
    Aug 2005
    Posts
    95


    Did you find this post helpful? Yes | No

    Default Try this

    http://www.lantronix.com/device-netw...rs/uds-10.html

    Not to shure if this is what you are looking for.

    Sphere.
    Last edited by Sphere; - 17th April 2006 at 15:53.

  3. #3
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Microchip recently released the ENC28J60 which is an Ethernet to SPI bridge. I haven't yet seen any sample PBP code to make use of it.

    There are numerous manufacturers who supply Ethernet-to-RS232 devices, frequently called serial servers. Some provide virtual serial port drivers for the PC end so legacy software sees them as serial devices. You can handle the PIC end with PBP code. The Lantronix XPort is one such device.

  4. #4
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    As I understand it the ENC28J60 is more than just plug and play. You have to load a TCP/IP stack onto a specific type of pic. My guess is the lantronix device is going to be the winner.

  5. #5
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DynamoBen
    As I understand it the ENC28J60 is more than just plug and play. You have to load a TCP/IP stack onto a specific type of pic.
    I don't think your understanding is correct. The ENC28J60 datasheet says...
    • The ENC28J60 is a stand-alone Ethernet controller with an industry standard Serial Peripheral Interface (SPI™). It is designed to serve as an Ethernet network interface for any controller equipped with SPI.
      ...
      With the ENC28J60, two pulse transformers and a few passive components are all that is required to connect a microcontroller to a 10 Mbps Ethernet network.

  6. #6
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    I completely undestand how it works. A few months back nuts and volts magazine covered it. Although it is an ethernet controller at the physical level you still need to manage the protocol. When I first saw it I thought it would be plug and play until I looked into it further. Trust me when I say it takes a fair amount of work for it to function the way the lantronix does.

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I currently use the Lantronix XPORT with a whole bunch of PIC- based projects.

    The Lantronix has a pin (CP2) that can be programmed to be a "carrier detect" pin. This pin goes "low" whenever a telnet session is in progress. I use that signal to "hijack" the RS232 port (using a 74HC125). That way, I get RS232 functionality when there is no active Ethernet session. It all works automatically with no manual switching.
    The best part about the XPORT is that you don't have to deal with protocol stacks or the processor overhead they it would take. The PIC just "talks" RS232 at 9600 baud.
    One downside - to change the IP address (or any other parameter) of the Ethernet port from the "serial side", you have to write what Lantronix calls Setup Records. These are 128 or 256 byte strings of Intel Hex. You have to write the entire record if you want to change only one variable.

    I can give details if anyone needs them.

    Charles Linquist
    Charles Linquist

  8. #8
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    I can give details if anyone needs them.
    I'd like the details.

  9. #9
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Below is an example of writing Setup Record '0'. There are 7 setup records in all. You don't need to write to all of them every time, but you have to write an ENTIRE setup record each time you want to change even one byte.

    For a better explanation, you will have to get a copy of "COBOX Setup Records" from Lantronix.

    First, you have to pull the XPORT's RESET line low for 500mSec and release it, then you start feeding it a series of lower case "z"s through the serial port. It will respond with a string (I just look for ANY response, and throw the string away). The 'zzzzzzzz's" put it in Command MODE. After that, you send the setup records themselves.

    Note that in the example below, I have "seeded" the Checksum register ("Z")
    with a 128. This is necessary because I didn't run the whole string through my checksum calculation routine. I only need to change certain bytes, IP, Protocol (tcp/ip or UDP), etc. So I ran only those through the checksum calculator. Also note that this calls a routine "BIN2IHEX" which calculates the Intel Hex values needed.


    ------------------------------------------------------------------------



    Z = 128

    HSEROUT ["S0"] 'Setup Record '0'
    PAUSE 150
    HSEROUT [13]
    Pause 550
    HSEROUT [":20000010"] 'Prefix
    FOR Y = 0 to 3 'IP address of unit
    X = IP[Y]
    Z = Z - X
    GOSUB Bin2IHex
    HSEROUT [MSN,LSN]
    NEXT Y
    Pause 10
    HSEROUT ["0000000000000000000000004C020000"] '4C is line interface mode
    '02 is baud rate. Last byte is
    Pause 10 'byte number 19

    X = LPortNo 'Port number of Xport LSByte
    Z = Z - X
    GOSUB Bin2IHex
    HSEROUT [MSN,LSN,"00"] 'MSByte of port number (always 0)
    X = RPortNo 'LSByte of Remote Port number
    Z = Z - X
    GOSUB Bin2IHex
    HSEROUT [MSN,LSN,"00"] 'MSByte of Remote Port (always 0)
    FOR Y = 0 to 3 'Remote IP address
    X = IP2[Y]
    Z = Z - X
    GOsub Bin2IHex
    HSEROUT [MSN,LSN]
    NEXT Y
    Pause 10
    If PROT = 0 THEN
    X = 192
    ELSE
    X = 204
    ENDIF 'Connect Configuration and
    Z = Z - X 'protocol - "0" for tcp, "1" for UDP
    GOSUB Bin2IHex
    HSEROUT [MSN,LSN,"010100"] 'Disconnect with 1 min of
    X =Z 'inactivity
    GOSUB Bin2IHex

    HSEROUT [MSN,LSN,13] 'WRITE CHECKSUM, ADD CR
    PAUSE 150
    HSEROUT [":200020100000230000000000000000000000000000000000 0000000000000000000000008D",13]
    Pause 150
    HSEROUT [":200040104C0200001227000000000000C000000000000000 00000000000000000000000049",13]
    Pause 150
    HSEROUT [":180060100000000000000000000000000000000000000000 0000000078",13]
    Pause 150
    HSEROUT [":00000001FF"]
    PAUSE 150
    RETURN
    Charles Linquist

  10. #10
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default Another Idea

    Don't think anyone has mentioned it yet, but if you've got a spare PC that can be dedicated to the pic, you can write a client/server type application in whatever pc language you use and have the pc connected to the pic retrieve commands over the network, spit them out the serial port to the pic, then have the pic send the serial commands to the device. Kind of cheap and dirty, but does the job. I've done this easily in VB.... and who doesn't have an extra old pc laying around collecting dust?
    Here is a link for another pc solution.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  11. #11
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    i've done a job with this ones, prefered the sbc68ec with bootloader :

    http://www.modtronix.com/index.php?cPath=1_36

    they work now in this release very fine. be sure that you have a switch right before which select only the traffic you really need. don't use a hub!
    i know it's only microcontrolling, but i like it!

Similar Threads

  1. 18F67J60 circuit for ethernet operation
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th August 2014, 18:12
  2. serial data over ethernet?
    By lester in forum Serial
    Replies: 3
    Last Post: - 22nd November 2007, 08:29
  3. Microchip Ethernet controllers
    By Philip in forum Documentation
    Replies: 23
    Last Post: - 2nd November 2007, 01:30
  4. U2 Programmer Interface for Ethernet MINI
    By edtp in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st July 2007, 22:29
  5. RS 485 wireless communication
    By Armadus in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 26th January 2006, 19:30

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts