Uncategorized
The above video demonstrates the operation of an Arduino-driven proximity sensor constructed from a piece of aluminum foil, a resistor, an (optional) capacitor, and two LED’s. One observes marked brightening of the LED’s when the hand is about four inches above the aluminum foil – the foil does not have to be touched.
First, the credits. The project uses the Arduino CapSense Library written by Paul Badger in 2008. See the preceding link for the the needed library, the demo sketch, and a discussion of how CapSense works. The Arduino sketch below is based on Badger’s demo sketch.
Next, the caveats and sticky points. (1) To get good results, you may have to experiment. (2) Look at the output of the Arduino in the serial monitor. The first column gives the time needed for the Arduino to make one measurement and respond. The second column gives the “sensor reading”. (3) Use the second column to calibrate the system. (4) You may need to press the reset button if the system gets flaky. (5) You will notice marked changes in the behavior of the system according to the device that is providing it power. The video and also the settings used in the code below came from a system plugged into my laptop. If you plug it into the wall, it will give different readings. When the Arduino is connected to my laptop, bringing my hand near the laptop brightened the LED’s, just as they were brightened when I brought my hand near the aluminum foil. Why? Because my laptop is part of the capacitance of the circuit.
Overview:
Capacitative proximity sensor: When your hand gets near to or touches the tinfoil sensor, a light brightnes or turns on.
Circuit:
- 10 MOhm resistor between pins 2 and 4. Connect “sensor” wire to pin 2. Connect wire to tinfoil, etc.
- Pin 9 to LED to GND. (LED brightness is controlled by pulse-width modulation.) Same for pin 10.
Discussion:
- Uses a high value resistor e.g. 10M between send pin and receive pin.
- The Capsense library measures the time an RC circuit taked to return to state 1 after being forced in to state 2. This time is several multiples of the time constant RC. Thus, with the resistance R fixed, the measured time is a measurement of the capactance C.
- Human body capacitance is estimateed to be between 100 and 400 pF. If is 10 MOhms, and C 0s 100 pF, then RC is 1 ms.
- Resistor effects sensitivity, experiment with values, 50K – 50M. Larger resistor values yield larger sensor values.
- Receive pin is the sensor pin – attach aluminum foil for higher capacitance sensitivity.
- The values of threshold1, threshold2, and max were set by experimentation. Bring up the serial monitor (command-shift-M) and observe the numbers in the second column when your hand is far, news, or touching. Set these values accordingly. In the code below, LED 1 was set to respond only when my
hand was very close. LED 2 was set to respond to anything. - It helps to manually reset the arduino when the unit becomes flaky.
Arduino code
#include CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin // add a wire and or foil if desired int receivePin = 2; int sendPin = 4; int ledPin1 = 10; int ledPin2 = 9; void setup() { cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // above: turn off autocalibrate on channel 1 - just as an example Serial.begin(9600); pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); } void loop() { long start = millis(); long total = cs_4_2.capacitiveSensor(30); Serial.print(millis() - start); // check on performance in milliseconds Serial.print("\t"); // tab character for debug windown spacing Serial.print(total); // print sensor output Serial.println(); // parameters to set level for PWM output float level1; float level2; float threshold1 = 0; float threshold2 = 100; float max = 3000; if (total < threshold1) { level1 = 0; } else { level1= map(total,threshold1,max,0,1023); } if (total < threshold2) { level2 = 0; } else { level2= map(total,threshold2,max,0,1023); } analogWrite(ledPin1,level1); analogWrite(ledPin2,level2); delay(1); // arbitrary delay to limit data to serial port }
Dylan started a new film blog today:
My friend Harsh V. Pittie, passed away suddenly on Monday, January 16, 2012.
Harsh was born January 3, 1944, educated during long walks with his father, later at George School, Swarthmore, and Princeton, where he received his Ph.D in mathematics. He held a professorship at the University of Georgia, which he later renounced in order to care for his father in Mumbai during the last years of his life. After his father’s death, he moved to New York City. He loved to go to the ballet, to work crossword puzzles, and of course, to do mathematics. Harsh is survived by his sister, Nirja Kamani, and her two daughters, Anandita and Janhavi, all of Mumbai, India.
Harsh’s friends remember him for his humor, quick wit and brilliant intelligence. We regret his passing.
Two miles beneath the surface, in this South African gold mine, bacteria of the firmicutes clan have taken up residence. The advantages of this extreme real estate? The tight space, heat, and high pressure are not appealing to most species. Since it is dark, you can’t see the gold, so that selling point is pretty weak. But where you live is a personal choice, and has to be respected. Different strokes for different folks.
That said, taking up permanent residence two miles down takes some getting used to. Every living thing needs a source of chemical energy to run all those cellular processes. Photosynthesis? No sun. No way. Oxygen for respiration? There isn’t any. Gasp! What is their secret? Use hydrogen liberated from underground water by the decay of uranium. OK! That should last a while! Use the same heat source that keeps the depths hot so that our earth can maintain its lively geology with volcanoes, earthquakes, plate tectonics, etc. What an idea! The big question: what else is down there? Who is down there?
Related: Eyjafjallajokull, Beneath the floor …
The following recipe is useful for those living a grad student existence, whether they be in grad school or not. The recipe is inexpensive, requires little equipment, and is simple to execute. Even a math or physics grad student of the male gender can follow it successfully. I have used it many times myself, and have taught it to others in a variety of academic fields, from comparative literature to computer science. The instructions should be detailed enough for a PhD candidate with no cooking experience to follow, gain confidence in the culinary arts, and ensure sufficient caloric intake to complete a thesis.
Materials and equipment
One or more potatoes, depending on hunger level and ability. A fork, butter, salt, pepper, plate, and a microwave oven.
Procedure
(1) Wash potato (recommend but not required). Don’t bother to peel it. Stick fork in potato several times. (2) Place potato in microwave device for as long as you think it needs to be there. (3) Remove, split open. If it is not sufficiently cooked, go to 2. If the potato is burned, get a new one and go to 1. (4) Put the potato on a plate. Then mash in some butter and sprinkle with salt and pepper. Eat potato. (5) Put used plate on top of the other plates in the sink. If you wish, you may run some water over them. (6) Go back to doing whatever you were doing before step 1. Repeat entire process until 2 am as needed, then go to bed.
Notes
1. A tip from mom: to tell if the potato is cooked, look at the center. If it is sort of transparentish and hard by comparison with the part near the skin, the potato is not sufficiently cooked.
2. Acquire a timer and lab notebook. Keep careful records of oven settings, cooking times and result, e.g. “burned”, “raw”, “just right,” “yummy.” From the data you collect, you will quickly find the optimum cooking time, regardless of altitude, microwave power and frequency, type of potato, etc. After all, you are a grad student! At this point, you will be ready to invite friends over for a potato dinner. Your cooking skill will amaze your friends, particularly those of the opposite sex.
Song of the Earth
The day’s eye is His eye, it burns
With fearsome, hot embrace. She twists, turns
But cannot flee that ancient heavy pull,
That passion which came to her so long ago
And filled the eternal cold of night
With his light, and a thousand songs of love.
And then, after the customary journey,
The sounds of life, a buzzing, humming, and chirping
From every corner of their joyful marriage house.
But now he has grown mad: he spurns the children,
Pulls her closer, ever closer to his raging
Fiery gaze. Waters where fish swam
Have boiled away and now no song is sung.
No birds take wing nor does any seed sprout.
Yet still he draws her closer. She cries out,
But cannot flee that ancient heavy pull.
(c) Jim Carlson 12/9/1993