Shop OBEX P1 Docs P2 Docs Learn Events
TSL1401-DB object for the Propeller Backpack — Parallax Forums

TSL1401-DB object for the Propeller Backpack

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2010-03-03 06:40 in Propeller 1
I've completed a rudimentary object for driving the TSL1401-DB from the Propeller Backpack. It performs these basic tasks:
  • Set the exposure time.
  • Acquire a 128-pixel 8-bit grayscale image.
  • Transfer the image array to the hub.
  • Transfer image stats (min/max pixel values and locations) to the hub.
The total time required to acquire an image with this object, exclusive of the hub transfer, is equal to the exposure time (20 µs to 70 ms), plus 3.2 ms for the acquisition.

To verify that it works, I've also written a down and dirty dirt simple PC monitor program (attached) that displays the pixel values as a real-time scope trace:

attachment.php?attachmentid=68286

Note that there's no way yet to change the exposure time from the PC. You have to do this manually in the attached Spin program. The reason this has not been included in the monitor program yet is that there are two ways to connect to the Backpack: via the Prop Plug and via an intervening BASIC Stamp, Propeller, etc. How to communicate the change info depends on how the Backpack is connected. If it's via a BASIC Stamp, you have to reset the Stamp (to get its attention) then send the data. But the Propeller requires much longer to come out of reset than the Stamp does, so the effect would not be instantaneous. Anyway, I didn't want to delay posting at least something while I dither on the best approach.

Thanks to all for your patience. I know this was a long time coming.

-Phil

_

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-03 04:54
    I don't know why I didn't think of this before. One solution to the lack of exposure control from the PC terminal program is autoexposure. If you use the attached, instead of the monitor program in the previously posted Spin archive, the highest pixel value will be held automatically between $C0 and $E0. (You will still need to download the archive to get the driver object.) The downside, however, is that if your subject is illuminated with fluorescent light, the pixels may "bounce" quite a bit.

    -Phil
  • TubularTubular Posts: 4,717
    edited 2010-03-03 05:20
    Phil,

    Thanks for your efforts once again.

    I have a backpack en route to me, but in the mean time can you please clarify whether this will work with a standard Prop setup (proto/demo board), or is an adc required somewhere?

    My first application is to try reading the stave and notes on piano sheet music... hopefully 128 px is enough for one stave if not two. My wife has recommended starting with ragtime (cos the durations don't matter as much), but I'm thinking something much more basic myself... and if that fails Pianola spools!

    cheers
    tubular
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-03 06:40
    Tubular,

    The software I've posted is designed for the Backpack and uses its sigma-delta ADC capabilities to read the pixel values. That's not to say that you couldn't use, say, the Propeller Demo board with an external ADC chip. It would require a change to the PASM adc routine to read the chip, and you could dispense with the calibration section. Also, for strictly black-and-white applications, you could simply run the analog output to a logic input, where it would be thresholded at Vdd/2. But you have to be careful that your subject is illuminated very evenly and has high contrast for this to work reliably.

    I really like your application idea! My recommendation is to start simple and work your way up from there. Pianola spools, or even marks on paper with a Sharpie, should provide a good foundation for more complex score reading.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 3/3/2010 7:03:26 PM GMT
Sign In or Register to comment.