Shop OBEX P1 Docs P2 Docs Learn Events
bs2p24 with accelerometer mx2125 — Parallax Forums

bs2p24 with accelerometer mx2125

panosathenspanosathens Posts: 5
edited 2014-07-14 15:14 in BASIC Stamp
when i am using pulsin in my program with no delay i get maximum 8 samples per second but i need at least 20 for my expirement..What can i do to solve this problem?


'{$STAMP BS2p}
'{$PBASIC 2.5}
' {$PORT COM2}
x VAR Word
y VAR Word
DEBUG CLS
DO
PULSIN 6, 1, x 'Read X axis
PULSIN 7, 1, y
'Read Y axis
DEBUG CR, DEC4 ? X, DEC4 ? Y 'Display values
DEBUG "DATA,", DEC X, ",", DEC Y, CR
DEBUG "DATA, TIME, TIMER,", DEC X,",",DEC Y,CR


LOOP

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-07-13 10:01
    Welcome to the forum, panosathens!

    BTW, cross-posting is against forum rules, so I've removed your duplicate post for you.

    Also,

    attachment.php?attachmentid=78421&d=1297987572

    -Phil
  • panosathenspanosathens Posts: 5
    edited 2014-07-13 10:28
              '{$STAMP BS2p}
    '{$PBASIC 2.5}
    ' {$PORT COM2}
    x   VAR   Word
    y   VAR   Word
    DEBUG  CLS
    DO
      pulsin 6, 0, x                        'Read X axis
      PULSIN 7, 1, y                         'Read Y axis
    
    
      DEBUG  CR,   DEC4 ? X, DEC4 ? Y        'Display values
          DEBUG "DATA,", DEC X, ",", DEC Y, CR
            DEBUG "DATA, TIME, TIMER,", DEC X,",",DEC Y,CR
    
    
    
    
    LOOP
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-07-13 10:51
    when i am using pulsin in my program with no delay i get maximum 8 samples per second but i need at least 20 for my expirement..What can i do to solve this problem?

    You can start by outputting less verbiage with each pass through the loop. Even without the PULSINs, you will get a maximum of 17 loops/sec at 9600 baud (the default for DEBUG). Also, you can switch from DEBUG to SEROUT on "pin" 16 at a higher baudrate.

    -Phil
  • panosathenspanosathens Posts: 5
    edited 2014-07-13 10:58
    You can start by outputting less verbiage with each pass through the loop. Even without the PULSINs, you will get a maximum of 17 loops/sec at 9600 baud (the default for DEBUG). Also, you can switch from DEBUG to SEROUT on "pin" 16 at a higher baudrate.

    -Phil

    if you are able please make your self more clear because my knowledge in this section are very limited.
  • 72sonett72sonett Posts: 82
    edited 2014-07-13 11:04
    Why do you need the $PORT COM2 directive?

    DEBUG is relatively slow to execute. Apparently it slows the program down too much to be able to do more than 8 loops/sec.

    Use a faster BS2, like a BS2px.
  • panosathenspanosathens Posts: 5
    edited 2014-07-13 11:06
    i also checked it with 1 debug.I can't get more samples.Something is wrong with pulsin
    72sonett wrote: »
    Why do you need the $PORT COM2 directive?

    Maybe the 3 DEBUGs slow the program down too much to be able to do more than 8 loops/sec.
  • PublisonPublison Posts: 12,366
    edited 2014-07-13 11:25
    i also checked it with 1 debug.I can't get more samples.Something is wrong with pulsin

    PULSEIN has been around for ages. There is nothing wrong with it.

    As said before, DEBUG has quite a bit of overhead. Timing is the issue.

    I can try this on a BS2px tomorrow.
  • PublisonPublison Posts: 12,366
    edited 2014-07-14 08:29
    Well, I can't find my MX2125. I'll continue to look for it.
  • panosathenspanosathens Posts: 5
    edited 2014-07-14 15:14
    thanks a lot
    Publison wrote: »
    Well, I can't find my MX2125. I'll continue to look for it.
Sign In or Register to comment.