Connect with us

RS232 Level Correction

Discussion in 'Electronic Basics' started by nobody, Jan 23, 2006.

Scroll to continue with content
  1. nobody

    nobody Guest

    What's the best way to compensate for RS232 levels that are out of spec?
    The absolute levels I'm getting are around 9.1V, and I'd like to
    raise them to the 12-13V level.

    I've deduced (from my very limited electronics - learning all the time!)
    that I could either build a transistor amplifier (given that I have
    access to a 12V power source), or feed the signal through a MAX232/233 -
    what would be simplest?

    If it matters - the problem is that my serial-port PIC ICSP cannot read
    back (or verify) what's been programmed, although the programming is
    definitely working correctly. Doing a Read-All (using IC-Prog software)
    it gets the first word back correctly, the second wrong, and the rest
    are 0x3FFF. I'm hoping it's not the timings - I don't have a clue how
    to fix them (and have no Oscilloscope anyway...)

    Thanks,
    Andrew Merton
     
  2. The RS-232 specification allows for 9V signaling, I believe. Just a
    moment..., looking in both 2nd and 3rd ed McNamara..., yes, the
    requirement is that the loaded voltage should be between +5 to +15 or
    else -5 to -15. The receiver is supposed to consider anything over +3
    or below -3 as valid. And the open circuit driver voltage should not
    exceed 25V.

    So this is probably not your problem. The 9.1V (assuming we are
    talking about +9V for a SPACE and -9V for a MARK) you mentioned is
    within the specification and should work just fine.

    It very well may be your timing that is causing later words to be read
    incorrectly.

    Jon
     
  3. nobody

    nobody Guest

    Thanks Jon - unfortunately I seem to have misled you somewhat - the
    problem is that the PIC (16F876A) that I am dealing with expects
    13+/-0.5V on its Vpp - the 9.1V it's getting is obviously way off that.
    The programmer is a version of the Ludipipo programmer (also
    equivalent to JDM) and uses direct manipulation of the serial port
    signals to control the programming of the chip. It's not actually doing
    RS232 comms - just using the wires...

    To be honest, I do actually think it's more likely to be timing. I just
    can't confirm it, though, so I want to fix the levels before I go and
    try to find a cheap oscilloscope...
     
  4. Rich Grise

    Rich Grise Guest

    Sorry, it's the timings. If you look up the RS-232 spec, it calls out
    something like +3~12V for a "space", and -3~-12V for "mark", so your
    9.1 is well within spec.

    The simplest, not to mention cheapest, way to go about this is to study
    the data sheets until you can do the whole communication stream in
    your head, bit rate clock and all.

    From your symptoms, it sounds almost like your two UARTs are configured
    for different numbers of stop bits, or one is looking for parity.

    But, like I said, sorry, but the problem isn't the voltage level. )-;

    Good Luck!
    Rich
     
  5. Rich Grise

    Rich Grise Guest

    You didn't say that. Yes, you've misled us.

    What you need to do is either invest in a proper programmer or find
    a proper programmer design and quit trying to fudge something like Vpp
    with a lash-up like that.

    Good Luck!
    Rich
     
  6. I hear that. OTOH, a bunch of these cheesy type programmers use one of
    the control pins that stays at a negative voltage and then reference the
    programmer's ground to that. Then the programmer has a much larger
    voltage to use for programming since it "sees" the -9V to +9V span as an
    18V supply. Zeners take care of the +5V Vcc and +13V Vpp
    regulation/protection. Of course the programmer can't touch the PC
    casing (nor can you connect an oscilloscope ground) or the whole thing
    goes to hell. ;-) But as long as the PC is making +6.5V and -6.5V
    (plus some allowance for headroom) then it should work, even though it's
    a "sucky" way to do things IMHO. But if someone doesn't have enough
    troubles getting their PIC projects to work as is, then I highly
    recommend using one of these flaky "no parts" programmer designs. :-/

    To make a long story short, I doubt the OP is having trouble with
    voltages or the programming wouldn't work at all. He's only having
    trouble reading/verifying the chip, I'd look towards a software error on
    that issue. At any rate, using a MAX232 will cause a signal inversion
    and it will still probably only generate about -10V and +10V signals.
    Not to mention that the inputs only want to see 0V and +5V signals.
     
  7. Ah!! I see much more clearly, now. The RS-232 levels are important
    because of the PIC programming voltages required on the Vpp pin and
    the positive-going RS-232 signaling is depended on in order to gain
    the right voltage. That is one of the reasons, I suppose, that such a
    programmer board isn't a robust design.
    Well, let's start with the voltage. May we fairly assume that the
    Ludipipo programmer board gets _all_ voltage and current from the
    RS-232? That there is no external supply present that you can depend
    on? (Probably so.) If so, then exactly how do you expect to provide
    the required voltage? Will you be willing to modify the existing
    programmer? Or are you looking for a powered circuit that sits in
    between the RS-232 port of your PC and the programmer that will "fix
    up" the signaling? Or are you looking for a sophisticated unpowered
    circuit that can do the same?

    Jon
     
  8. Well, you make a good point. Andrew clearly says that the programming
    is working, but the read-back isn't. However, in a later note, he
    mentioned that the measured voltage is about 9.1V, loaded. I already
    know from reading the PIC programming specifications on a variety of
    such chips (of the OTP variety) that they do, in fact, require a
    narrow range of voltages on Vpp, around the 13V location. I thought
    it was +/- 0.25V on the parts I've looked at, but Andrew says this is
    +/-0.5V. Okay, close enough for now. The main point here is that it
    simply is NOT easily possible for the programmer to develop the
    required Vpp from the RS-232 without going to heroic efforts (and I'm
    pretty sure it doesn't even begin to try to do that.) It's instead
    probably a dead-simple schematic and depends heavily upon the RS-232
    delivering the required Vpp entirely by coincidence. I've seen such
    designs before, so I'm not surprised if this were the case here.

    So all this leaves us with a quandary. The read-back is supposed to
    be performed at multiple voltages, stepped by 0.25V or 0.5V increments
    to verify programming. In no case that I recall, though, does the
    read-back require anything higher than 7V. The Vpp for writing to the
    OTP chips is indeed 13V or so and I'm pretty certain that this
    programmer board isn't developing that, if Andrew is correct about the
    9.1V, measured. We don't know if Andrew is using flash or OTP and I
    haven't gone looking over the serial programming chips to see what
    they require, Vpp-wise, so they may have an internal charge pump and
    don't need the Vpp for sourcing current, though they may still use the
    voltage requirement for enabling the charge pump just for safety. I
    honestly am not sure about this aspect.

    So it may be timing. Or voltage. Or both. Or?

    Andrew, what exact PIC chip are we talking about here?

    Jon
     
  9. Or as I said before..... "a bunch of these cheesy type programmers use
    one of the control pins that stays at a negative voltage and then
    reference the programmer's ground to that. Then the programmer has a
    much larger
    voltage to use for programming since it "sees" the -9V to +9V span as an
    18V supply. Zeners take care of the +5V Vcc and +13V Vpp
    regulation/protection"

    So it is possible to develop the 13V needed for Vpp from a serial port
    that only supplies + and - 9V since that is really an 18.2V supply if
    you look at it the right way. ;-) It's the only way that any serial
    port can supply enough voltage since + and - 12V is the limit of what
    you are likely to see anywhere coming out of a PC. It's the only way
    that I know that it can be done without an onboard boost switching
    supply or charge pump widget.

    Assuming that Andrew meant that he is getting + AND - 9.1V, he should
    have plenty of voltage. Of course my warnings still stand about
    grounding the programmer since its ground is really at -9.1V relative to
    the PCs frame ground.
     
  10. After rereading this, it comes off kinda "smart assish" for lack of a
    better term. That was not my intention at all, my apologies. :)
     
  11. I had considered what you said. Mostly, because that is how I once
    thought they might get these programmers to work with less. But after
    looking at a few of the schematics for cheap programmer systems and
    seeing how unimaginative they are, I don't consider this approach very
    likely. By this, I mean that of relying upon the occasional -9V
    appearance as a possible ground return. I haven't seen a single one
    of them do that, yet. And I've seen plenty of them rely only upon the
    common provided by the RS-232 interface and either one side or the
    other (some prefer the - side, since that is the MARK condition and
    where things are held when communication is not ongoing.)

    You may be right that the +9 and -9 provides enough headroom. But I
    don't think you are permitted within the specification to return the
    +9 to the -9, as if it were a ground and ignoring the actual ground.
    And it's also true that the RS-232 specification allows for as little
    as +5V, when loaded. Which would _not_ be sufficient. So the design
    is poor, I suspect, if it depends on more.

    But... who knows? We will have to wait for more information on the
    chip Andrew is using. And perhaps I'll have to break down and go look
    up the programmer if I'm to get out of this guessing loop I'm in.

    Jon
     
  12. He said that he's using IC-Prog, and it's a serial port interfaced
    programmer, so I bet it's allot like this one:
    http://www.jdm.homepage.dk/newpics.htm

    I use a tait style programmer (PICALL). It's a relative cheapie, but it
    works pretty well. It needs an external power supply since it uses a
    parallel port interface.
     
  13. nobody

    nobody Guest

    OK. To try to answer all the questions I found in the thread at once,
    in no particular order:

    1) It's a 16F876A (see my second post...)

    2) The programmer is wired from RS232 to PIC as follows:

    RS232 (9-pin) PIC16F876A (board)
    [3]TXD-------------4.7Kohm--------------_MCLR/Vpp [1]

    NC-------Vdd [20 (+5V)]

    [5]GND----------------------------------Vss [19 (GND)]

    [4]DTS-------------4.7Kohm------+-------DATA [28]
    |
    [8]CTS--------------------------+

    [7]RTS-------------4.7Kohm--------------CLK [27]

    Note that it requires the power supply for the chip to remain connected,
    otherwise it does nothing (this will of course be obvious to everybody
    except me - I had to learn by (not) doing B-) )

    (I don't think that this has a GND to -12V connection problem, does it?)

    3) Regarding levels required: this is from the Microchip datasheet
    (39589b - PIC16F87XA Flash Memory Programming specification):

    "...follows the normal Microchip Programming mode entry of holding
    pins RB6 and RB7 low, while raising MCLR pin from VIL to VIHH (13V ± 0.5V)."

    4) The readback at different voltages I believe is only required for a
    so-called "production" programmer - development programmers aren't
    required to do this (this is my understanding from comments on various
    websites). The one I'm using is not meant to be a production programmer!

    And thanks for all the help, guys - I feel like I'm learning, just
    reading the discussion!
     
  14. Byron A Jeff

    Byron A Jeff Guest

    -Jonathan Kirwan wrote:
    ->
    ->
    ->>What's the best way to compensate for RS232 levels that are out of spec?
    ->> The absolute levels I'm getting are around 9.1V, and I'd like to
    ->>raise them to the 12-13V level.

    As pointed out these voltages are not in fact out of spec.

    ->>I've deduced (from my very limited electronics - learning all the time!)
    ->>that I could either build a transistor amplifier (given that I have
    ->>access to a 12V power source), or feed the signal through a MAX232/233 -
    ->> what would be simplest?

    The simplest would be a transistor switch (not an amplifier per se) that
    switches 13V.

    ->>If it matters - the problem is that my serial-port PIC ICSP cannot read
    ->>back (or verify) what's been programmed, although the programming is
    ->>definitely working correctly. Doing a Read-All (using IC-Prog software)
    ->>it gets the first word back correctly, the second wrong, and the rest
    ->>are 0x3FFF. I'm hoping it's not the timings - I don't have a clue how
    ->>to fix them (and have no Oscilloscope anyway...)

    What PIC chip are you testing with?

    -> The RS-232 specification allows for 9V signaling, I believe. Just a
    -> moment..., looking in both 2nd and 3rd ed McNamara..., yes, the
    -> requirement is that the loaded voltage should be between +5 to +15 or
    -> else -5 to -15. The receiver is supposed to consider anything over +3
    -> or below -3 as valid. And the open circuit driver voltage should not
    -> exceed 25V.

    Bingo. So many RS-232 ports that are PC based fall out of spec that one
    should not even bother to try to extract a paricular voltage level from it.
    I always treat RS-232 as if it were going to be a 0-3.3V out of spec signal.
    Many serial ports for laptops will produce exactly that.

    -> So this is probably not your problem. The 9.1V (assuming we are
    -> talking about +9V for a SPACE and -9V for a MARK) you mentioned is
    -> within the specification and should work just fine.

    But the PIC programmer presumes that +-12V are going to be available. A
    mistake BTW.

    -> It very well may be your timing that is causing later words to be read
    -> incorrectly.

    Depending on the chip, it may be the voltage.

    THe OP's best bet is to use an external power supply to generate the Vpp
    voltage and then use the RS-232 modem line to switch it.

    -Thanks Jon - unfortunately I seem to have misled you somewhat - the
    -problem is that the PIC (16F876A) that I am dealing with expects
    -13+/-0.5V on its Vpp - the 9.1V it's getting is obviously way off that.

    However the 16F876A in particular will accept a Vpp that is only 3.5V above
    Vdd. So in fact it should work with a 9.1V Vpp.

    So it's possible that some other issue is causing the problem.

    - The programmer is a version of the Ludipipo programmer (also
    -equivalent to JDM) and uses direct manipulation of the serial port
    -signals to control the programming of the chip. It's not actually doing
    -RS232 comms - just using the wires...

    I know it well. This is one reason that I prefer, design, and maintain
    parallel port programmers as parallel ports are always within TTL spec.

    Let me suggest that if you have a parallel port that you may wish to
    consider throwing together one of my Trivial Programmers. You can find
    them here:

    http://www.finitesite.com/d3jsys

    They are quite reliable when attached to short cables. Also one of my
    users has experimented with grounding the cable shield via a small valued
    cap (0.1 uF IIRC) and has had success with even 10ft cables.

    One of my students recently threw a low voltage one together. Once the
    cable was debugged it worked like a champ.


    Just some ideas.

    BAJ
     
  15. Rich Grise

    Rich Grise Guest

    Well, I wouldn't do it that way, and I'd almost bet money that neither
    would John or Win or Spehro or John or John or John. Or even Jim. ;-)

    Cheers!
    Rich
     
  16. Rich Grise

    Rich Grise Guest

    Well, from my POV, the level of "smart-assish"-ness is exactly apropos,
    given the character of the thread. ;-)

    IOW, no worries, mate. ;-)

    Cheers!
    Rich
     
  17. Rich Grise

    Rich Grise Guest

    .
    Well, that's pretty much what we're here for.

    Welcome to the zoo! ;-P

    Cheers!
    Rich
     
  18. Rich Grise

    Rich Grise Guest

    I'm gonna revise this since I got caught up on the thread - if you're
    trying to use a serial port to provide Vpp, then you're doomed.

    Thanks,
    Rich
     
  19. Nor would I but, like I said, that's how it's done by more than one
    design out there. I like having a real power supply myself.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-