bs2p24 with accelerometer mx2125
panosathens
Posts: 5
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
'{$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
BTW, cross-posting is against forum rules, so I've removed your duplicate post for you.
Also,
-Phil
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.
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.
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.