Initial report by Diane Thomas

Description: a laser light source focused onto a photo-variable resistor; when laser beam is broken, the resistance value
of the photo-variable-resistor rises, causing a change of state of the digital input pin on the micro-controller from 1 to 0.

see site w/ images

Components:

Laser beam source - pen light, Chinatown ($5)
Batteries removed and + / - leads soldered for connection to electric power. In this case, the spring is ground and
encasing body positive.

Phototransistor
links:
Radio Shack (purchased here, slim on data)

Jameco Data-sheet

Notes selected from Wikipedia
A photodiode is an electronic component and a type of photodetector. It is a p-n junction designed
to be responsive to optical input. Photodiodes are provided with either a window or optical fibre connection, in order
to let in the light to the sensitive part of the device. Photodiodes can be used in either zero bias or reverse bias.
In zero bias, light falling on the diode causes a voltage to develop across the device, leading to a current
in the forward bias direction. This is called the photovoltaic effect, and is the basis for solar cells - in fact a solar
cell is just a large number of big, cheap photodiodes. Diodes usually have extremely high resistance when reverse biased.
This resistance is reduced when light of an appropriate frequency shines on the junction. Hence, a reverse biased diode can
be used as a detector by monitoring the current running through it. Circuits based on this effect are
more sensitive to light than ones based on the photovoltaic effect.

A phototransistor is a bipolar transistor that is encased in a transparent case so that light can reach
the Base-Collector diode. The phototransistor works like a photodiode, but with a much higher
sensitivity for light, because the electrons that tunnel through the Base-Collector diode are amplified by the transistor function.
A phototransistor has a slower response time than a photodiode. A bipolar junction transistor (BJT) is a type of transistor,
an amplifying or switching device constructed of doped semiconductors. Bipolar transistors are so named
because the main conduction channel employs both electrons and holes to carry the main electric current.

Semiconductors and N-type/ P-type doping for Semiconductors

Applications for Photodiodes / Phototransistors:

