Shop OBEX P1 Docs P2 Docs Learn Events
Baud.... — Parallax Forums

Baud....

ArchiverArchiver Posts: 46,084
edited 2001-09-29 18:12 in General Discussion
OK, I know this is a simple question, but I'm a beginner so I feel
justified. Hz is one cycle per second, but what is baud? I want to
send and recieve serial data via the BS1, but none of the books I
have mention how fast baud is. Any help would be appreciated.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-09-28 05:19
    Baud is very close to bytes per second, but when transfering via a
    serial port the bits are clumped into bytes with pauses bewteen, so
    technically you can't say bits per second because it varies.

    Baud is essentially how fast the bits in the byte are transfered, so
    9600 baud is about 9600 bits per second for that chunk of data, then
    a pause, then another chunk. Also, a serial string is more than 8
    bits because there is a start, stop and possibly parity bit. but
    typically, there are 10 bits to one character sent.

    The simpliest way calculate what you need to use for the various baud
    settings it to look it up on the SERIN and SEROUT instructions in
    your stamp manual.

    Even when programming in Assembler, such as on the 8051, most
    controllers provide a table to refer to lookup the proper values for
    the common baud rates.

    -Martin Hebel
    SelmaWare Solutions
    Serial Data? Plot Data and create GUIs for your Stamp with StampPlot.
    http://www.selmaware.com/s-plot
    http://www.selmaware.com/tutorials


    --- In basicstamps@y..., "Astro Fizzix" <astro_fizzix@y...> wrote:
    > OK, I know this is a simple question, but I'm a beginner so I feel
    > justified. Hz is one cycle per second, but what is baud? I want to
    > send and recieve serial data via the BS1, but none of the books I
    > have mention how fast baud is. Any help would be appreciated.
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-28 13:34
    --- In basicstamps@y..., "Astro Fizzix" <astro_fizzix@y...> wrote:
    > OK, I know this is a simple question, but I'm a beginner so I feel
    > justified. Hz is one cycle per second, but what is baud? I want to
    > send and recieve serial data via the BS1, but none of the books I
    > have mention how fast baud is. Any help would be appreciated.

    The actual definition of baud is fairly complex, but in these
    discussions it is used interchangably with "bits per second" (bps).
    If you are sending data via a serial port at 9600 bps, the time to
    send each bit is 1/9600th of a second. Typical serial communications
    is in what is generally referred to as asynchronous mode, which means
    that a "start" bit and a "stop" bit are attached to each data
    character that is sent. If you are sending bytes (8 bit characters),
    which is most typical, the addition of a start and stop bit means you
    are actually sending 10 bits for each byte - at 9600 bps, you can
    theoretically send 960 bytes per second. This assumes that each byte
    is immediately followed by the next byte with no delay - real systems
    seldom achieve this actual speed. Just don't confuse bits per second
    with bytes per second, which is generally about 1/10th the speed.

    A guy who designs modems will tell you that baud rate and bit rate
    are not the same thing, but for our purposes we can assume they are
    identical.
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-28 14:44
    At 23:08 09/27/01, Astro Fizzix wrote:

    >OK, I know this is a simple question, but I'm a beginner so I feel
    >justified. Hz is one cycle per second, but what is baud? I want to
    >send and recieve serial data via the BS1, but none of the books I
    >have mention how fast baud is. Any help would be appreciated.

    Think of it as meaning "bits per second" and use the "baudmode" settings
    provided in your BS1 manual and you won't have any (programming) problems
    when it comes to Stamp communications. You can stop reading here and you
    won't miss a thing that really matters to Stamp communication.

    Technically baud is the reciprocal of the duration of the shortest signal
    element in your data encoding scheme. The difference between baud and bits
    per second really shows up when using higher speeds that typically have
    advanced modulation schemes that send more than one bit of data at a
    time. If a modem sends two bits at a time, the speed of the modem
    expressed in bits per second is twice the speed expressed in baud. BUT....
    these are characteristics of the communication channel, NOT characteristics
    of the Stamp-to-modem digital serial interface. You only need to be
    concerned with, for example, how fast you must send digital data bits
    serially to a modem, not what sort of analog modulation scheme the modem
    uses over it's communication channel to another modem.

    It's complicated, but it doesn't matter with a Stamp, so if I've explained
    it incompletely or confusingly, just ignore it, use the parameters defined
    in the BS1 manual under SERIN and SEROUT, and you'll be fine.


    Jim H
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-29 04:22
    Wow, that is a lot of information. I suppose I should have included
    my application. It's kinda long, but what the hey:

    I have the need to detect sunlight in two places at the same time.
    One reading in town and one at my home. I figure that I'll take a
    reading myself in town, while the BS1 takes data from a photocell and
    saves it on it's hard drive (then powers down COMPLETELY, retaining
    the data ONLY on the hard drive), then when I get home, I power it up
    and read the data. I thought it would be simple, but it's transfering
    the data from the BS1 to a serial to parallel shift register that I
    can't do. I have other apps that will also be taking up pins on the
    BS1, so I MUST do serial data.

    So my problem is this: what speed to set the clock to retrieve the
    data from the BS1? That is where baud comes in. I've searched all
    through that book and I can't find a blame thing. That is my trouble.
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-29 05:22
    Well, I just checked my stamp manual too, but can't see the baud
    listed for the BS1, I'm going to assume it's 9600 for DEBUG.

    Typically, data can be sent back to the PC by using the DEBUG
    instruction. Just as you can debug to your screen, you are sending
    back serial dta. This data may be captured by another program,
    instead of the debug window, and stored.

    You can also use the SEROUT instruction where you define the baud and
    pins.

    Our StampPlot programs can accept serial data from the Stamp and plot
    them, or log them. An option is to to store the data in the EEPROM
    of the stamp, and then dump it at your leisure, depending on how much
    data you need to store and how much EERROM memory you have
    remaining. StampPlot Pro can easily accept the data and log it,
    either as it is measured, or as it comes in. If you would like to go
    this route, let me know and I can assist in helping you get setup for
    this.

    Or, you could most any terminal program to accept then save your data
    as a file.

    I personally have never programmed much on the BS1, but I think I
    have one around here somewhere.....

    Martin Hebel
    SelmaWare Solutions
    http://www.selmaware.com/s-plot

    --- In basicstamps@y..., "Astro Fizzix" <astro_fizzix@y...> wrote:
    > Wow, that is a lot of information. I suppose I should have included
    > my application. It's kinda long, but what the hey:
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-29 12:22
    That sounds good, I guess I haven't thought about sending the data to
    my cp, but I would appreciate it if you'd show me how cause I'm still
    new to all of this...

    I'm using the POT function to retrieve the resistance of a photocell.
    I want to use the BS1 to convert that data to light levels (10 or so
    levels). That's about it.
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-29 15:01
    The BS1 has a Write command, where you define the memory location to
    store data, and the value:
    Write location, data

    With each read, incrememnt the location and store into the next
    memory location starting at 0. I'm not very good with BS1 syntax so
    take it with a grain of salt.... just trying to demonstrate some
    structure here.

    light var byte
    loc var byte
    x var byte

    Loop:
    pause 1000 '1 second pause
    Pot 5,10,light 'read value
    Write loc,light 'store in memory
    If in0=0 then dump 'if button on p0 is pressed, dump data
    loc = loc + 1 'incrememt memory location
    Goto Loop 'repeat

    Dump:
    for x = 0 to loc 'loop to read back values
    read x,light 'get value from memory
    debug #b2,CR 'display value
    next 'next value
    goto Loop

    One caution, storing can start at location 0, but if you write too
    much data you can overrun your program space. Please see you manual
    on the Write instruction for more detail.

    -Martin Hebel
    http://www.selmaware.com/s-plot
    and
    http://www.siu.edu/~imasas/est


    --- In basicstamps@y..., "Astro Fizzix" <astro_fizzix@y...> wrote:
    > That sounds good, I guess I haven't thought about sending the data
    to
    > my cp, but I would appreciate it if you'd show me how cause I'm
    still
    > new to all of this...
    >
    > I'm using the POT function to retrieve the resistance of a
    photocell.
    > I want to use the BS1 to convert that data to light levels (10 or
    so
    > levels). That's about it.
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-29 18:12
    >So my problem is this: what speed to set the clock to retrieve the
    >data from the BS1? That is where baud comes in. I've searched all
    >through that book and I can't find a blame thing. That is my trouble.

    Your original question asked for a general definition of "baud" and
    maybe you got more than you bargained for.

    The BS1 is capable of just 4 baud rates, 300, 600, 1200 and 2400.
    This is well explained in the Stamp manual under the SEROUT and SERIN
    commands. It is on pages 59 to 65 in th v1.9 manual. Here is a demo
    of how to do it at 2400 baud, to transfer 50 bytes from the eeprom of
    the BS1 to the eeprom of the BS2:

    On the BS1, assuming 50 bytes stored in eeprom:

    symbol i=bo
    symbol x=w1
    for i=0 to 49
    read i,x
    SEROUT 0,N2400,(x) ' on p0, 2400 baud, resting low
    pause 12 ' give the BS2 time
    next
    end

    On the BS2

    i var byte
    x var word
    for i=0 to 49
    SERIN 0,396+$4000,1000,error,[noparse][[/noparse]x] ' on p0, 2400, resting low
    write i,x
    next
    end


    error:
    debug "didn't get 50 bytes, try again",cr
    end

    If you are transferring from the BS1 directly to a PC, the same BS1
    program should work, except use
    SEROUT 0,N2400,(#x,32) ' on p0, 2400 baud, resting low
    The # makes it send the data as a numerical string instead of a
    single byte, and the 32 separates the data fields with spaces.


    -- regards,
    Tracy Allen
    electronically monitored ecosystems
    mailto:tracy@e...
    http://www.emesystems.com
Sign In or Register to comment.