<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bed_Data</title>
	<atom:link href="http://beddata.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://beddata.com/blog</link>
	<description>Bed Behavior Research</description>
	<lastBuildDate>Tue, 30 Mar 2010 04:03:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Arduino code for Bed_data</title>
		<link>http://beddata.com/blog/?p=57</link>
		<comments>http://beddata.com/blog/?p=57#comments</comments>
		<pubDate>Tue, 30 Mar 2010 04:03:23 +0000</pubDate>
		<dc:creator>mustafa</dc:creator>
				<category><![CDATA[Arduino]]></category>

		<guid isPermaLink="false">http://beddata.com/blog/?p=57</guid>
		<description><![CDATA[int sensorValue[80];  // an array to store the sensor values
// the address pins will go in order from the first one:
#define firstAddressPin 8
#define ThermistorPIN 0   // Analog Pin 0
double temp;
//////////////////////////////temperature alg
#include

//Schematic:
// [Ground] &#8212;- [10k-Resister] &#8212;&#8212;-&#124;&#8212;&#8212;- [Thermistor] &#8212;- [+5v]
//               [...]]]></description>
			<content:encoded><![CDATA[<p>int sensorValue[80];  // an array to store the sensor values</p>
<p>// the address pins will go in order from the first one:<br />
#define firstAddressPin 8</p>
<p>#define ThermistorPIN 0   // Analog Pin 0<br />
double temp;</p>
<p>//////////////////////////////temperature alg</p>
<p>#include<br />
<math.h>
//Schematic:<br />
// [Ground] &#8212;- [10k-Resister] &#8212;&#8212;-|&#8212;&#8212;- [Thermistor] &#8212;- [+5v]<br />
//                                     |<br />
//                                Analog Pin 0</p>
<p>double Thermistor(int RawADC) {<br />
  // Inputs ADC Value from Thermistor and outputs Temperature in Celsius<br />
  //  requires: include<br />
<math.h>
  // Utilizes the Steinhart-Hart Thermistor Equation:<br />
  //    Temperature in Kelvin = 1 / {A + B[ln(R)] + C[ln(R)]^3}<br />
  //    where A = 0.001129148, B = 0.000234125 and C = 8.76741E-08<br />
  long Resistance;<br />
  double Temp;  // Dual-Purpose variable to save space.<br />
  Resistance=((10240000/RawADC) &#8211; 10000);  // Assuming a 10k Thermistor.  Calculation is actually: Resistance = (1024/ADC)<br />
  Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later. // &#8220;Temp&#8221; means &#8220;Temporary&#8221; on this line.<br />
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));   // Now it means both &#8220;Temporary&#8221; and &#8220;Temperature&#8221;<br />
  Temp = Temp &#8211; 273.15;  // Convert Kelvin to Celsius                                         // Now it only means &#8220;Temperature&#8221;</p>
<p>  // Uncomment this line for the function to return Fahrenheit instead.<br />
  //Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert to Fahrenheit<br />
  return Temp;  // Return the Temperature<br />
}</p>
<p>double printDouble(double val, byte precision) {<br />
  // prints val with number of decimal places determine by precision<br />
  // precision is a number from 0 to 6 indicating the desired decimal places<br />
  // example: printDouble(3.1415, 2); // prints 3.14 (two decimal places)</p>
<p>  if( precision > 0) {</p>
<p>    unsigned long frac, mult = 1;<br />
    byte padding = precision -1;<br />
    while(precision&#8211;) mult *=10;<br />
    if(val >= 0) frac = (val &#8211; int(val)) * mult;<br />
    else frac = (int(val) &#8211; val) * mult;<br />
    unsigned long frac1 = frac;<br />
    while(frac1 /= 10) padding&#8211;;</p>
<p>    if(frac > 0.5){<br />
      val = val+1;<br />
    }<br />
    else{<br />
      val = val;<br />
    }</p>
<p>    Serial.print((int) val);<br />
  }<br />
}</p>
<p>////////////////end of temp</p>
<p>int analogInput = 0;<br />
int sensorNum = 0;</p>
<p>void setup() {<br />
  Serial.begin(115200);<br />
  // set the output pins:<br />
  for (int pinNumber = firstAddressPin; pinNumber < firstAddressPin + 4; pinNumber++) {<br />
    pinMode(pinNumber, OUTPUT);<br />
  }<br />
}</p>
<p>void loop() {</p>
<p>  // iterate once for every multiplexer (called muxes for short):<br />
  for (int mux = 0; mux < 5; mux++) {</p>
<p>    for (int channelNum = 0; channelNum < 16; channelNum ++) {<br />
      // determine the four address pin values from the channelNum:<br />
      setChannel(channelNum);</p>
<p>      // read the analog input and store it in the value array:<br />
      sensorValue[channelNum] = analogRead(analogInput+mux);</p>
<p>      if(analogInput+mux == 4&#038;&#038; channelNum == 14){<br />
        //////temp </p>
<p>        temp=sensorValue[channelNum]; </p>
<p>        temp = Thermistor(temp);      // read ADC and convert it to Celsius<br />
        //Serial.print(", Celsius: "); printDouble(temp,3);     // display Celsius</p>
<p>        temp = (temp * 9.0)/ 5.0 + 32.0;                      // converts to Fahrenheit</p>
<p>        // Serial.print("Fahrenheit: ");<br />
        printDouble(temp,3);  // display Fahrenheit<br />
        Serial.print(",");</p>
<p>      }<br />
      else{<br />
        // print the values as a single tab-separated line:<br />
        Serial.print(sensorValue[channelNum], DEC);<br />
        Serial.print(",");<br />
      }<br />
    }<br />
  }<br />
  // print a carriage return at the end of each read of the mux:<br />
  Serial.println();  </p>
<p>}</p>
<p>void setChannel(int whichChannel) {<br />
  for (int bitPosition = 0; bitPosition < 4; bitPosition++) {<br />
    // shift value x bits to the right, and mask all but bit 0:<br />
    int bitValue = (whichChannel >> bitPosition) & 1;<br />
    // set the address pins:<br />
    int pinNumber = firstAddressPin + bitPosition;<br />
    digitalWrite(pinNumber, bitValue);<br />
  }<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://beddata.com/blog/?feed=rss2&amp;p=57</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bed_Data</title>
		<link>http://beddata.com/blog/?p=24</link>
		<comments>http://beddata.com/blog/?p=24#comments</comments>
		<pubDate>Mon, 01 Mar 2010 04:27:14 +0000</pubDate>
		<dc:creator>mustafa</dc:creator>
				<category><![CDATA[instructions]]></category>

		<guid isPermaLink="false">http://beddata.com/blog/?p=24</guid>
		<description><![CDATA[Concept: Create a bedAPI to control log sleep, and have a smart house system that can adjust ambiance sleep settings.
Content: FSR matrix, camera tracking, light, temperature, and noise sensors to log bed data.
Context: Your room.
Initial thoughts: We wanted to create an under mattress sensor system to detect weight shifts during sleep without the use of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Concept: </strong>Create a bedAPI to control log sleep, and have a smart house system that can adjust ambiance sleep settings.</p>
<p><strong>Content: </strong>FSR matrix, camera tracking, light, temperature, and noise sensors to log bed data.</p>
<p><strong>Context:</strong> Your room.</p>
<p><strong>Initial thoughts: </strong>We wanted to create an under mattress sensor system to detect weight shifts during sleep without the use of a camera.</p>
<p><a href="http://beddata.com/blog/wp-content/uploads/2010/02/Bed_dataGraf.jpg"><img class="alignnone size-medium wp-image-46" title="Bed_dataGraf" src="http://beddata.com/blog/wp-content/uploads/2010/02/Bed_dataGraf-300x230.jpg" alt="" width="300" height="230" /></a></p>
<p><strong>Figure 1. Diagram of installation </strong></p>
<p><a href="http://beddata.com/blog/wp-content/uploads/2010/02/Bed_dataFlow1.jpg"><img class="alignnone size-medium wp-image-45" title="Bed_dataFlow1" src="http://beddata.com/blog/wp-content/uploads/2010/02/Bed_dataFlow1-300x230.jpg" alt="" width="300" height="230" /></a></p>
<p><strong>Figure 2. Diagram of system flow. </strong></p>
<p>If you want to build your own Bed_Data, you have to follow these are the hardware that you need:</p>
<p><em>FSR matrix (DIY) (72)</em></p>
<p><em>Camera (1)</em></p>
<p><em>Photocell (1)</em></p>
<p><em>Thermistor (1)</em></p>
<p><em>Microphone (1)</em></p>
<p><em>Arduino (1)</em></p>
<p><em>Terminals (12)</em></p>
<p><em>CD4067 (6)</em></p>
<p><em>Resistors (72)</em></p>
<p><em>Wires</em></p>
<p>We used force sensors matrix(6*12) to detect pressure on the bed. We are looking for places on the bed that you apply your force on. We are trying to understand how your bed sees you while you are sleeping.</p>
<p><img class="alignnone" title="FSR's" src="http://lh5.ggpht.com/_0tV4HXRIFeY/Sx0-i9U0D4I/AAAAAAAAAP8/ruSJC03v6ww/s720/IMG_4104.JPG" alt="" width="583" height="389" /></p>
<p><strong>Figure 3. Wires, force sensors and the bed</strong></p>
<p><img class="alignnone" title="terminals" src="http://lh3.ggpht.com/_0tV4HXRIFeY/Sx0-wrq_o4I/AAAAAAAAAQA/Cg1GbXd3nsM/s720/IMG_4109.JPG" alt="" width="583" height="389" /></p>
<p><strong>Figure 4. Force sensors</strong></p>
<p><a href="http://beddata.com/blog/wp-content/uploads/2010/02/P1030213.jpg"><img class="alignnone size-large wp-image-48" title="P1030213" src="http://beddata.com/blog/wp-content/uploads/2010/02/P1030213-1024x576.jpg" alt="" width="553" height="311" /></a></p>
<p><strong>Figure 5. Terminals, sensors, wires, Arduino, multiplexers</strong></p>
<p>We used terminals (with 8 inputs) to connect each line of sensor. Then on the other side, we used ribbon cables to connect terminals to multiplexer breadboard. Then we connected the sensor wires to CD4067 as our multiplexers. There is a good documentation by <a href="http://itp.nyu.edu/physcomp/Tutorials/Multiplexer">Tom Igoe</a>.</p>
<p><img class="alignnone" title="temp and photocell" src="http://lh3.ggpht.com/_0tV4HXRIFeY/SyZkcYUn5pI/AAAAAAAAAUA/ggyIYPkofbE/s512/IMG_4137.JPG" alt="" width="341" height="512" /></p>
<p><strong>Figure 6. Photocell and thermistor</strong></p>
<p>We add temperature and photocell to understand what is going on in the environment. These sensors are giving us temperature and amount of light in the room. We connected all of these sensors to multiplexers and multiplexers to Arduino. Then we used Arduino code from <a href="http://itp.nyu.edu/physcomp/Tutorials/Multiplexer">Tom Igoe&#8217;s multiplexer example</a> . We used 115200 boudrate for our serial communication.</p>
<p>Then we collect all the values in processing. We also add a webcam from the ceiling and used processing to get images. We mapped force sensor values on image to show force on different parts of the bed. Values from the force sensors are changing the transparency values of the rectangles (which represents force sensors).</p>
<p>We also used the microphone from the camera to get the noise level of the environment. We displayed temperature, lights values and time on the right side of the image.</p>
<p>Processing sketch kept taking snapshots from the processing application each 20 seconds. Then made a stop motion video of these images.</p>
<p><a href="http://beddata.com/blog/wp-content/uploads/2010/02/208.png"><img class="alignnone size-medium wp-image-42" title="208" src="http://beddata.com/blog/wp-content/uploads/2010/02/208-300x224.png" alt="" width="300" height="224" /></a></p>
<p><strong>Figure 7. Bed_Data interface.</strong></p>
<p>Feel free to contact us: <A HREF="mailto:info@beddata.com">info@beddata.com</A></p>
]]></content:encoded>
			<wfw:commentRss>http://beddata.com/blog/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to multiplx</title>
		<link>http://beddata.com/blog/?p=18</link>
		<comments>http://beddata.com/blog/?p=18#comments</comments>
		<pubDate>Sun, 28 Feb 2010 20:42:23 +0000</pubDate>
		<dc:creator>diegorioja</dc:creator>
				<category><![CDATA[Microcontroller]]></category>

		<guid isPermaLink="false">http://beddata.com/blog/?p=18</guid>
		<description><![CDATA[
Here is a link to the tutorial we used. Arduino + 6 multiplexers to receive data from the FSR matrix. Multiplexers expand analog inputs by 16, and by daisy chaining more multiplexers&#8230;well you do the math.

]]></description>
			<content:encoded><![CDATA[<p><a href="http://itp.nyu.edu/physcomp/Tutorials/Multiplexer"><img class="alignnone" title="Multiplex by Igoe" src="http://itp.nyu.edu/physcomp/uploads/multiplexer_schematic.jpg" alt="" width="486" height="310" /></a></p>
<p>Here is a link to the tutorial we used. Arduino + 6 multiplexers to receive data from the FSR matrix. Multiplexers expand analog inputs by 16, and by daisy chaining more multiplexers&#8230;well you do the math.<br />
<a href="http://beddata.com/blog/wp-content/uploads/2010/02/IMG_9784.jpg"><img src="http://beddata.com/blog/wp-content/uploads/2010/02/IMG_9784-300x225.jpg" alt="" title="arduino and multplxr" width="300" height="225" class="alignnone size-medium wp-image-22" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://beddata.com/blog/?feed=rss2&amp;p=18</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to FSR&#8217;s</title>
		<link>http://beddata.com/blog/?p=8</link>
		<comments>http://beddata.com/blog/?p=8#comments</comments>
		<pubDate>Mon, 21 Dec 2009 04:24:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FSRs]]></category>

		<guid isPermaLink="false">http://beddata.com/blog/?p=8</guid>
		<description><![CDATA[See how we built the force resistance sensors (FSRs) by clicking the image link below.

]]></description>
			<content:encoded><![CDATA[<p>See how we built the force resistance sensors (FSRs) by clicking the image link below.</p>
<p><a href="http://www.instructables.com/id/DIY-FSR-sandwich/"><img class="alignnone size-medium wp-image-11" title="FRS sandwich YUM!" src="http://beddata.com/blog/wp-content/uploads/2009/12/P1030220-300x168.jpg" alt="" width="300" height="168" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://beddata.com/blog/?feed=rss2&amp;p=8</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Bed_Data video</title>
		<link>http://beddata.com/blog/?p=4</link>
		<comments>http://beddata.com/blog/?p=4#comments</comments>
		<pubDate>Sun, 20 Dec 2009 18:47:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Visualization]]></category>

		<guid isPermaLink="false">http://beddata.com/blog/?p=4</guid>
		<description><![CDATA[Here are the first sleep logging visualizations we did:

]]></description>
			<content:encoded><![CDATA[<p>Here are the first sleep logging visualizations we did:</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/WvGCJnhysXo&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/WvGCJnhysXo&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://beddata.com/blog/?feed=rss2&amp;p=4</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
