Shop OBEX P1 Docs P2 Docs Learn Events
QRD1114 Optical Detector - QTI Sensor Code — Parallax Forums

QRD1114 Optical Detector - QTI Sensor Code

JBWolfJBWolf Posts: 405
edited 2013-07-18 17:27 in Propeller 1
I built one of these from scratch with the exast same sensor...
http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/ProductID/100/txtSearch/qti/List/1/Default.aspx

I was planning to follow the phototransistor lesson in the PEKit book, but found the WTI sensor uses less components and seems much simpler... But the OBEX link is dead.
I simply need to get this working for basic object detection within 5mm, I need to identify when something is directly infront of the sensor.
Here is the sensor I purchased:
https://www.sparkfun.com/products/246

If there is an obex available for this I would love to work with that rather than starting at scratch.
I am using the propeller, not basic stamp.
Can anyone find a link to this obex for the prop?
If it does exist, maybe someone can update the webstore link.

Thanks

Comments

  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2013-07-16 20:14
    http://obex.parallax.com/object/437

    Two ways to find objects in the new OBEX that have broken links mapped to the old OBEX:

    1) A site restricted google search: add "site:obex.parallax.com" to a google search
    2) In the OBEX, click "ALL" in the upper left and then change the projects per to "ALL". This will give you one web page with all objects and you can use Control-F to find text on the page.
  • JBWolfJBWolf Posts: 405
    edited 2013-07-18 17:27
    Thanks,
    Right afterwards I went back to the PEkit book and got it working within 20 minutes lol.
    I used the TestRcDecay.spin object from chapter 7: "Counter Modules and Circuit Applications Lab". Page 126 & 133
    See those two pages for the schematics & wiring diagrams.
    Set it up exactly as in the book and viola! works great!
    Also have a potentiometer going with it.
    Modified the code a lil to get rid of the extra stuff spamming on the PST screen... now it just refreshes each value on one line each so it is much easier to read.

    Here is the code useful for the QRD1114 'Optical Detector' from sparkfun.
    ''This code example is from Propeller Education Kit Labs: Fundamentals, v1.2.
    ''A .pdf copy of the book is available from www.parallax.com, and also through
    ''the Propeller Tool software's Help menu (v1.2.6 or newer).
    ''
    '' TestRcDecay (Modified for Concurrent Measurements).spin
    '' Test RC decay measurements on two circuits concurrently.
    
    CON
       
      _clkmode = xtal1 + pll16x                  ' System clock → 80 MHz
      _xinfreq = 5_000_000
    
    OBJ
       
      pst : "Parallax Serial Terminal"           ' Use with Parallax Serial Terminal to
                                                 ' display values 
       
    PUB Init
    
      'Start Parallax Serial Terminal; waits 1 s for you to click Enable button
    
      pst.Start(115_200)
    
      ' Configure counter modules.
    
      ctra[30..26] := 000                     ' Set CTRA mode to "POS detector"
      ctra[5..0] := 20                           ' Set APIN to P20 (Potentiometer 10k)
      frqa := 1                                  ' Increment phsa by 1 for each clock tick
    
      ctrb[30..26] := 000                     ' Set CTRB mode to "POS detector"
      ctrb[5..0] := 25                           ' Set APIN to P25 (IR Collector)
      frqb := 1                                  ' Increment phsb by 1 for each clock tick
    
      main                                       ' Call the Main method
    
    PUB Main | time[2]
    
    '' Repeatedly takes and displays P20 & P25 RC decay measurements.
    
      repeat
    
         ' Charge RC circuits.
    
         dira[20] := outa[20] := 1               ' Set P20 to output-high
         dira[25] := outa[25] := 1               ' Set P25 to output-high
         waitcnt(clkfreq/10_000 + cnt)           ' Wait for circuit to charge
          
         ' Start RC decay measurements...
    
         phsa~                                   ' Clear the phsa register
         dira[20]~                               ' Pin to input stops charging circuit
         phsb~                                   ' Clear the phsb register
         dira[25]~                               ' Pin to input stops charging circuit
    
         ' Optional - do other things during the measurement.
    
           waitcnt(clkfreq/60 + cnt)        
    
         ' Measurement has been ready for a while.  Adjust ticks between phsa~
         ' and dira[20]~.  Repeat for phsb~ and dira[25]~.
     
         time[0] := (phsa - 624) #> 0                
         time[1] := (phsb - 624) #> 0                
         
         ' Display Results                                  
    
         pst.Str(String(pst#NL, "Potentiometer = "))
         pst.Dec(time[0])
         pst.Str(String(pst#NL,"IR Sensor = "))
         pst.Dec(time[1])
         waitcnt(clkfreq/2 + cnt)
         pst.str(string(pst#cs))  
    
    
Sign In or Register to comment.