P-N photodiodes are used in applications similar to photoconductor family:
Consumer items such as camera light meters, clock radios (the ones that dim the display when it's dark)
and street lights usually seem to use photoconductors rather than photodiodes, although in principle either could be used.http://en.wikipedia.org/wiki/SemiconductorReceivers for remote controls in VCRs and televisions often use photodiodes.
Laser mouse action.

Proposed Application:

Break-beams in tandem to deliver casual population count.
The break-beam sensor can easily be used to trigger an event when a beam is broken; a state change from 1 to 0
(or when an obstacle is removed; a state change to 0 to 1). Beginning with using this as a tool to detect when a person has entered
a specific area (installation space). And it would,
obviously, also be useful to know when a person has left. Also, it would be useful to know how many people remain
in the area at any given time.

Ultimately, the series should describe a 4 enter/ exit space. The tandem lasers are called in sequential alphabet pairs,
with the earliest letter letter noting the out-most laser/diode and the inner-most the second in the pair, ie, AB = enter.
BA = exit. The outer beam must be tripped first when a body enters the site; a count of 1 is added when the A beam
is tripped before B.

A count of -1 is added (1 is subtracted) when B is tripped before A.||

To begin, a pair of AB laser/ diodes is prepared. A proto-type that houses 2 laser pen lights aimed at a separate box that
house 2 phototransistors. This second box is divided into 2 parts and lined with reflective tape with a hole cut in the center
of each half.
The phototransistor is mounted across each hole, the reflected light bounces off the back of the box and hits the front of the
transistor. When the transistor receives the light source, enough electrons are excited to allow the current to pass;
resistance is lowered. add box photo images 1,2

The population report is "casual" because there is a fairly wide margin for error. A person may stand blocking
a beam while others pass through returning a false count. Many people may pass through at one time, also returning
a false count. A measure of "single person pass time" might be added to debug
these 2 possible instances.

code for AB and CD sets?code for AB and CD sets



'totalpopcounter events:
'evaluate popcountvar
'all sounds ramped for volume (cross fade)
''midi to MaxMSP? buffer size as lone as track for1,2,3; fades to end 
'if popsize constistant to end to track
'if totalpopcounter = 0 do nothing
'if totalpopcounter = 1 or totalpopcounter < 4 do (1)whisper prayer 
'is 1 but less then 4
'if totalpopcounter =4 or totalpopcounter < 8 do(2) tibetian horn ' 
'is 4 but less then 7
'if totalpopcounter= 8 or totalpopcounter < 15 do (3)byzantine chant
'if totalpopcounter > 15 do nothing
define clock 3
define bits 10
define sampleus 20
define osc 4
inv9600 con 16468

Tx var portc.6
TRISB = %11111111
         AllSwitches var byte
         State var byte

         TotalPopCounter var byte
         PreviousPopCounter var byte
TRISC = %00000000        'for visual aid    check to pair correctly
     ALaserShow var portc.3   '"A"redLED
     BLaserShow var portc.4   '"B"redLED
     CLaserShow var portc.2   '"C"YellLED
     DLaserShow var portc.5   '"D"YellLED


'test chip
     high alasershow
     pause 200
     high blasershow
     pause 200
     high clasershow
     pause 200
     high dlasershow
     pause 200

     low alasershow
     low blasershow
     low clasershow
     low dlasershow
     pause 1000
    i var byte
     for  i = 0  to 1 
     totalpopcounter = 0
      next i 
       PreviousPopCounter = 0
  main:

  state = state
   totalpopcounter =  totalpopcounter


  'check laser targets
  if portb.7=1   then  'visual evidence that beam is hitting diode
     high aLasershow
       else
         low aLasershow
       endif

if portb.6=1   then  'visual evidence that beam is hitting diode
    high bLasershow
     else
        low bLasershow
     endif

'check laser targets
  if portb.4=1   then  'visual evidence that beam is hitting diode
     high cLasershow
       else
         low cLasershow
       endif

if portb.5=1   then  'visual evidence that beam is hitting diode
    high dLasershow
     else
        low dLasershow
     endif


'now readout and evalute the switch states
      pause 500

AllSwitches = PORTB & %11110000  'pins b.6, b.7
select case AllSwitches

        case %11110000   ' (all are high)
             state = 111

        case %00000000   ' (all are low)
           'both triggered
           state = 0

       case %01110000   '(if b.7 is low = Atriggered)
          state = 2   


       case %10110000 '(if b.6 is low= Btriggered)
         state = 3

       case %00110000     'b.6, b.7 (AB low, CD high)
         state = 1

       case %11000000      ' (AB are high, CD low)
             state = 10


       case %11100000   '(only C is low)
         state = 12



       case %11010000   ' (only D is low)
           state = 13   


          end select

serout2 tx,inv9600,[dec totalpopCounter,13,10]

if state = 111 or state = 0 then goto main
if state = 2 then GOTO ABEnterSet
if state = 3 then GOTO BAExitSet
if state = 12 then GOTO CDEnterSet
if state = 13 then GOTO DCExitSet

goto main


ABEnterSet:

  WHILE state = 2
  if portb.6 =0 then goto MyOneEnter
  wend
    state = state
    goto main

BAExitSet:
    while state = 3
    if portb.7 = 0 then goto MyOneExit
    wend
      state = state
      goto main


CDEnterSet:
    while state = 12
    if portb.5 = 0 then goto MyOneEnter
    wend
        state = state
        goto main


DCExitSet:
    while state = 13 
    if portb.4 = 0 then goto MyOneExit
    wend
         state = state
         goto main


MyOneEnter:

    totalpopcounter = totalpopcounter + 1 
    state = state
     goto main


MyOneExit:

  totalpopcounter = totalpopcounter - 1
  state = state
  goto  main