Shop OBEX P1 Docs P2 Docs Learn Events
Problem using input on BOE — Parallax Forums

Problem using input on BOE

llryanllryan Posts: 5
edited 2007-12-21 18:26 in BASIC Stamp
Hi,
I am using a Stamps in Class BOE board to test a gear tooth sensor. I have it set up detecting gear teeth sensor pulses. I am connecting the pulses to one of the inputs (P7)·on the BOE so I can count them.
Here is the Basic:

' {$STAMP BS2}
' {$PBASIC 2.5}
toothcount VAR Word 'Also tried VAR Byte
DEBUG "Hall-effect sensor test program is running!", CR
DEBUG "Starting to count gear teeth", CR
DEBUG "
", CR
DO
·· DEBUG CRSRXY, 0, 3,· 'Start the line at col 0, 4th line down
· "Input logic level = ", BIN1 IN7 'Make sure P7 is·normally zero with everything wired
·· IF (IN7 = 1) THEN toothcount = toothcount+1 'ENDIF causes syntax error for some reason
··· DEBUG CRSRXY, 0, 5,"Number of gear teeth counted= ", DEC2 toothcount· 'Display
· 'the total -·max·will be 24 teeth
LOOP

When I substitute a manual pushbutton·into P7, and·wired like the whisker on P 171 of "Robotics With the Boe-Bot" it works. I can push the button and see the count increase from 00 to whatever. However when I connect the pulse output of the gear teeth sensor, I get no count at all. I have a scope connected to P7·and I can see the pulses go from zero to +5v. If I touch a logic probe to the wire to P7, I can see the pulses on the logic probe.

The sensor module is powered from the BOE +5V and an external 12V source that has common ground with the BOE (VSS)

Pulse width is 100 uS and swings from ground to +5V. Is this pulse too narrow for the BOE timing and CPU speed?

Thank you,

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-21 01:46
    I think the COUNT statement might do what you need. Have a look in the PBasic manual or under the help menu of the Stamp Editor. This counts the pulses that occur during a specified interval and can handle shorter pulses than a loop as you've programmed. The BS2 is just too slow to count individual pulses programmatically at that width.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-21 02:04
    By the way, forum rules say that you cannot post the same message under more than one forum. Please refrain from doing that in the future.
  • llryanllryan Posts: 5
    edited 2007-12-21 18:26
    Thank you for the help. I will try the count. I was suspecting my loop or something like that·was too slow for a 100 uS pulse.

    I also apologize for the double post. After posting it on the BASIC Stamp forum, I thought I posted it in the wrong forum and didn't know how to rescind it. But, as I just found out, it doesn't matter which. It will not happen again.

    Thanks again for the response.
Sign In or Register to comment.