Shop OBEX P1 Docs P2 Docs Learn Events
row column scanning of photocell array with bs2 — Parallax Forums

row column scanning of photocell array with bs2

K.CamarataK.Camarata Posts: 6
edited 2005-04-12 01:11 in BASIC Stamp
I have an 8 by 8 array of photocells that I would like to scan using a bs2. The rows are being scanned through an 8-bit shift register and the columns can be scanned using up to 10 bins of the bs2. Any ideas on how to pull this off?

thanks

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-04-11 07:28
    K.Camarata -

    It's not quite clear what the input to the Stamp is going to be. Is this a set of only 8 bits representing the active (1) or inactive (0) state of these photocells, or is this a numeric value (voltage perhaps)? It's also not quite clear if there are multiple shift registers, or only one?

    A simple diagram of how this is set up externally, would be real helpful. The implementation is fairly straightforward once the format of the data is known.

    Regards,

    Bruce Bates
  • K.CamarataK.Camarata Posts: 6
    edited 2005-04-11 14:39
    Ideally it would be a voltage and I would be using something like rctime to read it. This would allow me to threshold the photocells from within the software. (I could make an ADC from a comparitor if necessary) A digital input would be okay. The downside is that the threshold is then in the hardware and shifts in ambient light would affect the system.

    The system has a basic stamp and a shift register to control the row scan and 10 free pins to control and read the columns. (The system also has leds being powered by the same row shift register and being lit by pulling their own shift registers low, but that part works and may only confuse the topic).

    So - 3 pins are talking to the cascaded shift registers, 3 pins are reserved for future RF communication, and 10 pins are available for reading the 8 columns of photocells.


    See attached jpg for a schematic of the arrangement that I tested

    I was trying to read the columns using rctime. Unfortunately, the readings from this arrangement were unstable (was rctime charging all of the caps?).


    Thanks for your help!

    Ken
    563 x 587 - 28K
  • K.CamarataK.Camarata Posts: 6
    edited 2005-04-11 15:53
    Here is an external description of the system:

    I am building a set of interactive tables. We can call them the red and the yellow table. When you wave your hand over or place objects on the red table, red leds in it and in the yellow table light up as a visible shadow. The same is true with the yellow table. When you place an object on it or wave your hand over it yellow leds light up in it and in the red table. As a result, the tables carry a sort of telepresence relationship.

    So, what I have is a basic stamp2 and what is really an 8 by 24 array. 8 rows by 8 columns of red leds, 8 columns of amber leds, and 8 columns of photocells. The basic stamp is driving 3 cascading 8 bit shift registers (3 pins), talking to a surelink rf module (3 pins), and reading the 8 columns of photocells (10 available pins).

    thanks

    Ken
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-04-11 15:55
    Ken -

    I should offer this disclaimer first. I'm really more of a software guy than a hardware guy but I don't see how you're going to accomplish what you're trying to do with a shift register. Additionally it's a bit difficult to understand your set-up without seeing where the Stamp is in that circuit, and where the shift register you're talking about is fitting in. I presume the items on the right are the photocells?

    Are you sure you didn't mean a multiplexer rather than a shift register?

    A bit more information would be helpful.

    Bruce
  • K.CamarataK.Camarata Posts: 6
    edited 2005-04-11 16:03
    The shift registers take 8 bits and output them to their 8 pins (high or low). So, a 00000001 would result in the shift register having one row driven high. For the leds I am using them in reverse logic for the columns. If I send a 11111110 then the one column has a low bit and can light the led on the high row. This allows me to row column scan an 8 by 8 array of leds using 2 cascading shift registers (74HC595). -this works and I have been having fun making the leds chase each other around the array[noparse]:)[/noparse]

    The same shift register that is row scanning the leds is also powering up the columns of photocells. So, now I need to figure out how to read the photocells in each column.

    Does that make sense?
  • K.CamarataK.Camarata Posts: 6
    edited 2005-04-11 16:07
    I'll try and draw a more complete schematic for you. Also, yes, those are the photocells. I have a habit of using that visual icon for photocells ( instead of a traditional variable resistor ) when I'm thinking and should have changed the diagram before posting it. Sorry.


    K
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-04-11 16:57
    Ken -

    When you used the word "scanning" I was envisioning an input or reading operation, not a output or writing operation. I'll wait to say more until you re-vamp the schematic so the picture is more clear.

    Where does the RCTIME operation you spoke of come into play here?

    Bruce
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-04-11 17:21
    For each column, I'd be more inclined touse something like the following:

    SR     1n4148   photocell
     low ---->|------/\/\----;
                                     |
     low ---->|------/\/\----o
                                     |
    high ---->|------/\/\----o
                                     |
     low ---->|------/\/\----o
                                     |
                                     |
          stamp p0 ----------o
                                     |
                              =====
                                    |
                                 Vss
    
    



    The row driver that is high charges the single capacitor through the photocell, while the rows that are low have their photocells isolated by the diode.
    LOW 0
    RCTIME 0,0,mytime
    LOW 0

    I didn't understand the purpose of the transistors in your circuit.

    There are a couple of problems with this though.

    It will be hard to compensate for ambient light. Using RCTIME will give you some flexibility there, but the photocells would have to be pretty well matched. Otherwise it will be a mess of numbers.

    The RCTIME scheme will be slow. RCTIME is single tasking, so you have to do one point at a time. Allowing 0.1 second per point, and 64 points in the array, that is 6.4 seconds per scan.

    On the other hand, if you use a fixed threshold, you can query each row in parallel and do the whole scan in a small fraction of a second. But that leaves you with the problem of adjusting the threshold for ambient light. For that scheme, you'd be replacing the capacitor in the above diagram with a resistor for each column. Maybe you could make the resistor variable, a digital pot perhaps, and adjust it in firmware for ambient light.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-04-11 17:25
    Instead of a shift register, I would think about using two 4051B multiplexors. ...each photo-cell would require a diode to prevent
    resistive cross talk to adjacent photo-cells. With this setup you can still use your 11 I/O's.... 8-I/O's would control the +5V or High
    supply to the LED's and the "photo resistor-diode" leg. One 4051 would be used as providing the GND power to the LED's, while the
    other 4051 would be used to supply the resistive photoresistor value to a single capacitor in an RC configuration to the stamp. Both
    4051's would have their select lines (3 I/O's) tied together for stamp control. I can put together a schematic later if you wish.


    Do the LED's and photoresistors need to be powered at the same time? In other words are the LED's driving the photoresistors?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    Latest Company News
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071

    Post Edited (Beau Schwabe) : 4/11/2005 6:58:50 PM GMT
  • K.CamarataK.Camarata Posts: 6
    edited 2005-04-11 22:18
    Excellent! Thank you so much. I knew that I was making this more difficult than it needed to be.

    The transistor was an attempt to isolate the photocells from the signal line because it looked as if they were acting in parallel and affecting each other during reads. The problem REALLY was that each cell needs its own diode (not just a diode per row) to keep the power from working its way from one row to the next (through the photocells further down the row).
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-04-12 01:11
    K. Camarata,

    The schematic below uses 3 8051B's and a total of 7 stamp pins. For size I only drew a 3x3 matrix,
    but this circuit can handle an 8x8 and still only use 7 I/O pins

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    Latest Company News
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071

    Post Edited (Beau Schwabe) : 4/12/2005 1:16:58 AM GMT
    857 x 605 - 15K
Sign In or Register to comment.