Pyserial non-standard baud rate

Discussion in 'Python' started by oyinbo55, Oct 1, 2009.

  1. oyinbo55

    oyinbo55 Guest

    Hello all: this is my first post. I hope I'm doing it right.
    I have a digital multimeter that sends data through an RS232 interface
    at 19230 baud. I would like to record and graph the output in Python.
    Pyserial does not want me to set the baudrate at a non-standard value:

    >>>ser=serial.Serial('/dev/ttyUSB0' ,baudrate = 19230, bytesize = 7, parity = 'N', stopbits = 1)

    ValueError : Invalid baud rate : 19230

    Using the standard 19200 baud results in gobbledegook from the
    multimeter.

    How can I connect to this device?

    I am using Python 2.5.1 running on Ubuntu 4.2.3 using IDLE 1.2.2

    Thanks
     
    oyinbo55, Oct 1, 2009
    #1
    1. Advertising

  2. "oyinbo55" <> wrote in message
    news:...

    > Using the standard 19200 baud results in gobbledegook from the
    > multimeter.


    You aren't going to notice a 0.1% clock skew within 1 byte.
    Forget about the difference between 19200 and 19230.

    If you have a scope handy, see what the output waveform
    looks like, and check the timings. If not play around with
    the rates, parity etc., until you find something that works.
     
    Richard Brodie, Oct 1, 2009
    #2
    1. Advertising

  3. oyinbo55

    oyinbo55 Guest

    On Oct 1, 11:36 am, "Richard Brodie" <> wrote:
    > "oyinbo55" <> wrote in message
    >
    > news:...
    >
    > > Using the standard 19200 baud results in gobbledegook from the
    > > multimeter.

    >
    > You aren't going to notice a 0.1% clock skew within 1 byte.
    > Forget about the difference between 19200 and 19230.
    >
    > If you have a scope handy, see what the output waveform
    > looks like, and check the timings. If not play around with
    > the rates, parity etc., until you find something that works.


    Thank you, Richard, you are absolutely right. Looking back at the
    documentation for the instrument, I found the following:

    "The data format complies with JIS 7Bits-transmission code with a baud
    rate of 19230. "

    I had overlooked the JIS transmission code because I didn't know what
    that meant. (It is the Japanese Industrial Standard). Changing my
    script to display the data one character at a time, I found it was
    sprinkled with escape characters that Japanese machines use to switch
    from ASCII to Kanji characters and back.

    Does Python have a module that will translate the data stream and
    display normal ASCII characters? The escape codes appear to alter the
    values of the characters in some systematic way.

    Thanks again for your help.
     
    oyinbo55, Oct 2, 2009
    #3
  4. oyinbo55

    John Nagle Guest

    oyinbo55 wrote:
    > On Oct 1, 11:36 am, "Richard Brodie" <> wrote:
    >> "oyinbo55" <> wrote in message
    >>
    >> news:...
    >>
    >>> Using the standard 19200 baud results in gobbledegook from the
    >>> multimeter.

    >> You aren't going to notice a 0.1% clock skew within 1 byte.
    >> Forget about the difference between 19200 and 19230.
    >>
    >> If you have a scope handy, see what the output waveform
    >> looks like, and check the timings. If not play around with
    >> the rates, parity etc., until you find something that works.

    >
    > Thank you, Richard, you are absolutely right. Looking back at the
    > documentation for the instrument, I found the following:
    >
    > "The data format complies with JIS 7Bits-transmission code with a baud
    > rate of 19230. "


    OK. First off, 19200 baud should work. 19230 is a number which
    comes from devices that use a 4MHz crystal for the clock and divide
    by 208. 4000000 / 208 = 19230.769, which is as close as you can get
    to 19200 baud given a 4MHz timing source. Serial ports
    can usually tolerate an error of about 1/4 a bit time, which is 2.5%.
    Since you're running a little fast, I'd suggest sending 2 stop bits,
    which guarantees the receiver can't gain on the transmitter during
    long blocks sent at full speed.

    >
    > I had overlooked the JIS transmission code because I didn't know what
    > that meant. (It is the Japanese Industrial Standard). Changing my
    > script to display the data one character at a time, I found it was
    > sprinkled with escape characters that Japanese machines use to switch
    > from ASCII to Kanji characters and back.
    >
    > Does Python have a module that will translate the data stream and
    > display normal ASCII characters? The escape codes appear to alter the
    > values of the characters in some systematic way.


    If you're really receiving content in Shift-JIS, you just need to
    translate it into Unicode. Python can do that. See

    http://www.velocityreviews.com/forums/t646242-251-shiftjis-to-unicode.html

    Now you'll have Unicode strings that contain kanjii, which Python can process
    just fine.

    Printing kanjii in a terminal window is troublesome on some operating systems.
    But it's possible to get everything working in Unicode, which will result in
    kanjii text appearing.

    Reading the Japanese may be a problem, although you can put the text through
    Google Translate.

    John Nagle
     
    John Nagle, Oct 2, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. debayan_p

    BAUD rate problem

    debayan_p, Jun 30, 2009, in forum: VHDL
    Replies:
    0
    Views:
    786
    debayan_p
    Jun 30, 2009
  2. rjmccorkle
    Replies:
    5
    Views:
    366
    rjmccorkle
    Apr 25, 2011
  3. Replies:
    2
    Views:
    1,073
  4. sagar0205

    1200 baud rate generator

    sagar0205, Aug 8, 2012, in forum: VHDL
    Replies:
    0
    Views:
    540
    sagar0205
    Aug 8, 2012
  5. Replies:
    6
    Views:
    996
    Dennis Lee Bieber
    Oct 27, 2012
Loading...

Share This Page