Shop OBEX P1 Docs P2 Docs Learn Events
IR object detection with 3 feet of wire — Parallax Forums

IR object detection with 3 feet of wire

markmbmmarkmbm Posts: 8
edited 2012-08-24 22:05 in BASIC Stamp
I'm trying to setup two IR detection circuits. One of them is on a BOE board and the other one is about three feet away on a bread board that is hooked up to the BOE board via P4, P6, Vss, and Vdd using 22 AWG hookup wire. When I upload the code to my STAMP, sensor two (irDetectTwo) works on the bread board that is three feet away but sensor one (irDetectOne) on the BOE board doesn't work. I don't see a short anywhere. If I remove all of sensor two components from P4, P6, Vss, and Vdd then sensor one works. Sensor one is hooked up similar to what is shown on page 231 (Robotics with the Boe-Bot). Am I drawing too much current? Do I need a capacitor?
' {$STAMP BS2e}
' {$PBASIC 2.5}

irDetectOne VAR Bit
irDetectTwo VAR Bit

DO
  FREQOUT 2, 1, 38500
  FREQOUT 6, 1, 38500

  irDetectOne = IN0
  irDetectTwo = IN4

  IF (irDetectOne = 0) THEN
    DEBUG "Sensor1"
  ENDIF
  IF (irDetectTwo = 0) THEN
    DEBUG "Sensor2"
  ENDIF

  PAUSE 100
LOOP

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-08-24 21:57
    You can't intersperse the FREQOUT and = INx statements. As the tutorial mentions, you have to put the =INx statement right after the corresponding FREQOUT statement like this
    FREQOUT 2, 1, 38500
    irDetectOne = IN0
    FREQOUT 6, 1, 38500
    irDetectTwo = IN4
    
  • markmbmmarkmbm Posts: 8
    edited 2012-08-24 22:04
    I found the problem. The FREQOUT and irDetect in need to be right next to each other.
    ' {$STAMP BS2e}
    ' {$PBASIC 2.5}
    
    irDetectOne VAR Bit
    irDetectTwo VAR Bit
    
    DO
      FREQOUT 2, 1, 38500
      irDetectOne = IN0
    
      FREQOUT 6, 1, 38500
      irDetectTwo = IN4
    
      IF (irDetectOne = 0) THEN
        DEBUG "Sensor1"
      ENDIF
      IF (irDetectTwo = 0) THEN
        DEBUG "Sensor2"
      ENDIF
    
      PAUSE 100
    LOOP
    
  • markmbmmarkmbm Posts: 8
    edited 2012-08-24 22:05
    Thanks Mike. I just figured that out.
Sign In or Register to comment.