Shop OBEX P1 Docs P2 Docs Learn Events
SX A/D conversion — Parallax Forums

SX A/D conversion

jmokiejmokie Posts: 13
edited 2006-11-02 01:35 in General Discussion
First time SX user, not familiar with machine code, former STAMP user and a electronics hacker needs help.·
I'm trying to use the a/d method in the sample code for the SXB on an SX28AC to read the output of a line sensor output to do PID control on the motors of my robot.· I'm using the Vishay TCRT5000 reflex detector.· The code is straight out of the example

I am trying to scale the output in a usable range.· The ckt is attached.
Right now with the resistors shown, the transistor·collector reads:

0.181 vdc with white resulting in .48 ma

3.08 with black resulting in .192 ma

Which sounds like a good range. But the a/d, monitored with the Watch/Poll command in the Debug mode,·starts counting at 0 or 1 @ 0.3vdc on the·collector·and reaches 240 @2.67 vdc, which is really dark grey.·

I would like to have 0·counts = white and 255 = black

My sensor has the emitter tied to gnd on the ckt board, so putting another resisor in the emitter ckt means more cut-n-kludge.· Hoping for some advice that will give a better range in counts.

Comments

  • BeanBean Posts: 8,129
    edited 2006-11-01 22:39
    If you already getting 0 to 240 why do you need 0 to 255 ?
    I'm not following what you want. You're not going to get consistance values everytime.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • jmokiejmokie Posts: 13
    edited 2006-11-02 01:35
    What I'd like to achieve is 0 or close to it with a piece of white paper under the sensor.· The high end can be anything darker than that.· I'd like to be able to set the PID to seek and achieve the whitest part of a strip on the line follower board.

    Is there any place that tells me the voltage range equivalent at Rb.1 for 0-255 counts?
Sign In or Register to comment.