Shop OBEX P1 Docs P2 Docs Learn Events
How to make ADC with RCTIME. — Parallax Forums

How to make ADC with RCTIME.

stevetronikstevetronik Posts: 15
edited 2010-02-02 23:38 in Propeller 1
Well legitamately this is a second post, since no one reply the first one, but I'll ask a slightly different question.

Original Post : http://forums.parallax.com/showthread.php?p=875743
above post is talking about using flexiforce sensor on propeller. I have yet to solve the problem, I'll greatly appreciate anyone can advice on the problem

I want to use propeller to accept analogs input, from 'flexiforce' as well as

now a IR sensor , Sharp GP2YOA or GP2D12.

How do you use RCTIME to do that?


long RCValue
  
OBJ
  tv    : "vga_text"
  gr    : "graphics"
  RC    : "RCTIME"
  Num   : "Numbers"

PUB start
  tv.start(16)                 'start vga display

    'Initialize RCValue
  RCValue := 0
  RC.start(0,1,@RCValue )

  repeat
    tv.out(1)
    tv.str(string("R = "))
    tv.dec(RCValue)



I'm using the above code for flexiforce, I've yet to test with IR sensor.

Advice is greatly appreciated.

Steve,

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-01 05:02
    Look in the RCTIME section of www.emesystems.com using the "app-notes" link near the bottom of the page.

    I strongly suggest using the analog to digital conversion routine included in the application note on the cog counters (AN001) here:

    www.parallax.com/tabid/832/Default.aspx
  • stevetronikstevetronik Posts: 15
    edited 2010-02-01 06:15
    Somebody said...
    The two 1nF capacitors and the 100kΩ resistor must be placed within 1 inch (2.5 cm) of the Propeller
    chip for stable operation of the circuit and any excess leads must be cut away. This circuit will not
    work properly by placing it on a breadboard. The component marked as an asterisk is chosen
    according to the application.
    From the ANN001

    Seems like it is very unstable, I'm using the Demoboard which seems to have to make connections on the breadboard.

    Any advice to read analog value?

    Thank you
    Steve
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-02-01 06:32
    Hi Steve,

    depending on the sample-rate and the resolution it might be working stable at lower frequencies and with using higher capacitances.

    But I can not say which values you would have to choose.

    Or using an external Chip like the MCP3208. For this chip already exists an object in the obex

    best regards

    Stefan
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-01 06:37
    The Demo Board already uses this for the microphone. It's not unstable. It's just that the switching speeds are so high (12.5ns clock) that lead length for the capacitors and feedback resistor become significant. With the Demo Board, it's hard to add additional ADCs this way. The Propeller Backpack has two ADCs that share one feedback I/O pin (so you can only use one at a time). It's pretty straightforward to add several ADCs to a Protoboard.
  • stevetronikstevetronik Posts: 15
    edited 2010-02-01 07:47
    So i assumes that I cant fiddle with the demoboard to get A to D values.

    Anyway solution i can use to read and intepret Analog values

    Steve,
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-02-01 08:06
    fiddle and give the ANN001-circuit a try and use a bigger capacitance and a slower switching speed

    The RCTime solution is pretty slow even compared to a slowed-down ANN001-circuit

    Tell us what the maximum-speed is that you need the digital value.

    If its only 5 times a second you can slow down the ANN001-circuit a lot

    And at such a low speed you can wrap the wires three times around the whole demoboard before you connect it to the capacitors

    best regards

    Stefan
  • stevetronikstevetronik Posts: 15
    edited 2010-02-01 08:25
    Somebody said...
    The Flexiforce has an ideal output for A/D conversion - 0V is no force and 4.2V is 100 lbs. The RCTIME command may be used with a LOOKUP table or calibration formula to execute some math to make the output useful.

    CON
       _clkmode = xtal1 + pll16x
       _xinfreq = 5_000_000
       _stack = ($3000 + $3000 + 100) >> 2   'accomodate display memory and stack  
       
       
    VAR
      
      long RCValue
      
      
    OBJ
      tv    : "vga_text"
      gr    : "graphics"
      RC    : "RCTIME"
      Num   : "Numbers"
    
    PUB start
      tv.start(16)                 'start vga display
    
        'Initialize RCValue
      RCValue := 0
      RC.start(1,1,@RCValue )
    
      repeat
        tv.out(1)
        tv.str(string("R = "))
        tv.dec(RCValue)
    



    I'm using the above code, reading from pin 1, with a circuitry provided meant for BASIC stamp, the value i get from RCValue, is a long number than changes, at high force compress the value changes very fast, (rather than increase or decreas as normal analog value should be). at no force the number stop changing.
    I don;t see any relation in the value produce.
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-02-01 10:30
    The circuit works NON-linear. It is a basic and simple circuit that CAN'T provide a linear output.
    This means the flexisensor IS linear. The rctime-ciruit is NON-linear.
    This is the reason why you can't "see" an easy to analyse correlation. And this is the reason why Mike recommended using the ANN001-circuit which works different.

    If you still want to use the rc-time-circuit, you have to measure the force and the digital values and build a lookuptable like mentioned above
    to compensate the non-linearity of the rc-time-circuit.

    Excel and OO-calc provide a function to calculate an aproximation-formula to any kind of curves like linear, exponential, polynomical or logarithmic curves

    best regards

    Stefan
  • grouchygrouchy Posts: 16
    edited 2010-02-01 16:31
    I modified the demo board to use the adc pins normally used by the microphone. I jumpered from the breadboard to the end of the 100K resistor as shown in the picture. Then you just have to add a suitable input resistor, like 150K.· Pull the microphone out of its socket.
    You can use this to read analog voltages.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Rudy's CNC Freeware·· http://www.enter.net/~schleinkofer
    640 x 588 - 104K
  • stevetronikstevetronik Posts: 15
    edited 2010-02-02 06:10
    wow grouchy, ( i have no idea that was a michrophone) (getting amazed by propeller by the moment)

    I would prolly used that as a last resort, would like try Mike Green suggestion on AN001 at the moment.

    Stefan: As for a look up table, I was thinking linear and non linear, hence I wouldnt be able to set a treshold level specifying 0 and 1(too much force -1 and too less force -0) in spin.
    so to formulate that look up table do i use the value obtained from tv.dec(RCValue) ?

    thanks guys
    Steve,
  • stephenwagnerstephenwagner Posts: 147
    edited 2010-02-02 18:14
    FYI

    I have benn using the demo board for audio applications.

    Here is what I have done while working on my audio delay project.

    I built the ADC by:
    1.·plugging in a 100K ohm resister into P0 and P6. short wire into P0 and long wire into P6
    2. pluging in a 0.001uF ceramic disk capacitor into vss and soldering to the resistor wire at P6
    3. Pluging in a 0.001uF ceramic disk capacitor into vdd and sodering to the resistor wire at P6
    4. Soldering a 47K ohm resistor to the resistor wire at P6 and connecting the other end to my line level audio source
    5. Soldering with very small wires a 1K ohm resistor accross the 10K resistor at the RC network between the amplifier and the headphone jack. This will raise the corrner frequency from approximatly 1.59Khz to 15.9Khz.

    The ADC was stable and the audio quality fantastic.

    You can play with the gain by changing the 47K ohm resistor.

    I still need to thank a few form members for their support with my project.

    I hope this helps.

    SJW
  • stephenwagnerstephenwagner Posts: 147
    edited 2010-02-02 18:28
    There are some realy neat articals on how to straighten a non linear curve in the old basic stamp 1 manual found here:

    http://www.parallax.com/Portals/0/Downloads/appnt/stamps/bs1Appnotes.pdf

    Practical Pulse Measurements and Using a Thermistor. You can use MS Xcell plot wizard to back out the power-series polynomial equation.

    I hope this helps

    SJW
  • edited 2010-02-02 23:38
    I missed this thread because I was obsessing over revisions to a chapter draft on measuring resistance and capacitance with the Propeller.·Must have been overdue for·a dose of irony. At any rate, the chapter and source code are all at:

    forums.parallax.com
    ·· -> Propeller Chip
    ······ -> Propeller Education Kit Labs, Tools, and Applications
    ·········· -> Measure Resistance and Capacitance

    This chapter uses RC decay/growth circuits that return measurements that are linear - directly proportional to the variable element (R or C).· The linearity is demonstrated with an ohmmeter application that's good to 1% over four decades. It's the fourth post in the thread.

    Incidentally, there are more chapters like this one at:

    forums.parallax.com
    ·· -> Propeller Chip
    ····· -> Propeller Education Kit Labs, Tools, and Applications

    Please drop me a line if you have any suggestions to improve the material or find any typos.

    Thanks, Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 2/3/2010 10:22:55 PM GMT
Sign In or Register to comment.