Week 11:
Input Devices

Objectives

My geranium is dying. How am I suppposed to have a beautiful vertical farm desk for my final project when I can't keep a plant alive? I am making a humidity sensor for plant soil.

The shape of a commercial one is like a chignon pin. I will emphasize that.

Software

Machines

////

Vocabulary

STEP RESPONSE. "Step response is the time behaviour of the outputs of a general system when its inputs change from zero to one in a very short time." Why it matters: "From a practical standpoint, knowing how the system responds to a sudden input is important because large and possibly fast deviations from the long term steady state may have extreme effects on the component itself and on other portions of the overall system dependent on this component. In addition, the overall system cannot act until the component's output settles down to some vicinity of its final state, delaying the overall system response. Formally, knowing the step response of a dynamical system gives information on the stability of such a system, and on its ability to reach one stationary state when starting from another." ~ info from Wikipedia

CAPACITANCE. When we are looking at this, we are measuring discharge that occurs when something measurable (a human body, a plant, anything organic, essentially, that contains water) comes into contact with the capacitance field ~ i.e., the largish areas of copper. Larger areas of copper produce more sensitivity because they collect more electrons, and therefore the discharge has a greater "step." There's a balance between too small to read and too large for an effective reading.

Objectives

Practices

 BASIC STEPS TO CONNECT SENSORS:

(1) Choose - (2) Design - (3) Mill - (4) Stuff - (5) Connect - (6) Program - (7) Record

And the files.
And, finally, some research and methods on Application.

Here's a little more elaboration on the list, before going into a mountain of details:

 GOING THROUGH THE STEPS IN MORE DETAIL

(1) Choose.

I want to look at humidity sensors.

I'm starting with Neil's TxRx step reponse board plus a capacitance sensor. Where I want to get to is dielectric measurements of plants and other living substrates so that I can read how they are affected by electricity / waves.

(2) Design Board(s).

 START

Notes on some parts:

Some settings in Eagle:

 USING EAGLE TO MAKE A MORE INTERESTING BOARD DESIGN

 ADDING AN ICON

I opened the exported .png in Gimp, added an icon, and saved again as .png.

More about the genesis of the icon below.

 CUSTOMIZING BOARDS MORE INTENSIVELY: SOME NOTES

I wanted my humidity sensor to look like a chignon pin for hair. I used Illustrator to draw it, using the pen tool.

I had numerous failed designs before achieving what I wanted. Had a difficult time getting the outline file and the traces file to line up, and also it took me some effort to figure out how to mill off the copper and not mill unnecessarily over the outline. I worked in Eagle, Illustrator, Photoshop, Gimp, and the Fab Modules.

I tried a bunch of things to mill away the copper exactly where I wanted.

Therefore, some advice ...

 FAILED ATTEMPT TO IMPORT A PATH FOR A BOARD OUTLINE INTO EAGLE

After a lot of time trying to run a ULP to import a .dxf or .bmp from Illustrator, I abandoned this and went straight to Illustrator to draw the .png to run in FabModules.

In designing, I referred to the work of / was inspired by Ani Liu, Matt Blackshaw, Francesca Perona, and Arnau Tasies.

(3) MILL BOARD(S)

This is a good page on the process.

Straightforward, right? It seems nothing is straightforward!! Spent night of 29 April fighting with a Linux system that crashed repeatedly when I tried to retrieve files to load in Fab Modules for the Roland Modela MDX-20. It seemed all my files were sized well, then I would open in FabModules, and I'd see unexpected sizes. Getting images loaded, lined up, the drill lined up, breaking the drill bit, etc ... it took hours.

Supplies used:

Not going well:

The scratch was due to an error in the "z" in Fab Modules. I didn't know that at the time. Also, you can see the images were not lining up.

 PROBLEMS WITH MILLING

I carefully milled another based on a -1 offset design. I started w a cut depth of .1 and sent the file a total of 3x, going down 0.5mm each time: cut depth of .15 and cut depth of .20. The unevenness meant some parts got milled totally while others were just barely scratched, hence the minutely increasing increments on the "z."

The words are not visible ... will figure this out at another opportunity.

However ...

The board will NOT lie flat! This video shows why it matters:

If your board does not mill evenly, try going down incrementally each time:

first try on the left, successful milling in the middle, step response board on the right top didn't work ~ redesign on the bottom! ~ This is before stuffing!

PLEASE NOTE: After milling, I forgot to use steel wool and dish soap to clean my boards. I soldered directly. I was having a hell of a time soldering, and I think it was both more difficult and didn't work because I forgot this step!!!

FILES

3 .pngs for (finalized) Step Response (one is .png is for words) // 2 .rml files (board size = 37 x 38mm)

step .png and .rml

2 .pngs for capacitance board // 2 .rml files (board size = 140 x 40mm)

chignon .png and .rml
Jisun helped model the board! Back to Top

(4) Stuff Board(s)

(5) Connect Board(s)

correct wiring on left; wrong traces and bad soldering on the right!

I discovered some problems when I tried to program ~ had not traced the circuit well, so I added a jumper to rectify. Still didn't work, so I eventually did a total re-design. It's the redesign that's in the files above.

redesigned traces

(6) Program Boards

A little mistake ...

 I unplugged board while program was running. Oops. I tried to exit Python by running command:
