Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Kludging the serial port

by Dr. Mu (Hermit)
on Oct 09, 2001 at 04:40 UTC ( #117596=note: print w/ replies, xml ) Need Help??


in reply to Kludging the serial port

I looked at their docs. The "send" and "data" lines are separate here, and of a polarity that should render them useful with a normal RS232 converter. By "normal", I mean one that converts outgoing CMOS 0V to (+3 to +12V) and CMOS +5V to (-3 to -12V), and vice-versa for incoming RS232 lines. This is to say, it inverts in both directions. This needs to be done for all the signals you use. If it doesn't do this, you're not getting your money's worth, and I'd get a different converter or build one using a Maxim MAX232 or somesuch IC.

Once you have a proper converter, the rest is easy. Pin 2 on your PC's DB9 should map from the note scanner's "data" line. It's easiest if the "send" line maps to one of the handshake lines the PC can control directly, but if it maps to the PC's TX line (pin 3) that's okay too. You just need to send the changer a pulsed BREAK for a period long enough to meet their timing requirements. This is done with: $PortObj->pulse_break_on($milliseconds);
What this does is raise the RS232 TX line (pin 3) from -10V, say, to +10V for a period you specify. The converter, by inverting this, will create a 0V pulse on a normally 5V signal line -- just what the scanner wants. Then all you have to do is check your input buffer for the incoming data byte.

With all the means available for doing this right, there just isn't any excuse for kludging the hardware in the manner you describe.


Comment on Re: Kludging the serial port
Download Code
No, not quite...
by Aighearach on Oct 09, 2001 at 07:16 UTC

    Yes and no. Yes, in the docs they are listed as seperate lines. No, that is not the way it is actually working.

    Yes, that appears to be the action of the converter.

    Yes, that would be the logical way for it to be wired, and is quite what I was expecting. But there is not a single unused line that you can cycle to get the desired behavior. Using an RS-232 breakout box, I tried all the lines... only by turning off and restoring RD would the hardware respond in the way that is described for when the SEND line is toggled.

    $PortObj->pulse_break_on() doesn't do anything for me. First of all, as the docs specify, you can't get exact timing out of it. Second, that plays with TD (pin 2) not RD (pin 3), and the hardware doesn't blink. Actually, I wrote a strober to try all the pulse methods before I tried manually playing with the voltages via breakout box. Closest I can get that way is to throw ACCEPT_ENABLE(DTR) around, which makes it burp but not finish processing any events or state changes.

    With all the means available for doing this right, there just isn't any excuse for kludging the hardware in the manner you describe.
    Yes, and considering your sollution contains errors, and also doesn't work at all, there is even less excuse for your attitude than for my kludge. If I thought I had the ideal sollution, I would have posted in CUFP instead of Seekers. On the bright side, since it's for my own company I only need it to accept the customers money and credit them; nobody is going to ask what it's "excuse" for working is.
    --
    Snazzy tagline here
      Sorry if my tone offended. It's just that I've been burned enough times by hardware kludges, I tend to mount the soapbox when I see others toying with the same fate. Especially since you indicate it's not a one-off project, I still maintain it's worth the time to figure out what's going on and get it right.

      I confess confusion now regarding the separation/non-separation of the RD and SEND lines. I'd be happy to provide more assistance if I knew more about the circuitry of your RS232 converter. Unfortunately, this goes outside the realm of Perl, so this probably isn't the best forum to continue the discussion. Perhaps you could message me on the Chatterbox with your email address, and we could continue there.

Re: Re: Kludging the serial port
by Anonymous Monk on Jan 03, 2002 at 06:49 UTC
    As I found out, if you are interfacing to a PC, you do not need to use anything as fancy as a MAX232. In fact, a plain old 74HCT00 (quad nand gate) will suffice. Simply take PC output connect it to a 22k resistor and tie it to the inputs of one of those gates. The output of that gate will be the RS232 input into your device. Similarly, take the output of your device, tie it to the inputs of another gate and that output will be the input into the PC. This is not fully RS232 compliant but it's awfully cheap and works wonders with PCs.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://117596]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-11-01 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (227 votes), past polls