Shop OBEX P1 Docs P2 Docs Learn Events
help with SERIN — Parallax Forums

help with SERIN

maismais Posts: 5
edited 2007-06-11 10:16 in BASIC Stamp
I have a module (3axis electronic compass) which gives me data using UART interface in ASCII format.
The data coming out from the module are like:

174.9,0.1,18.6

174.8,-0.0,18.4

174.9,0.1,18.6

170,2,-0.0,8.4
...

I want to handle this data with a basic stamp module.
If i run the following code the debug window is like the attached file.

ser VAR Word

' {$PBASIC 2.5}
' {$STAMP BS2}

Main:
SERIN 8, 19200, [noparse][[/noparse]ser]
DEBUG ? ser
GOTO Main

Could you please help me? I want the data in the debug window to be like 174.9,0.2,19.6 and not like the screenshot
587 x 498 - 37K

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-06-09 21:37
    The data you are trying to receive is bigger than a word. The longest on of your examples is 15 BYTES long. You need to capture this to a variable. There are documents on sensors and industrial control on this site and the compass module or GPS should have examples of handling strings of data.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • maismais Posts: 5
    edited 2007-06-10 11:10
    The compass module doesn't have any example, could you please tell me how can I capture this data?
    The longest variable that i can use due to stamp editor help guide is WORD which means 2 Bytes, how can I handle 15 bytes data?
    Could you please send me an example? because the examples in help index of stamp editor didn't help me
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-06-10 14:28
    Mais -

    There are sample programs which can be downloaded from the link below, as well as all of the other HM-55B documentation that's available. Download the link which indicates "source code" for the programming examples.
    http://www.parallax.com/detail.asp?product_id=29123

    To answer your question more directly, you make multiple accesses of the compass module before a full set of data is obtained. The compass module documentation explains that aspect, and the source code shows how it is actually done.

    By the way, as I remember, you don't use SERIN to access the compass module data, SHIFTIN must be used since it is a synchronous serial device (it has it's own clock).

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • maismais Posts: 5
    edited 2007-06-11 09:44
    Dear Bruce,
    First of all I want to thank you for your reply.

    I 'm not using the HM55B compass·but the honeywell HMR3300(it's a 3axis compass module)
  • kristiankristian Posts: 6
    edited 2007-06-11 10:16
    It looks like you want to read in and buffer a string rather than a single word.
    pg. 405 in the Syntax and Ref Manual (rev2.2) has a quick and straight forward example
    that might work for your cause.
    regards,
    kristian
Sign In or Register to comment.