Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

(OT) How to read a 2-Wire RS-232-C line?

by aplonis (Pilgrim)
on Oct 09, 2006 at 18:28 UTC ( [id://577247]=perlquestion: print w/replies, xml ) Need Help??

aplonis has asked for the wisdom of the Perl Monks concerning the following question:

I have an instrument, an Heise Model 170A pressure transducer with output described on page 6 of the manual as follows:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

4.1 SERIAL OUTPUT

ASCII encoded 8-bit data pluse one start and one stop bit.
Data rate: 1200 baud
Interface: Two wire hookup, EIA RS-232-C Standard.
See page 8 for barrier strip identifications.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

And sure enough page 8 shows a pair of screw terminals beneath a "Serial Out" lable, marked as "Common" and "Signal".

I have only gotten as far as installing on my WinXP box the modules, Win32::API, Win32::SerialPort, Win32API::SerialComm, but not any further.

I had thought RS-232C took more than two wires...that two wires was RS-422. And I can't find any more info on either the device or on two-wire RS-232.

Any and all clues will be welcome.

2006-10-09 Retitled by g0n, as per Monastery guidelines
Original title: 'How to read a 2-Wire RS-232-C line?'

Replies are listed 'Best First'.
Re: (OT) How to read a 2-Wire RS-232-C line?
by g0n (Priest) on Oct 09, 2006 at 20:21 UTC
    Assuming a 9 way plug, wire signal to pin 2 (rx), common to pin 5 (sig ground), set up your serial port correctly and hope for the best.

    Oh, and if you must post hardware questions, mark them OT or ask them in the CB (this is waaay off topic - hopefully you will soon be using perl to talk to your device, but at the moment it looks very much like a hardware question) ;-)

    Update:this might come in handy

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

    "If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
    John Brunner, "The Shockwave Rider".

Re: (OT) How to read a 2-Wire RS-232-C line?
by samtregar (Abbot) on Oct 09, 2006 at 20:19 UTC
    I don't think you're going to get a good answer for this question without more details about how your hardware works. Try to find other users of this hardware, or similar hardware. You should be able to find some sample code - don't worry if it's not Perl. If you can, post it here and we'll help you figure out how to do it in Perl.

    -sam

Re: (OT) How to read a 2-Wire RS-232-C line?
by monarch (Priest) on Oct 10, 2006 at 07:09 UTC
    If you have the correct voltage/impedance converters between your RS232 pins and the device you're driving it may be possible to write your own communications protocol using a control pin on the serial port.

    Windows will let you switch DTR and RTS if I remember correctly using an API call, it is up to you to time this properly. Messy, but possible.

    Actually, looking at the documentation for Win32API:CommPort there's an example of this very concept.

    update: apologies I missed the fact that the device is standard serial 1200 baud. Thus you only need the RD pin wired up.. but follow the link g0n provided in Re: (OT) How to read a 2-Wire RS-232-C line? to ensure that the PC end has DTR/DSR/CD pins wired together and the RTS/CTS pins wired together (so the PC thinks something is connected to the port). Also ensure your device handles RS232 voltages (+/-25V). If it doesn't you'll need to add some hardware to convert those to CMOS voltages (if your device is CMOS) otherwise you might fry your component.

      RS-232 was never +/-25 V. IIRC the standard specifies +/-3V to +/-15V with +/-12V being typical.

      Many systems generate a quasi RS-232 output (OP's device is likely to be of that sort) using 0V and 5V for their signaling levels. Most RS-232 receivers will work fine with those levels.


      DWIM is Perl's answer to Gödel
Re: (OT) How to read a 2-Wire RS-232-C line?
by GrandFather (Saint) on Oct 10, 2006 at 09:24 UTC

    The "serial" bit of RS-232 serial only requires two wires as described. The RS-232 bit is a standard that describes a wiring interface that was used between computers and modems and has been hijacked for virtually anything you can think of since.

    The standard specifies wiring and connectors that provide various handshake and status signalling to allow communication management in the original context for which it was designed. For the vast majority of applications derivitaves of RS-232 are used for now the handshaking ans status are almost completely irrelevant. For your application it has degenerated to a single direction signal that only requires two wires.

    The reason you can find nothing on two wire RS-232 is because there is no such animal. However, to use your transducer you can find a wiring diagram for the 9 pin connector often used for serial ports these days and connect signal to the serial in line on the connector. Common of course goes to common. Once you have done that you can use your serial modules to configure the port according to the specification you already have (8 bits,one stop, one start, 1200 baud), make sure you turn off handshake, and away you go.


    DWIM is Perl's answer to Gödel
Re: (OT) How to read a 2-Wire RS-232-C line?
by aplonis (Pilgrim) on Oct 11, 2006 at 13:17 UTC

    The above replies were very helpful.

    I have tried the following code with the wires hooked up as instructed.

    But it aways warns "Port is blocked".

    I checked BIOS and serial is indeed COM1. It writes the config file.

    use Win32::SerialPort; $PortName = "COM1"; $quiet = 0; $Configuration_File_Name = "c:/com1_config.txt"; $PortObj = new Win32::SerialPort ($PortName, $quiet) || die "Can't open $PortName: $^E\n"; # $quiet is optional $PortObj->user_msg(ON); $PortObj->databits(8); $PortObj->baudrate(1200); $PortObj->parity("none"); $PortObj->stopbits(1); $PortObj->handshake("none"); $PortObj->buffers(4096, 4096); $PortObj->write_settings || undef $PortObj; $PortObj->save($Configuration_File_Name); $PortObj->baudrate(300); $PortObj->restart($Configuration_File_Name); # back to 1200 baud ($BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags) = $PortObj->status || warn "could not get port status\n"; if ($BlockingFlags) { warn "Port is blocked"; } if ($BlockingFlags & BM_fCtsHold) { warn "Waiting for CTS"; } if ($LatchErrorFlags & CE_FRAME) { warn "Framing Error"; } ($count_in, $string_in) = $PortObj->read($InBytes); print "Count: $count_in \n"; print "String: $string_in \n"; $PortObj->close || die "failed to close"; undef $PortObj;

    The written config file looks like this...

    Win32::SerialPort_Configuration_File -- DO NOT EDIT -- COM1 CFG_1,none eol,10 clear,-@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@@@@@@@@@@@@@- RCONST,0 istrip,0 CFG_2,none XOFFCHAR,19 PARITY_EN,0 WCONST,200 intr,3 U_MSG,1 STOP,1 XONLIM,2048 erase,8 XONCHAR,17 BINARY,1 RTOT,0 echonl,0 XOFFLIM,512 icrnl,0 inlcr,0 READBUF,4096 igncr,0 EOFCHAR,0 WRITEBUF,4096 RINT,4294967295 ocrnl,0 bsdel,  opost,0 echoke,1 PARITY,none HNAME,localhost echoctl,0 CFG_3,none EVTCHAR,0 icanon,0 isig,0 HADDR,0 E_MSG,0 DATA,8 DVTYPE,none echo,0 quit,4 s_eof,26 s_kill,21 ERRCHAR,0 onlcr,1 ALIAS,COM1 HSHAKE,none DATYPE,raw echok,1 echoe,1 BAUD,1200 WTOT,10

    Once I get this working I'll write a howto and maintain it online with my several others, and link to it with a final comment here. Thanks again.

      wtf

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://577247]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found