exit()
But nothing happened. So I quit out of the Python application. When I returned to Terminal I still didn't have my prompt, but had a carot instead of my shell. To return to the shell, typing "control-C" worked.

(7) Record.

Video of successful capacitance measuring:

Programming files:

These are for the Step Response Tx-Rx board.

.make, .c, and .py

Application & Complication

  To apply the capacitive sensor to a project requires a few more steps. You'd need to take the readings from the sensor and create code that uses "if" statements to route the readings into a variety of outputs. Though I do not at present have time to write new code that results in conditional outputs, I have commented a capacitive sensing code from the Arduino playground so that what is happening is clear, and how one would use it for further next steps is clarified. I've applied the explanation to my current sensor, the capacitive chignon.

EXPLANATION.  The capacitive sensor works by attaching two pins to a sheet of electrons -- a large piece of copper, for example, or, in my case, copper on a PCB in the shape of a chignon pin. The two processor pins are wired differently and coded separately. One of the pins is the send pin, and it connects to the copper field via a large resistor, something like 10M ohms (much larger than we use for standard pullups or pulldowns). The send pin (which is pin 4 in the code below) sends out a square wave, which is slowed down by a big resistance, crosses the copper surface, and reaches the receive pin of the Arduino, which in the code below is pin 2, also called the sensor pin.

Why the big resistance?  When you put a human body or other dielectric medium to the copper surface, the electrons are pulled through the resistor more easily. The charge resides in the big fat organic stuff (i.e., body, or other thing that functions as a sink), before that thing gets replete and passes the charge along, where it is received by the Arduino pin (in this case, pin 2). Since, if you take the organic half of the capacitor out of the system, you should get a constant flow at a particular time, you can measure different materials' different capacities by changing out the half of this embedded system that is not the copper. In the real world example below, I switched the human hand for a plant in wet soil, to see how the readings might or might not produce enough of a level of difference so as to be useful in writing code that could sample the readings to create a usable output.
 In case it is not clear, what is useful for the code is seeing the difference in the numbers based on the physical conditions affecting the copper field. The conditions affect the reading from the receive pin, which is counting time via program ticks. So a greater resistance means more possible variety in timing, which equates to more sensitivity.
 You see the difference in the numbers via the serial monitor.

This good explanatory video includes this relevant part:



Now, here is the commented Arduino code for a capacitive sensor -- please note that you need the Capacitive Library from Arduino to run this, and you can find that here.

#include <CapacitiveSensor.h>

/*
 * CapacitiveSense Library Demo Sketch
 * Paul Badger 2008
 * Uses a high value resistor e.g. 10M between send pin and receive pin
 * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
 * Receive pin is the sensor pin - try different amounts of foil/metal on this pin

 Commented by Janaki Ranpura, Fab Lab BCN, 20170707.
 */

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
                                                          // to be clear on how to wire: pin 4 sends a square wave from the Arduino, 
                                                          // it passes through high resistance to a copper field (connect pin to big resistor to copper)
                                                          // the copper field + body or other dielectric material creates a capacitor
                                                          // the copper field is connected to pin 2, which is coded as an input
                                                          // the serial monitor states how many program ticks passed between the square wave output
                                                          // and the square wave receipt as input on pin 2

void setup()                    
{
   cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   Serial.begin(9600);
}

void loop()                    
{
    long start = millis();                        // this is milliseconds
    long total1 =  cs_4_2.capacitiveSensor(30);   // this is program ticks
                                                  // this means that the two numbers you see in the serial monitor
                                                  // are not in the same units
                                                  
    Serial.print(millis() - start);        // check on performance in milliseconds
                                           // the first number printed here is stating when the pin activated; it is not so relevant for our purposes
    Serial.print("\t");                    // tab character for debug windown spacing

    Serial.println(total1);                  // print sensor output 1
 

    delay(1000);                             // arbitrary delay to limit data to serial port 
}

USING IT.  Here is some data collected using these methods. It is collected to solve the question: how would I make a system to water plants based on the capacitive sensor that I have? The answer is to determine the limits of the sensor in different conditions and use those limits as the edges of conditional statements in code. I have only had time to gather some data on what the perimeters would be.


--------------------

--------------------
--------------------

 Based on the data, I would say that it would be possible to make code for this system that sends fairly reliable feedback on whether or not your plant needs water; in this case, you would need to hold your plant's leaf, look into its eyes, and ask it.
 A more sensitive no-touching system would need further experimentation with the size of the copper fields and the size of the resistance on the send pin.

  The idea of a hair pin that measures water or air quality based on the relative changes in women's hair in a neighborhood still totally charms me; it just would require a much more subtle system than the one I was able to build in this unit. It's yet another simple, alluring idea that is not at all simple to create.

THEORIES, IDEAS, EVENTS, INSPIRATIONS:

MY ICON

A little bit about my the genesis of my icon ... The icon comes from a graphic representation of "the most popular story in Western Civilization" as diagrammed à la Kurt Vonnegut combined with the date Hiroshii Ishii suggested we use when we envision the future viability of our designs: the year 2200, far enough into the future so that everyone we ever meet today is likely to be dead.

Return to section on customizing boards, or to the list of steps near the top.

And I want to recommend again Hiroshii Ishii's talk.

Back to the top