Sensing with a computer
External stimulus -> sensor/transducer -> amplifier -> analog processing -> A/D converter
-> computer port -> software processing -> sensor output/decision-making
Example: Building a light sensor for a laser
-
Building a sensor with a photoresistor
-
Resistance decreases with increasing light levels
-
Need to convert ohms to voltage/current
-
Use a simple inverting/non-inverting op-amp circuit
-
Look at the gain (megaohms to 100 ohms) using a fixed feedback resistor
-
Set the power supply to an appropriate value
-
How do you deal with noise in the system?
-
Is there sufficient difference between the lights on/lights off and the laser that you don't need to worry about noise?
-
Do you need to shade the sensor?
-
Do you need to chop the laser at a high frequency and then integrate/low-pass the rectified AC signal?
-
How do you make a decision with the signal?
-
Analog logic that sets a TTL level: set the output to the integrated output, a low signal represents when the laser has been broken.
-
Let the op-amp saturate at 5V max signal
-
Make sure the op-amp does not saturate and has a low value when the laser is off
-
A/D convert and use software processing to make a decision: look at the signal over time and make a decision using a rule-based framework.
Example: motion sensor using ultrasonic transducers
-
Get a transmitter and a receiver
-
Pulse the transmitter with a big pulse (square wave, short duration, high voltage)
-
Sensing voltage across the receiver (connect one side to ground, the other to an op-amp)
-
Amplify the signal to a reasonable level
-
Integrate the signal so that the output of the system is a big peak whose maximum is directly related to the return time by some offset.
-
A/D convert the signal and take the maximum value as the return time
-
Do the calculations
-
Sound = ~300m/s
-
We want to resolve 5cm (theoretical limit is 0.5 cm)
-
Therefore, we need to be able to resolve the difference between peaks that are .05m / 300 m/s = .16ms apart
-
Therefore, we need to sample at least twice that frequency (~12kHz)
-
Then we come up with an equation D = (time + offset) * speed
-
offset is found using a calibration procedure
-
To use as a motion sensor, just look for significant changes in the distance. When the change is above a certain number, then activate the alarm/turn on the lights/whatever...