Shop OBEX P1 Docs P2 Docs Learn Events
ADC without additional components in spin. — Parallax Forums

ADC without additional components in spin.

RoderickhRoderickh Posts: 2
edited 2011-03-21 09:36 in Propeller 1
Hi everybody,

I'm a 1st year student working on a project using the stingray robot.
My job is to get the Qti Line follower (#28108) to work on the Propeller Robot Control Board, MSR1 (28230) without the use of any extra components like the ADC083. Resistors,capacitors and diodes are allowed though.
The propeller manual says that it should be possible using the counters, to bad it doesn't say wich one..
I have searched the a lot on google and this forum but couldn't find any examples. Obex doesn't seem to have an object in for spin either.
The only solutions i have found were written for BS or used additional components, except for the AN001 doc, but that didn't cleared things up for me..

Does someone have any experience with the Qti line follower in spin?
It would help me out a lot!

Thanks in advance.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-03-20 15:02
    Look at the BS2 Functions object from the Object Exchange. The QTI Line Follower is designed to be used with the RCTIME statement of the Stamps and there's an RCTIME equivalent for the Propeller as part of the BS2 Functions object. There's a description of this technique for measuring voltages here. Use the "app-notes" link at the bottom of the page.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-03-20 15:46
    Be aware that if you use the BS2 functions object your program will be burdened with all of the methods in it (unless you're using BST which removes dead code). If you're using the Propeller Tool, this will method is similar to RCTIME -- you may need to adjust some timing. I use this in the EFX-TEK AP-16+ for reading the PRE and POST play pots.
    pub readpot(p)
    
    '' Reads RC circuit on pin p
    '' -- takes about 2ms
    '' -- assumes 10K + 0.01uF
    
      ctra := (%01000 << 26) | p                                    ' ctra in pos detect mode 
      frqa := 1
    
      outa[p] := 1                                                  ' charge cap
      dira[p] := 1
      waitcnt((clkfreq >> 10) + cnt)                                ' ~1ms @100MHz
    
      phsa := 0                                                     ' clear counter
      dira[p] := 0                                                  ' allow discharge
      repeat while (ina[p] == 1)   
      ctra := 0                                                     ' disable ctra
      
      return (phsa >> 4) <# 500                                     ' return discharge time
    

    Note, too, that for my application of scrub off the lower four bits and truncate the value at 500.
  • RoderickhRoderickh Posts: 2
    edited 2011-03-21 09:36
    Thanks for the quick response, I'll see what i can do with it tomorrow!
Sign In or Register to comment.