View Full Version : ethernet to rs-232
maus
- 17th April 2006, 14:50
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 ?
Sphere
- 17th April 2006, 15:48
www.lantronix.com/device-networking/external-device-servers/uds-10.html
Not to shure if this is what you are looking for.
Sphere.
dhouston
- 17th April 2006, 16:31
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.
DynamoBen
- 17th April 2006, 16:53
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.
dhouston
- 17th April 2006, 17:46
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.
DynamoBen
- 17th April 2006, 17:54
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.
Charles Linquis
- 17th April 2006, 18:50
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
dhouston
- 17th April 2006, 19:40
I can give details if anyone needs them.
I'd like the details.
Charles Linquis
- 17th April 2006, 20:02
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 [":2000201000002300000000000000000000000000000000000 000000000000000000000008D",13]
Pause 150
HSEROUT [":200040104C0200001227000000000000C0000000000000000 0000000000000000000000049",13]
Pause 150
HSEROUT [":1800601000000000000000000000000000000000000000000 000000078",13]
Pause 150
HSEROUT [":00000001FF"]
PAUSE 150
RETURN
rhino
- 18th April 2006, 01:14
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 (http://home.comcast.net/~hardandsoftware/NETCommOCX.htm) is a link for another pc solution.
mischl
- 18th April 2006, 17:44
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!
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.