Shop OBEX P1 Docs P2 Docs Learn Events
checking the serial data — Parallax Forums

checking the serial data

edited 2009-03-09 19:55 in BASIC Stamp
hello,

i am working on basic stamp2e for AROBOT. i would like to check the data(like 1010, 0001,... 4bit)·coming in to my board at pin number 2.
according to the data or command i have to movve my robot like if command is like 0010 then i hav to move my robot left like that.

i am getting the commands from a synapse board through a wire connected to the stamp board.

how to check the·data on pin 5?

Is i/opins of basic stamp are bit/nibble/word?????

thanq in advance for answering

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-18 05:15
    It's difficult to answer your question without adequate information. What format is the data coming in on pin 2? Presumably, the data is provided as asynchronous serial which consists of a start bit (0) followed by (usually) 8 bits of data, least significant bit first, followed by a stop bit (1). If that's the format, you need to specify the Baud (data rate). I assume that your 4 bit commands are right justified in an 8 bit value for transmission.

    The SERIN statement receives data in this format and the SEROUT statement transmits data. Read the chapters in the Parallax Stamp Basic Syntax and Reference Manual on these commands for details of how they are used and examples of their use.

    The Stamps have 16 I/O pins (except for the BS2p40) which each normally handle one bit of information. They can be grouped in 4-bit (nibble) groups where that's helpful and in 8-bit (byte) groups where that's helpful.

    There's a nice tutorial ("What's a Microcontroller?") that goes into basics like how the I/O pins are used and the various statements available. All of this documentation can be downloaded from Parallax's website. Go to the main webpage, click on the Resources tab, then choose Downloads, then Stamps in Class Downloads and you'll see a list of tutorials along with links for downloading.
  • KIRANKIRAN Posts: 5
    edited 2009-02-23 17:24
    but i am not receiving any serial data

    how to group those bits into nibble or byte ?
    can u provide me example
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-23 17:30
    There are examples in the Stamp Basic Manual starting on page 81 under Memory Allocation.
  • JDJD Posts: 570
    edited 2009-02-23 19:56
    Kiran,

    Just in case you do not have the BASIC Stamp Syntax & Reference Manual, or did not know it is available, here is a link to downloadable pdf. format for your convenience.

    BASIC Stamp Syntax & Refence Manual:
    http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf

    I hope this helps



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • KIRANKIRAN Posts: 5
    edited 2009-02-27 03:14
    how to check equality condition for an (binary)array with a binary constant?
  • JDJD Posts: 570
    edited 2009-02-27 20:22
    KIRAN,

    If I understand the question correctly, you could use an IF...THEN statement.

    For example, IF X = Y THEN (place some result here)

    Where X could be a constant; while Y is a variable or value you want to comparing it to. You can review the IF…THEN command in the book referenced above for more details on how to use the IF…THEN command.

    Feel free to ask more specifically if this is not what you meant.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • ForceFedForceFed Posts: 5
    edited 2009-03-04 20:37
    Why don't you store the incoming value from pin 5 somewhere and then use a debug command to print the value that you stored to the debug screen?
  • JDJD Posts: 570
    edited 2009-03-04 21:08
    That could be an option if a display or PC were available, however if there was no display or PC available, a simple IF...THEN could accomplish the task. There could be various ways to compelete the task, the IF...THEN is just one option.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • KIRANKIRAN Posts: 5
    edited 2009-03-09 14:16
    Thanq for that,


    but i already tried that like

    ' {$STAMP BS2e}
    ' {$PBASIC 2.5}
    t VAR Byte
    m VAR Bit
    i VAR Byte
    main:
    IF IN2=1 THEN
    m=1
    ELSE
    m=0
    ENDIF
    t(i)=m
    i=i+1
    GOTO main
    END

    IF t="0000" THEN
    HIGH 10
    ENDIF

    ·but its giving an error at t="0000"
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-09 14:32
    1) Nowhere in your program do you check the value of "i". You don't initialize it (although it will be zero after a reset) and you just increment it by 1.

    2) Your IF t = "0000" THEN doesn't make any sense. The quote is used to make a string in I/O statements and, for a single character, is used to specify a character constant. You probably want to use the "%" character which is used to start a binary constant or "$" which is used to start a hexadecimal constant. Read the section of the Basic manual on constants.

    3) Why do you have the bit about IF t = "0000" THEN at the end of the source code. It won't ever be executed.

    4) "t(i) = m" will not set individual bits of the variable "t". You probably want something like "t.BIT(i) = m". Please read the Basic manual as I've indicated.

    You seem to need to learn basic programming skills. Please start with "What's a Microcontroller?" and work through the exercises. It'll help a lot.
  • JDJD Posts: 570
    edited 2009-03-09 19:55
    KIRAN,

    As Mike suggested, completing What's A Microcontroller? and downloading the BASIC Stamp Syntax & Reference Manual will be a great help. Here is a link to What's A Microcontroller, and you can use the link above for the other manual.

    What's A Microcontroller?
    http://www.parallax.com/Portals/0/Downloads/docs/books/edu/Wamv2_2.pdf

    However, if you wanted to get·both·books with the·materials reviewed in them, I suggest the·BASIC Stamp Discovery Kit. Once you have completed this educational text, you will have a good foundation to build on; having a hard copy of the Syntax Manual is really handy as well.

    BASIC Stamp Discovery Kit [noparse][[/noparse] usb & serial ]:
    http://www.parallax.com/Store/Microcontrollers/BASICStampProgrammingKits/tabid/136/CategoryID/11/List/0/SortField/0/Level/a/ProductID/320/Default.aspx

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
Sign In or Register to comment.