tag:blogger.com,1999:blog-388933359576842322024-02-07T18:40:37.927-08:00Hardware HacksVarious hardware hacking ideas, generally related to microcontrollers (or other interesting electronic bits) and occasionally how one might use them in physics labs.Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.comBlogger35125tag:blogger.com,1999:blog-38893335957684232.post-7141622252988982642015-02-15T20:51:00.000-08:002015-02-15T20:51:41.603-08:00What this country needs is some serious competition in the Internet Service Provider market. Really! In most developed countries one can get 10Mbps for about $10/month. Here's what $36/month gets you in Chico California:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEji9zNPOS7z1DSY-q6MxJpO3MDCcPcafrDKrzOUEWk012xhi1OxGpLbI70cxVYplbT-LNM-_NLG-8tTsEuK6sUkWA-sDa-cineQhISwwRa1brAs1Efm4EN7o6e47Dx-mbEXgQnZ4LzwL38/s1600/output.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEji9zNPOS7z1DSY-q6MxJpO3MDCcPcafrDKrzOUEWk012xhi1OxGpLbI70cxVYplbT-LNM-_NLG-8tTsEuK6sUkWA-sDa-cineQhISwwRa1brAs1Efm4EN7o6e47Dx-mbEXgQnZ4LzwL38/s1600/output.png" height="300" width="400" /></a></div>
And yes, that's actual measured speed, at actual 15-minute intervals, for <i>over three and a half years</i>. Sucks, doesn't it? <br />
<br />
Oh, and before I get the inevitable "Wow, you checked internet speed every 15 minutes for three and a half years? Get a life!" comment, I should point out that I wrote a script to collect the data automatically for me and just left it running. (No, I did not click on internetspeedcheck.com 129,254 times!)<br />
<br />
This is horrible. This is 1/10 the speed one can get for half this price in South Korea. You can't <i>get</i> internet this slow in France. I suppose I could go to <a href="http://thechive.com/2014/08/26/move-over-satan-comcast-is-here-12-photos/" target="_blank">Comcast</a>, <a href="http://comcastsucksballs.blogspot.com/" target="_blank">but I'd rather</a> <a href="https://www.facebook.com/pages/COMCAST-SUCKS/351147252864" target="_blank">give myself</a> <a href="https://twitter.com/comcastsucks_" target="_blank">an appendectomy</a> <a href="http://forums.comcast.com/t5/Billing/XFINITY-SUCKS/td-p/1351991" target="_blank">with a screwdriver.</a><br />
<br />Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-50246425492791207612014-10-07T12:42:00.001-07:002014-10-07T12:46:08.507-07:00Laser-cut boxesI frequently build new physics equipment ---as I say, 2nd-best job in the world--- and if the new equipment is something that's going to be used frequently I try to build a semi-permanent version. This frequently requires some sort of electronics box.<br />
<br />
Last week we got our new <a href="http://fslaser.com/products/lasers/hobby-lasers/newhobby" target="_blank">Laser Cutter</a> working here in the College of Natural Sciences, and wow! This changes everything. Previously the process would be "order a metal box of about the right size, then cut holes in about the right places, then print labels with a labelmaker and call it good." With this laser cutter, though, the results can be pretty spectacular.<br />
<br />
I took about three hours last weekend designing the box. Most of that time was spent learning how to use the drafting program I installed on my Mac. (<a href="http://www.3ds.com/products-services/draftsight/overview/" target="_blank">DraftSight</a>, if you're curious. Seems good, and free for education use!) I could probably do the same design in about 20 minutes or less now that I know how to use the program. Here's the design:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDJxqn9GqeG0wJLkmqxc9o85Ro0DGV8HFTqedwcg8-ZtaM6YLK8qpsigkAlfW47tkDeqlEKQvXjc1cRT71mqU-YYUrhrlIO9X-tIPag4SrPlrPK4XFb76vWItCK-qySAXsEmUrTB497Dc/s1600/TSC_box.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDJxqn9GqeG0wJLkmqxc9o85Ro0DGV8HFTqedwcg8-ZtaM6YLK8qpsigkAlfW47tkDeqlEKQvXjc1cRT71mqU-YYUrhrlIO9X-tIPag4SrPlrPK4XFb76vWItCK-qySAXsEmUrTB497Dc/s1600/TSC_box.png" height="327" width="400" /></a></div>
<br />
It's designed to be cut from 1/8" acrylic sheet, and all the tabs interlock so it holds together nicely. The laser cutter software detects different colors and interprets them to mean different laser power/speed. For this one I set the red to high speed and low power, so it just marked the plastic. The black was set to high power, medium speed, so as to cut the pieces.<br />
<br />
Here's the resulting box:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgNA7lV3N96y0lEOmMo6KxbB-4TDsJxfGU9ipXyV0ub5NaaQDkRiLpddhRz3Nrx3vQU-d12kw2WEN5yxyGcIejrJ_-w46VoH6gsPfTDP7R4gWzrEF4_8i84B4aQ2cZPfJ1nWO9hqqI1Cw/s1600/TSC_box.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgNA7lV3N96y0lEOmMo6KxbB-4TDsJxfGU9ipXyV0ub5NaaQDkRiLpddhRz3Nrx3vQU-d12kw2WEN5yxyGcIejrJ_-w46VoH6gsPfTDP7R4gWzrEF4_8i84B4aQ2cZPfJ1nWO9hqqI1Cw/s1600/TSC_box.jpg" height="240" width="320" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
That doesn't have the circuitboard in it yet (a student is making it for a project) but it has the mount points for that circuitboard already. It's pretty slick! The acrylic sheet comes in different colors also, so clear is not an absolute necessity. The lettering shows up well: at high speed/low power the laser just makes a fingernail-deep "scratch" on the plastic, which is reasonably visible. To increase the visibility, I rubbed the lettering with a dry-erase marker and then rubbed the surface clean. The marker ink stayed in the lettering groves and shows up quite nicely. I held the pieces together by solvent-welding with Methyl Chloride (use a fume hood!) but superglue or model cement would also work. <br />
<br />
I need to re-think how I do this, though. For my entire career, any time I've needed to make holes for banana jacks I just drill a round 5/16" hole; so for this case, I cut a round 5/16" hole. But the banana jacks <i>aren't round!</i> They have flats on two sides so they don't twist in the hole. It's never been an option to use those flats before, since with a drill press all holes are round... But with this laser cutter I can just as easily make holes with those flats on them. Same with the BNC connectors on the front: there's a flat on the threads to keep them aligned. Now I can use that! I can even cut square holes for meters or NASA-style mil-spec switches. Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-71050160716288445342014-06-03T13:52:00.000-07:002014-06-03T13:52:11.127-07:00Programmable Servo ControllerThis is an update on my earlier <a href="http://hacks.ayars.org/2012/02/remote-key-switch-operation.html">Remote key-switch operation</a> post. These things have become rather useful around the lab! In addition to the original key-switch operation, they've been put to use running optical shutters for pump lasers, turning deposition shields inside vacuum chambers, etc. Basically, any time we have a mechanical device we want to be in one of two positions, we use a servo and this board. <br />
<br />
The only problem is the inconvenience of programming the limits on the servo. Each application has different desired positions for 'on' and 'off' logic level, and we were having to break out the AVR Programmer each time... So here's the fix. This version has user-programmable limits!<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1m5jdhl3SkS9S8ZTn0w9cYWj6T-kESVTK3MLaXnWNbe-7uyzVqceRXagtVNyxB05yfRlAu_1i83l7VlParolgy79FzqnJxJlP47DtWXnHRynYNqFprfXmRQAwrJTG9HT7U8ibDP4CDkA/s1600/Servo_controller.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1m5jdhl3SkS9S8ZTn0w9cYWj6T-kESVTK3MLaXnWNbe-7uyzVqceRXagtVNyxB05yfRlAu_1i83l7VlParolgy79FzqnJxJlP47DtWXnHRynYNqFprfXmRQAwrJTG9HT7U8ibDP4CDkA/s1600/Servo_controller.png" height="400" width="300" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
After first turning the device on, apply one logic level (low, say) then press the 'Learn' button. While holding the Learn button, adjust the servo position with the 'Adjust' potentiometer. When the servo is in the desired 'low' position, release the 'Learn' button and the ATtiny45 will store that position in EEPROM. Then apply high logic level, and use the 'Learn' button to teach the microcontroller where the servo should go for high input. Releasing the 'Learn' button stores the high position in EEPROM. From then on, even after power cycling, the device will remember where it needs to go for high and for low input. You can re-program it any time, as often as you like. (Well, up to the limit of EEPROM write cycles for the ATtiny45, which is about 10,000 or so.)</div>
<br />
The LEDs indicate power, logic state, and whether the servo is currently 'active'. That last one deserves some more explanation... Servos twitch. They jitter. They are not mechanically (or electrically) quiet. This is an annoyance sometimes, and a serious disadvantage if you need to mount the servo on an optics table. So the other feature to this device is that it turns the servo power off when it's not moving the servo. This <i>may</i> be a disadvantage if you have an application for which the holding force is not negligible, but it's acceptable for our applications. There's a switch in the code so that you can leave the servo power on continuously if you wish.<br />
<br />
Another improvement to the previous circuit is that the PWM signal on this version drives a transistor buffer which drives the servo, rather than driving the servo directly with PWM. This allows the circuit to control much larger servos reliably.<br />
<br />
It's still limited to 5V supply. The obvious next version would be to add a voltage regulator for the microcontroller, and drive the servo with whatever supply voltage you wanted... but we haven't needed that increase in servo power yet, so haven't bothered.<br />
<br />
Here are the <a href="http://physics.csuchico.edu/~eayars/code/Servo_Control.zip">EAGLE files</a> and the <a href="http://physics.csuchico.edu/~eayars/code/shutter.ino.html">ATtiny45 code</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuXMaCXGv6egrvf8NqrSbCLRLf6IHgxGrDg_219jjO9jiga8ppUz4qEiUwcUWfF8h_GzURY-pC_TAduu2SBswKQT7_sqWZJZwe7RabqJQoV79opTLKauFOspTEjel2SU63dYBRLHzPRoU/s1600/Servo_Control.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuXMaCXGv6egrvf8NqrSbCLRLf6IHgxGrDg_219jjO9jiga8ppUz4qEiUwcUWfF8h_GzURY-pC_TAduu2SBswKQT7_sqWZJZwe7RabqJQoV79opTLKauFOspTEjel2SU63dYBRLHzPRoU/s1600/Servo_Control.png" height="282" width="400" /></a></div>
<br />
<br />Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-2932829710636152952013-09-19T14:34:00.000-07:002013-09-19T14:34:10.508-07:00The "BAD DOG! NO!" alarmWe have a dog. He's a good dog, and very sweet, although a 70-pound golden retriever who thinks he's a lapdog can be a challenge.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqE7wp84ljTdYBIScwCEe5CIXF7zSZEKIkwF7RkGl00OBTq2VZ2Rjfbdq76AT8i_bsinQXkrYiU63GGftEUxK7msCyvLDdBAjYHDqOgQh4K-bGclx8hc8Bo185rToTIhfKLV1OBctQR94/s1600/shasta073.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqE7wp84ljTdYBIScwCEe5CIXF7zSZEKIkwF7RkGl00OBTq2VZ2Rjfbdq76AT8i_bsinQXkrYiU63GGftEUxK7msCyvLDdBAjYHDqOgQh4K-bGclx8hc8Bo185rToTIhfKLV1OBctQR94/s400/shasta073.jpg" width="400" /></a></div>
One of the current challenges is that he's decided that it's ok to cruise the countertop for goodies while we're off at work and school. We need some negative reinforcement...<br />
<br />
Here's just the thing. <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxpnzzzpdTBodOLIjFyhGkuHZSvDQrnFk9TiVcfIlQWQfiY9kVYzyoUL_vyegDBvtvjvTKaG81y8disJvaqEpduh13NgqET7suQQB1w3Xx19awrGEf3L_mnPcVq-JvGCbSqZf6HhSI5aY/s1600/motion-sensor.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxpnzzzpdTBodOLIjFyhGkuHZSvDQrnFk9TiVcfIlQWQfiY9kVYzyoUL_vyegDBvtvjvTKaG81y8disJvaqEpduh13NgqET7suQQB1w3Xx19awrGEf3L_mnPcVq-JvGCbSqZf6HhSI5aY/s400/motion-sensor.JPG" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: left;">
The sensor (on the left of the box) is a Passive Infrared (PIR) sensor. I do not know the origin of this particular unit, it's been rattling around my parts-bin for a few years; but similar units are about $10 at <a href="http://www.adafruit.com/products/189">Adafruit.com</a>. It puts out a logic high any time it detects motion. That PIR signal is connected to the RESET pin of a 555 timer chip, which is wired to generate a 2.5kHz square wave. The 555 output goes to the piezo buzzer on the right of the box. A switch and power-on LED complete the electronics.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Net result: loud annoying beep any time the sensor detects a dog in the area. We're now working on sensitizing the dog to the noise: every time it goes off we all yell "NO! BAD DOG!" so he starts associating that particular beep with "NO!" Next, we'll put it on the countertop, aligned so that it trips whenever he puts his nose over the edge. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Will it work? I don't know. It'll probably work better than nothing, which is what else we have.</div>
<br />
If you're curious, the box was made in Google Sketchup and printed in ABS on a Solidoodle. <a href="http://physics.csuchico.edu/~eayars/code/dog-alarm_box.skp">The box</a> holds all the parts and the circuit board, with a 9V battery to run things. I could really get used to this whole 3D printing thing: custom hardware like this is very cool.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9dJvj48gzScR0E9W32tNKeh65an_ayWlfsvK97hz8cfeXGO0tSRafqDtuXM7SVeE0Duv7VZiwRgDYYWJ2NZR8-Smq_IZ3HmrLrG4jRmUuKo8bFMGW3n2Vw8x5qnCCEtVkjzBxbHwHBUY/s1600/motion-sensor_box.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9dJvj48gzScR0E9W32tNKeh65an_ayWlfsvK97hz8cfeXGO0tSRafqDtuXM7SVeE0Duv7VZiwRgDYYWJ2NZR8-Smq_IZ3HmrLrG4jRmUuKo8bFMGW3n2Vw8x5qnCCEtVkjzBxbHwHBUY/s400/motion-sensor_box.png" width="400" /></a></div>
<br />Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-16680581474700503722013-08-30T21:34:00.001-07:002013-08-30T22:49:27.951-07:00Why should the army have all the good drones?<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK_J4BNLIeFUIt3YlN_uByhVOiTLTkm4VzitjlTufSRXwu9u5jesloxo-OfhvnEjRN6TMcMpsU9BMnIOakKanikZ-KhUGfVlEJpdxqQGLPX4K4xC4M9ixzAfCBmFeMWZD0X2m4Y5isQPM/s1600/FPVsetup.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK_J4BNLIeFUIt3YlN_uByhVOiTLTkm4VzitjlTufSRXwu9u5jesloxo-OfhvnEjRN6TMcMpsU9BMnIOakKanikZ-KhUGfVlEJpdxqQGLPX4K4xC4M9ixzAfCBmFeMWZD0X2m4Y5isQPM/s400/FPVsetup.JPG" width="400" /></a></div>
<br />
This hack is long overdue. It's been at least two years since I started thinking about how (and whether) to do it, and it's finally coming together. Earlier this month, I finally pulled the trigger on eBay and got a FatShark FPV video system.<br />
<br />
The FatShark is a combined video-receiver and video-goggles system. It includes a small video camera and 5.8GHz radio transmitter; the video plays through the goggles. The camera is mounted on a servo-controlled 2-axis gimbal, and a 2-axis gyroscopic/magnetic sensor on the goggles transmits a 433MHz signal to a receiver which controls the gimbal. Net result: A videocamera small enough to mount on an RC plane, that not only shows you the view from the cockpit but tracks your head motion and moves the camera accordingly. Control of the plane is achieved through the regular 2.4GHz RC transmitter/receiver: the FatShark video is a separate system operating on a completely different set of frequencies.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0PtbNWuFxYyNLpTn-_YXlNM2vrmFuZSUEDGvmYMS5clgsbUQPguir_ao-_AXV_R_xq13R7q3zCdz_ZtnOEuW7Wbl9CxOAHLEUKa3I3l1uFl4_90Y6eO3HhKfu606VvS6oA-aaUqeoRIQ/s1600/FPVcockpit_Sketchup.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0PtbNWuFxYyNLpTn-_YXlNM2vrmFuZSUEDGvmYMS5clgsbUQPguir_ao-_AXV_R_xq13R7q3zCdz_ZtnOEuW7Wbl9CxOAHLEUKa3I3l1uFl4_90Y6eO3HhKfu606VvS6oA-aaUqeoRIQ/s200/FPVcockpit_Sketchup.png" width="200" /></a></div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMTqdSULu9bPdiNOdkJi-NIMRZhwDkRgH4vIQ1DrnOKhV-_Br6CBDXzQcIXnkmlq2Tv45N25ZOv9UyPa2N3efUbSKLzL4v0kFG1Ukb7LFC5Axu1Imr4oYLe3K_mN8l1Z4GC1YQ66V3_4M/s1600/FPVcockpit_print.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="185" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMTqdSULu9bPdiNOdkJi-NIMRZhwDkRgH4vIQ1DrnOKhV-_Br6CBDXzQcIXnkmlq2Tv45N25ZOv9UyPa2N3efUbSKLzL4v0kFG1Ukb7LFC5Axu1Imr4oYLe3K_mN8l1Z4GC1YQ66V3_4M/s200/FPVcockpit_print.png" width="200" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH1bsOCBUv_ncBtmIfUkiFaG4hTJV4NG-SYVZ9g_nk1HeGxlkHsI0gu2y38igMF3dCbCtUVSlNlOXjwPfAUfe8C7g5Kpw0vEHuSJwzWFxqr2kSj0zMkwDGHuc_C42pt8LzxIJ5pzO05Oo/s1600/FPVcockpit_mounted.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="149" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH1bsOCBUv_ncBtmIfUkiFaG4hTJV4NG-SYVZ9g_nk1HeGxlkHsI0gu2y38igMF3dCbCtUVSlNlOXjwPfAUfe8C7g5Kpw0vEHuSJwzWFxqr2kSj0zMkwDGHuc_C42pt8LzxIJ5pzO05Oo/s200/FPVcockpit_mounted.png" width="200" /></a>I needed a good way of mounting the camera on the plane. Needed a good plane, too... well, a <a href="http://physics.csuchico.edu/~eayars/skysurfer.html">not-so-good plane</a>, actually; something slow and forgiving and not "special" in any way to either my son or myself. Most of our planes are hand-crafted balsa constructions that take a month to build and involve some emotional cost if they crash, and I figure this thing <i>will</i> crash. We have a "Sky Surfer" that someone gave us, and it fits the bill perfectly: slow, solid foam construction, underpowered (by our standards) and <i>boooring.</i> Someone gave it to us; we use it for teaching other people how to fly RC. It's an absolute pig of a plane, but I think that's probably what we need here. It's also a pusher-prop plane, so there's no obstruction of the front view.<br />
<br />
The cockpit of the plane is removable, and <a href="http://hacks.ayars.org/2013/08/3d-printing-for-lab-parts.html">I now have access to a 3D printer</a>; so I used Google Sketchup to design and print a replacement cockpit that can hold the radio gear. The cockpit just drops in where the stock cockpit came out; no modification to the plane is required. The pan servo on the video gimbal screws into the front slot on the cockpit, with clearance for wiring and for slightly larger servos as well. The angled slot at the back is designed to hold the video transmitter: the antennas are nicely exposed, and there's plenty of airflow onto the transmitter which otherwise gets quite hot. The pan/tilt receiver is stuck to the bottom of the cockpit with doublestick tape.<br />
<br />
The original cockpit is held in place by the front tab you can see on the print, and by a magnet that grips a 1-square-cm metal plate on the top-back surface of the cockpit. I designed this replacement cockpit with a recess to mount that plate, but I'm a bit leery of having things come loose in negative-g maneuvers so I strapped the cockpit down with a couple rubber bands just in case.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRtr0eJ_m_byUDUlfx080O01TND8ugou-jJl-G-0aiVO0BywBMgKpaWGdmA2paF6FrnoJrUCH-XWG7nvA0enS7E4VMuVjNXSrSHiENHzTz3qFu7Nipq_3QPDGW4WYXDYVsyeqDoK8YG8w/s1600/FPVsetup2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRtr0eJ_m_byUDUlfx080O01TND8ugou-jJl-G-0aiVO0BywBMgKpaWGdmA2paF6FrnoJrUCH-XWG7nvA0enS7E4VMuVjNXSrSHiENHzTz3qFu7Nipq_3QPDGW4WYXDYVsyeqDoK8YG8w/s400/FPVsetup2.png" width="400" /></a></div>
<br />
Now if we just had some good flying weather... Maybe tomorrow! This will be a new experience for me: I've been flying RC planes since high school, but never from "inside the plane!"<br />
<br />
Files for this project are available at <a href="http://www.thingiverse.com/thing:143317" target="_blank">Thingiverse</a>. Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-82837025813939828342013-08-04T20:23:00.000-07:002013-08-04T20:47:06.394-07:003D printing for lab parts...I reached a fascinating technological milestone this weekend. <br />
<br />
I needed some small plastic brackets to hold a sensor for a new experimental apparatus I'm building for the fall semester's Advanced Lab course. So I designed them, in 3D, on my laptop. This took about 30 minutes. When that was done, I went to my lab and printed them, which took another 30 minutes.<br />
<br />
Printed. Parts. Real parts. Physical objects. From "Light bulb!" to "Here are the custom parts you just designed" in an hour. SO COOOL!!!<br />
<br />
This is a GOOD time to be a nerd.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil79mk61TGhcc3fDNCtofim2gFr9bgSil8ZHwyEGRq23ogxbd9i_hFf8Y7EOziBmgBJu3HW25q8CxWBjdG9_x3oxjiXCwarVXQcpDkUE6sGzsLVvoEfEO926q8LaNCTfXuj84MEg3Vy9A/s1600/thermometer_brackets.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="247" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil79mk61TGhcc3fDNCtofim2gFr9bgSil8ZHwyEGRq23ogxbd9i_hFf8Y7EOziBmgBJu3HW25q8CxWBjdG9_x3oxjiXCwarVXQcpDkUE6sGzsLVvoEfEO926q8LaNCTfXuj84MEg3Vy9A/s320/thermometer_brackets.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil2mlqx_y4VF_IMOSMAnEgd3-6KJPcJDqy-2hyphenhyphenSFRdsvaeXzfhQDY2qwkyLuCoCxG3gAhyphenhyphenzsGzk6zgCjO_AsDnC8n0MuC9W5qtCmZvXJ0HhzSpi4QrH2vFAQGUrb_KikGLque4RDNK67o/s1600/thermometer_brackets_printed.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="279" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil2mlqx_y4VF_IMOSMAnEgd3-6KJPcJDqy-2hyphenhyphenSFRdsvaeXzfhQDY2qwkyLuCoCxG3gAhyphenhyphenzsGzk6zgCjO_AsDnC8n0MuC9W5qtCmZvXJ0HhzSpi4QrH2vFAQGUrb_KikGLque4RDNK67o/s320/thermometer_brackets_printed.png" width="320" /> </a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Technical details: parts designed in Google Sketchup, printed in ABS on a Solidoodle 2. This blog post should in no way be construed as an endorsement of Solidoodle, where the company policy appears to be to ship replacement parts on a schedule that would make glaciers wonder about the hold-up, and whose printer is currently printing using a jury-rigged extruder heater element that would make MacGyver shudder.</div>
Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-50534720141509555882013-06-01T13:15:00.000-07:002013-06-01T13:15:51.054-07:00Radioactive isotope decay simulation<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihjreUxPgu3uvLpIyiozznbd96KQ3wnf-_RgXKVKirJ-ncaLmKLFj6ICSQ50rUTT6fGzniG5-uIp1BayjeWIPStaOvphy4EYyF44drG9o2eRS2eCiGcxGcXgpXOWulJVEuorK4p71zB6w/s1600/arduino-decay.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="301" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihjreUxPgu3uvLpIyiozznbd96KQ3wnf-_RgXKVKirJ-ncaLmKLFj6ICSQ50rUTT6fGzniG5-uIp1BayjeWIPStaOvphy4EYyF44drG9o2eRS2eCiGcxGcXgpXOWulJVEuorK4p71zB6w/s400/arduino-decay.png" width="400" /></a><br />
<br />
My students need to learn LabVIEW —I know, it's proprietary software, and expensive, but until a viable open-source equivalent comes along we're stuck with it— and one of the exercises I have them do is to make a program to analyze radioactive decay. This gives them experience in using counters, plotting data in real time, curve fitting, etc.<br />
<br />
The problem arises when I have a dozen students and not so many good sources and detectors. During the students' development of their LabVIEW program, they need multiple re-starts on the measurement. The program NEVER works right the first time, and if you're using neutron-activated indium as a source it's hard to "reset" it when you realize that your block diagram isn't wired right.<br />
<br />
I have a dozen Arduinos, though, and I've programmed them to behave as if they were radioactive sources. This way the students can try their program, fix their program, push the reset button on the Arduino and try the program again.<br />
<br />
<a href="http://physics.csuchico.edu/~eayars/code/radsim.ino.html">Here's the code</a>. I use pin 13 as an output since the LED allows students to see that it's working, even when their program isn't. The plot shown at the top of this page is actual data from the Arduino, as collected via a student LabVIEW program and plotted in Python. There's a step in the data at about 80 seconds —not sure if that's the Arduino or LabVIEW— but it works well enough for the job.<br />
<br />
Once the students are confident that their program works, then I bring out the real sources: neutron-activated indium, neutron-activated silver, and a "cesium-barium cow".Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-28546168631790358192013-05-12T21:41:00.000-07:002013-12-02T20:16:19.936-08:00"Ayrduino" Single-Sided Arduino Clone<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBro4zD32K6c6Ivt5bInsMlfMJgIbOo1X6__enJWCf0OgRMiv53zf8aScFboCDW_OkVKfUTDDfpNSv_-Pub1je2VZAcY79DKzP1J3Smka-SE_J1z65iP8tSEaZeBLBZPSbBnVt8Xfyhdo/s1600/Ayrduino_v2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBro4zD32K6c6Ivt5bInsMlfMJgIbOo1X6__enJWCf0OgRMiv53zf8aScFboCDW_OkVKfUTDDfpNSv_-Pub1je2VZAcY79DKzP1J3Smka-SE_J1z65iP8tSEaZeBLBZPSbBnVt8Xfyhdo/s320/Ayrduino_v2.png" width="320" /></a></div>
<br />
I'm teaching "Electronics for Scientists" this semester, and I wanted to allow each student to have their own Arduino to play with for microcontroller lab exercises and possibly use for their final projects. The Arduino is not very expensive at roughly $30 per, but they add up quickly when you have a whole class of students needing one each. I'd been buying enough electronics equipment over the course of the semester that my department chair was showing an involuntary tic any time I knocked on his office door... So I built my own. They are a stripped-down variant of the Duemilanove.<br />
<br />
Hoo-ah:<br />
<ul>
<li>Standard Arduino form-factor and mount-points.</li>
<li>Accepts standard Arduino shields.</li>
<li>Single-sided board, easy to make with toner-transfer method. </li>
<li>16MHz ATmega328. </li>
<li>No SMT parts.</li>
<li>On-board 5V regulation.</li>
<li>Screw-terminal power-in connector, rather than barrel jack.</li>
<li>Pin-13 LED.</li>
</ul>
Meh:<br />
<ul>
<li>Lacks on-board USB-Serial conversion, so programming requires an FTDI cable.</li>
<li>No 3.3V regulator.</li>
<li>This is as detailed a board as I <i>ever</i> want to make using toner-transfer. </li>
<li>No TX/RX LEDs. </li>
<li>No ISP connector.</li>
<li>Three component-side jumpers. Couldn't <i>quite</i> get all traces on the back side!</li>
</ul>
None of these down-sides are significant for this application. The requirement of FTDI cable is inconvenient, sometimes, but I have 3-4 of them in the lab and students share them without too much squabbling.<br />
<br />
My grader, Lena, did most of the drilling and soldering work. She's graduating next week, and I'll miss her, but the graduate program in Nuclear Engineering at University of New Mexico is going to be thrilled.<br />
<br />
If you want to make your own single-sided Arduino variant, and this set of pros/cons is acceptable to you, <a href="http://physics.csuchico.edu/~eayars/code/Ayrduino.zip" target="_blank">here are the EAGLE files</a>. One of the smart-asses in the electronics class immediately dubbed it the "Ayrduino"...<br />
<br />
Note: the Arduino design, on which this is based, is licensed under the <a href="http://creativecommons.org/licenses/by-sa/2.5/">Creative Commons Attribution-ShareAlike 2.5</a> license; so this is available under that same license as well.<br />
<br />
Parts list:<br />
<ul>
<li>ATmega328P-PU (1)</li>
<li>16MHz crystal (1)</li>
<li>22 pF cap, ceramic (2)</li>
<li>Button, momentary tactile switch (1)</li>
<li>Angled header, 6-pin male (1) </li>
<li>0.1µF cap, ceramic (5)</li>
<li>Red LED (1)</li>
<li>Green LED (1)</li>
<li>1N4001 diode (1)</li>
<li>2-position screw terminal (1)</li>
<li>7805 regulator (1)</li>
<li>10kΩ resistor (1)</li>
<li>510Ω resistor (2)</li>
<li>47µF Al. Elect. cap (2) (short ones to fit under shield boards)</li>
<li>Female headers, 8-pin (2) (optional)</li>
<li>Female headers, 6-pin (2) (optional)</li>
<li>28-pin IC socket (1) OR 14-pin IC socket (2) (optional)</li>
<li>Three short jumper wires</li>
<li>Single-sided PC board, 0.032" 1/2oz Cu. </li>
</ul>
You can cut 11 of these from one 8x10 sheet of PC board if you do it just right.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4cL2W7-S3kPfWmiL65rJ9vOrFLpg6Fi7cTgNdpvUcdGIp3Tq4BuTC_lx9qAv8Rk5etoFx43r6gcAhWxErR4MlQTD0p8EOfgKnJvIgNgdurznW0DDw1_UL8LUjHHbuVqcF_CxzWSyD6-s/s1600/arduino.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4cL2W7-S3kPfWmiL65rJ9vOrFLpg6Fi7cTgNdpvUcdGIp3Tq4BuTC_lx9qAv8Rk5etoFx43r6gcAhWxErR4MlQTD0p8EOfgKnJvIgNgdurznW0DDw1_UL8LUjHHbuVqcF_CxzWSyD6-s/s320/arduino.JPG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1iTynI2O9EkDAD5e-xI20alYjAXrWe9nZkRqlSFYEUkly2SbZn0VpGd_zi3BubDc-Ntzb4LGx-k8jLIeiU7CBpAJe-xf1gRpbfrLuyk6xgNosZlDv5kCO0-lzhTERoFCkURuGD5UglA/s1600/arduini.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1iTynI2O9EkDAD5e-xI20alYjAXrWe9nZkRqlSFYEUkly2SbZn0VpGd_zi3BubDc-Ntzb4LGx-k8jLIeiU7CBpAJe-xf1gRpbfrLuyk6xgNosZlDv5kCO0-lzhTERoFCkURuGD5UglA/s320/arduini.JPG" width="320" /></a></div>
<br />Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com9tag:blogger.com,1999:blog-38893335957684232.post-28812593937588110522013-04-30T13:44:00.001-07:002013-04-30T13:46:29.580-07:00Minecraft Ore-Block night-light<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii2QJZ3OJaslguZwQgUeC0HZRQqfhgl1WvE8mhbDSUa68KbVekCAElo931xtKiVrz4WVL_rZj-kBl6nctbqbia8jho7PSSHSRCPBUO9xDc7Zagw43xHURJLwBs_2SYdgfPJLn16_Lm7i8/s1600/redstone.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii2QJZ3OJaslguZwQgUeC0HZRQqfhgl1WvE8mhbDSUa68KbVekCAElo931xtKiVrz4WVL_rZj-kBl6nctbqbia8jho7PSSHSRCPBUO9xDc7Zagw43xHURJLwBs_2SYdgfPJLn16_Lm7i8/s400/redstone.JPG" width="400" /></a></div>
You can <a href="http://www.thinkgeek.com/product/eea7/?srp=1" target="_blank">buy a minecraft ore-block night-light</a>... but it's more fun to make your own, and this one is not just redstone. It cycles through the colors of redstone, emerald, lapis lazuli, iron, gold, and diamond. It also pulses slowly; just a subtle fading in and out. My son and my nephew both had birthdays this month; although they're past the age of needing nightlights they're both minecraft nuts so I decided to make these for them. <br />
<br />
Let's start with the light. For the light source, I used a <a href="http://www.adafruit.com/products/848" target="_blank">10mm RGB LED from Adafruit</a>. This common-anode RGB LED provides a nice bright color-space, and the diffused package mixes the light well. I first wrote a quick Arduino program to read three potentiometers and adjust the red, green, and blue levels according to those pots. The program would then send the actual RGB values back to the computer via the serial line. This allowed me to experiment with different light mixes in an effort to find the best RGB combination for each color. I could tweak each knob, see the results immediately, and when I found a combination I liked I could check the serial line to see what it was.<br />
<br />
<a href="http://physics.csuchico.edu/~eayars/code/colordial.ino.html">Here's the program</a>, and here's what the test-rig looked like:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidcE78XUIPaOZNoOb5idAYurgcVv2CjbxamOhs0GMXmnlkg4hree1s8gFUBQuUiOdPFQGmoJIDA49l8u7yyGuVhekeoSlGJ7a96dCkcGjxBrTQsXD2o4-M8L2vxYbJGJX7QWEw3Xil4Bs/s1600/color-finder.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="335" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidcE78XUIPaOZNoOb5idAYurgcVv2CjbxamOhs0GMXmnlkg4hree1s8gFUBQuUiOdPFQGmoJIDA49l8u7yyGuVhekeoSlGJ7a96dCkcGjxBrTQsXD2o4-M8L2vxYbJGJX7QWEw3Xil4Bs/s400/color-finder.png" width="400" /></a></div>
<br />
I eventually decided on these tuples for each type of ore:<br />
Redstone (255,0,0)<br />
Emerald (0,255,0)<br />
Lapis Lazuli (0,0,255) --- those three are easy!<br />
Iron (16,4,0) --- closest I could get to "brown" with the RGB!<br />
Gold (255,115,0) --- maybe a bit less green?<br />
Diamond (0,255,100) --- could've gone more blue, but this works.<br />
<br />
These colors are hard-coded into the program, which was downloaded onto the microprocessor before soldering the microprocessor into the board. <a href="http://physics.csuchico.edu/~eayars/code/oreblock.ino.html" target="_blank">Here's the program</a>.<br />
<br />
Next, the electronics: I chose to use an <a href="http://www.mouser.com/ProductDetail/Atmel/ATTINY84-20PU/?qs=sGAEpiMZZMv256HIxPBQcJsmw879xCtO" target="_blank">ATtiny84 microprocessor</a> to drive the light. The ATtiny84 has much more memory than necessary for this purpose, but I needed three separate PWM outputs to do the color mixing (so the ATtiny45 was out) and I didn't have any ATtiny44's handy. The board layout was fairly simple: I used EAGLE CAD, and here's the design:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYTxIEn7JuidtNH-jocvwve9O-P6jOCQosh48h6wmWaJ6bboVbCDm2sKFH8lCRWkIXUmQy8SCHEhad7it2lJQ901Lz_BL7AD9nRD21iXtwfXNF7G_ShBlNexZY8-yHp16-hwWIpCsOjAU/s1600/oreblock_sch.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="186" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYTxIEn7JuidtNH-jocvwve9O-P6jOCQosh48h6wmWaJ6bboVbCDm2sKFH8lCRWkIXUmQy8SCHEhad7it2lJQ901Lz_BL7AD9nRD21iXtwfXNF7G_ShBlNexZY8-yHp16-hwWIpCsOjAU/s400/oreblock_sch.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC1tP6marR3Nhtcrk0N7BeyD6qQNonLX09BZmWbkY_EO0dsCGkj2Fd2HEF2hzJmdGW1lh6lkObavjvCq0_y5NaayHRi-0PfmyYqfuQpbGdlRycUPeC9D9MUNG-yOgBcW3n0PEXRlvBL0w/s1600/oreblock_brd.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC1tP6marR3Nhtcrk0N7BeyD6qQNonLX09BZmWbkY_EO0dsCGkj2Fd2HEF2hzJmdGW1lh6lkObavjvCq0_y5NaayHRi-0PfmyYqfuQpbGdlRycUPeC9D9MUNG-yOgBcW3n0PEXRlvBL0w/s320/oreblock_brd.png" width="320" /></a></div>
<br />
The <a href="http://physics.csuchico.edu/~eayars/code/orelamp.zip" target="_blank">EAGLE files are available here</a>. I created the board using toner-transfer and FeCl etching.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqKvq9wRGVHCtjOucP_Fv2doJ36AjNyOyPAodazYbimsmqW8NdttqbPTJcqNumTOVtbzBoyUcubOB2qijfrAdnQTunsOgJypWx28fydoVpg7WbqBdcZepBOxBofQv08-KI5vtj-XLd47o/s1600/Circuitboard.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="297" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqKvq9wRGVHCtjOucP_Fv2doJ36AjNyOyPAodazYbimsmqW8NdttqbPTJcqNumTOVtbzBoyUcubOB2qijfrAdnQTunsOgJypWx28fydoVpg7WbqBdcZepBOxBofQv08-KI5vtj-XLd47o/s400/Circuitboard.JPG" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Dt2GlA0aAsDg6M8jOLHems4zkDFBJnDfmClmEKDuFlLqjEzjE78b-mXPLQoNlw7O8I-FGgX9IcoZIB5q21q78ib5qFrvcaxkMefJyX6O-ANF_0CXx4mjNhz-GSLyP7ZrZvALLGngl1Y/s1600/Circuitboard-top.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="297" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Dt2GlA0aAsDg6M8jOLHems4zkDFBJnDfmClmEKDuFlLqjEzjE78b-mXPLQoNlw7O8I-FGgX9IcoZIB5q21q78ib5qFrvcaxkMefJyX6O-ANF_0CXx4mjNhz-GSLyP7ZrZvALLGngl1Y/s400/Circuitboard-top.JPG" width="400" /></a></div>
<br />
Next, it was time to make the physical ore-block. I used 1/4" clear acrylic, cut on my table saw. The sides are each 3" high by 2 7/8" wide, and the top is 2 3/4 x2 3/4. I then used a router table to cut a 1/8x1/8" shoulder-groove around each piece.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPDPZXy4qf6F30Wafn81qjkh7yxofc5qUIs76rJCUXqTnrZyLqtCjDxfBc5X2mTeQ-9CRk7Km2i0TkYnoT4medHrLhHicTdgoxdyI4ZbZtsH-DAZltKFCwxRZ1RBIoepq6veKqKVkndyk/s1600/clear.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPDPZXy4qf6F30Wafn81qjkh7yxofc5qUIs76rJCUXqTnrZyLqtCjDxfBc5X2mTeQ-9CRk7Km2i0TkYnoT4medHrLhHicTdgoxdyI4ZbZtsH-DAZltKFCwxRZ1RBIoepq6veKqKVkndyk/s400/clear.JPG" width="400" /></a> </div>
The side pieces then fit together, each overlapping the next. The top fit perfectly inside the recessed square formed by the sides. The bottom was left open for the moment, but if you're following along on visualizing how this goes together, you'll realize that there is a 2 3/4x2 3/4" recessed square hole there, too --- just the right size for the circuitboard.<br />
<br />
Before gluing the pieces together, I sandblasted them ---both sides--- to make them better diffusers.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGu5Ttpf7PRUlfsidEFWtoElQoRWfEZnk6nV5x7AP-Oi3C117ODsaXwBn-Poys4B9KkYzKhR0x5TrDaK5rT13xDAitOGZNYIRZ3VGU4xz0qIqGO6sHnmaqgZ0zNf1Peg8m_SSiopwaKOs/s1600/frosted.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGu5Ttpf7PRUlfsidEFWtoElQoRWfEZnk6nV5x7AP-Oi3C117ODsaXwBn-Poys4B9KkYzKhR0x5TrDaK5rT13xDAitOGZNYIRZ3VGU4xz0qIqGO6sHnmaqgZ0zNf1Peg8m_SSiopwaKOs/s400/frosted.JPG" width="400" /></a></div>
I then solvent-welded them together using methylene chloride. Plastic model glue would have worked nearly as well, but I work in a building with chemistry labs and fume hoods and solvent-welding acrylic works REALLY well. When finished, I had a nice translucent 3" cube of frosted acrylic, open on the bottom. I also drilled three holes near the bottom of one side of the block; holes that would later accommodate the buttons and power cord.<br />
<br />
The outside pattern is key to making this a Minecraft block, of course! I created a single 3x3" side using a vector graphics program, then put five sides together so I could wrap them around the cube. The largest-format laser printer I have available will only print letter-sized paper, so I had to break the wrap into two pieces, like this:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYHBEvBu1xrik7IxrKLBQFRp5gfz75guTGZ8DWl3N0yqbR-gn4ZI9pfPMs0FjAjhrcsu7MQk05A6Rm0sMM_mvgiTupytppP-Av31sYRk9iCHqOgY98sUailTTnyv1VnJxdRKPJ-LgzgLE/s1600/ore-block.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYHBEvBu1xrik7IxrKLBQFRp5gfz75guTGZ8DWl3N0yqbR-gn4ZI9pfPMs0FjAjhrcsu7MQk05A6Rm0sMM_mvgiTupytppP-Av31sYRk9iCHqOgY98sUailTTnyv1VnJxdRKPJ-LgzgLE/s400/ore-block.png" width="400" /></a></div>
The top piece wraps around three sides of the block, and the bottom folds over the top and fourth side. The extra on the sides wrap around to prevent light leakage around the edges. <a href="http://physics.csuchico.edu/~eayars/code/ore-block.pdf" target="_blank">Here's a link to a .pdf of that design</a>, should you want to make your own block.<br />
<br />
To make the "stone" parts of the lamp light-proof I used 3M spray adhesive ("Super 77") to glue a print of this pattern onto a smooth piece of aluminum foil. Next, I carefully cut the pattern out using a sharp new X-Acto blade and a metal straightedge.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidCjox9MsBzANs5Wz3TJenC1P2GQs14QnQhyrvSORPnxfu_g3RiIoXErXDr6gTkimAmdlY5oiig7meHTcApGLlVm4Ih0_xzZ8oILkfujkZT_Jqw6DWHOipsQccuKA3JfIrv4WUWlI4s3w/s1600/Cover.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidCjox9MsBzANs5Wz3TJenC1P2GQs14QnQhyrvSORPnxfu_g3RiIoXErXDr6gTkimAmdlY5oiig7meHTcApGLlVm4Ih0_xzZ8oILkfujkZT_Jqw6DWHOipsQccuKA3JfIrv4WUWlI4s3w/s400/Cover.JPG" width="400" /></a></div>
I then carefully creased this aluminum-foil/paper label on all fold lines, using the metal straightedge again. I sprayed the aluminum side with adhesive once more, and wrapped the label around the block.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZbksTdCihYJ69efAmSSjFo9ZKRbf-Mt-t3cVi7eOXoZgcTK5RT3pIWZsuFgRt7Ccgtr6Lag_GkeokIFn9qLOARcwGitF7p3X5xRVzAt2dcDaheCSa2jkEI20lHP6Naql0F_hRQbuA8C0/s1600/Assembly.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZbksTdCihYJ69efAmSSjFo9ZKRbf-Mt-t3cVi7eOXoZgcTK5RT3pIWZsuFgRt7Ccgtr6Lag_GkeokIFn9qLOARcwGitF7p3X5xRVzAt2dcDaheCSa2jkEI20lHP6Naql0F_hRQbuA8C0/s400/Assembly.JPG" width="400" /></a></div>
The final assembly step was to provide a power source (salvaged 5V phone charger) and solder the power cord and buttons. I found two buttons that were nearly identical; one was momentary and the other latched. The latched button is used for power, the momentary button cycles through ore-type. The circuitboard fit (with a small amount of sanding) into the recess on the bottom of the cube: I glued it into place with RTV and added four stick-on rubber feet.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5CxpJ2FKLDQHOyUm5gB85HqXiE07TvqoEHhXL1JSfAyinwwEH_dwAnvCNGXIdQKBYktjgS6wW_fccVAJWw4msrGiAiMxanAxojFGUY2Ci40loA_Zf-X7isonyWF2Fit-DvnRbSqbTAN4/s1600/Overall.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5CxpJ2FKLDQHOyUm5gB85HqXiE07TvqoEHhXL1JSfAyinwwEH_dwAnvCNGXIdQKBYktjgS6wW_fccVAJWw4msrGiAiMxanAxojFGUY2Ci40loA_Zf-X7isonyWF2Fit-DvnRbSqbTAN4/s400/Overall.JPG" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQBKpsxEy8eVvZ5jHst5EVKYzpbn6m7UTbv0XtTJZPwv-szZFfKbafuqUsxSLcSExAJuGtDhP6lmseAlEGd6TyqSR59k4IrVkmusHnbXG6amuikD0rUqvWQrvhYT5B2AYACuPet6-smco/s1600/Diamond.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQBKpsxEy8eVvZ5jHst5EVKYzpbn6m7UTbv0XtTJZPwv-szZFfKbafuqUsxSLcSExAJuGtDhP6lmseAlEGd6TyqSR59k4IrVkmusHnbXG6amuikD0rUqvWQrvhYT5B2AYACuPet6-smco/s400/Diamond.JPG" width="400" /></a></div>
It works great, the boys think they are cool, and it's on to the next project: writing a final exam for my electronics course!<br />
<br />Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-11229054763133164212013-04-08T21:40:00.000-07:002013-04-08T21:46:18.072-07:00ISP Clip for ATtiny44/84 (or others!)I got my start in microcontrollers with the Arduino, as many of us outside of electrical engineering did. (And still do!) The ease of programming that little board makes it a great gateway... and like any gateway, sometimes you go through.<br />
<br />
Most of my projects now don't use Arduinos directly. For simple microcontroller applications, it's much more cost-effective to use a bare microcontroller selected for the memory size and pin-count you need to do the job. For me, that usually means either the 8-pin ATtiny45/85 or the 14-pin ATtiny44/84. Both can now be programmed directly using the Arduino IDE with either a commercial programmer or with an Arduino, as described on the excellent <a href="http://hlt.media.mit.edu/?p=1706">MIT High-Low Tech site</a>.<br />
<br />
One frustration with these smaller microprocessors, though, is that I either had to take them out of the circuit and wire up a breadboard as shown at MIT's site, or build a 6-pin ISP connector into my project. I built a 6-pin ISP-to-breadboard adapter assembly, which often helped during the prototyping process, but it was not ideal. What I really wanted was something that would clip directly to the chip and let me reprogram it without removing it from the breadboard or circuit.<br />
<br />
It turns out the solution had been sitting in my toolbox for the last 15 years, I just didn't know it! Years ago, someone gave me a set of "DIP clips": they're a spring-loaded clip made by 3M that grabs a DIP chip from the top and provides easy contact points to each pin. They're still sold <a href="http://www.digikey.com/scripts/dksearch/dksus.dll?FV=fff40023%2Cfff80402&k=IC+test+clip&vendor=0&mnonly=0&newproducts=0&ptm=0&fid=0&quantity=0&PV-1=19&PV183=5523&stock=1">here</a> and elsewhere. I glued a 6-pin ISP header on the side of one of these with wires from the ISP header to the appropriate pins on the clip, and voila! A ISP clip.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggzUnNoPutF4NhUbGDXs-SpGRxz2Xev1tN18fwt-71z-uRS1eSJ3bzil9DBdWio_RDiMkaCh9_A2PmaQi6aNt4Na8QrB9IbDyPyjVZyXEcEm5K3W-AoAeXQ_AOtUspKTeoOBNqHYh_-hg/s1600/ATtiny84+ISP-clip.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggzUnNoPutF4NhUbGDXs-SpGRxz2Xev1tN18fwt-71z-uRS1eSJ3bzil9DBdWio_RDiMkaCh9_A2PmaQi6aNt4Na8QrB9IbDyPyjVZyXEcEm5K3W-AoAeXQ_AOtUspKTeoOBNqHYh_-hg/s400/ATtiny84+ISP-clip.jpg" width="400" /></a></div>
This one is for the ATtiny84 (or 44): I just plug my ISP programmer to the clip and put the clip on the ATtiny84: I can then test and debug the microcontroller while it's in the circuit —even if it's soldered into the circuit— without having to build an ISP header in the circuit. There's another 8-pin clip that does the same for me with the ATtiny85 (or 45).<br />
<br />
New idea? No... Pretty? No... But it works nicely.<br />
<br />Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-21952261599278493272013-03-10T14:01:00.000-07:002013-03-10T14:19:15.239-07:00Random training interval timerIn addition to various things I'm supposed to do, I race triathlons. One of the training tools we use is the interval workout, in which we alternate high- and low-intensity time intervals during the course of a run or bike workout. There's been a bit of discussion during the Monday-Night run recently about whether it might be advantageous to train with randomized intervals instead of with set intervals.<br />
<br />
A typical running interval workout might be a 20min warmup, 5 sets of 1min hard 3min recovery, then 20min cooldown. The idea is to replace the main set with 20 minutes of random intervals, during which the hard and recovery intervals vary randomly in length (within reasonable parameters, of course.) <br />
<br />
Typical sports-watches have an interval feature that helps time regular intervals, but they don't do random intervals. Here's my solution: use an ATtiny45 to generate the random intervals, and indicate the intervals via a flashing LED.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfFChBR7AkJdhMeqtjmMf07Q2JrzP-N45K_oZTRiWaM-gyknKdjqL4IWh7egucSnYoe4xweA3FBsy5h1G2ykXqVl8TbsUuOo2eEySctS63p2w2vIGFxzLSjTSB1kRH5M85d44SaQnsnFA/s1600/intervalometer.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfFChBR7AkJdhMeqtjmMf07Q2JrzP-N45K_oZTRiWaM-gyknKdjqL4IWh7egucSnYoe4xweA3FBsy5h1G2ykXqVl8TbsUuOo2eEySctS63p2w2vIGFxzLSjTSB1kRH5M85d44SaQnsnFA/s320/intervalometer.jpg" width="320" /></a></div>
<br />
And <a href="http://physics.csuchico.edu/~eayars/code/intervalometer.pde.html">here's the code</a>.<br />
<br />
Programming of the ATtiny45 was done via the Arduino IDE: the fuses on the ATtiny45 are set to use the 1MHz internal oscillator. The circuit itself is simply power and ground to the chip (using a 1225 lithium battery) and an LED with current-limiting resistor on PB0 of the microcontroller.Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-18471983696751804082012-06-18T10:37:00.000-07:002012-12-14T13:16:11.625-08:00Quantitative Two-Dimensional Temperature MeasurementsLab Experiments involving the Heat Equation are usually one-dimensional exercises involving a copper pipe and a half-dozen thermocouples. But with DS18B20 "One-Wire" thermometer chips and an Arduino, it's possible to measure <i>hundreds</i> of temperature values simultaneously. Here's what my students Daniel Lund and Lawrence Lechuga and I came up with for 2-D temperature measurements.<br />
<br />
We began by laying out a 10x10 grid of sensor locations on a 30cm-square plate of 5mm-thick aluminum. We laid Kapton tape in strips under where the sensor leads would be located, to prevent the leads from shorting against the aluminum plate; then we glued each sensor to the plate using thermal epoxy.<br />
<br />
Next, we temporarily attached each sensor to an Arduino microcontroller running <a href="http://physics.csuchico.edu/%7Eeayars/code/FindAddress.ino.html">FindAddress.ino</a>. This program first determines how many devices are on One-Wire bus; then for each device, it sends the address of that device to the Arduino serial port. A terminal emulator on the attached computer displays those addresses. By running this program with the sensors attached individually, we could then determine the hard-coded addresses of each sensor. One hundred tests later, we had a complete list of sensor addresses, ordered by their physical position on the grid.<br />
<br />
Once we knew the individual addresses and corresponding locations of the sensors, we permanently wired all the sensors to the Arduino. Power and ground are provided by the USB connection to the computer, and the data pins for each sensor are all connected via a single wire to one input pin of the Arduino. The data bus is also connected to power via a 1k pull-up resistor. (Note: the datasheet for the DS18B20 calls for a 4.7k pull-up resistor, but we found that with 100 sensors on a single bus a 1k pull-up resistor provided more reliable operation.) The Arduino itself is connected to the computer via a “FTDI Friend” USB-serial converter board.<br />
<br />
The completed hardware (bottom side) can be seen below. The plastic stand-offs allow it to be placed flat on a table with the bare top side up.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNs510pmmwZ1wgDidUlaHkHouMN01ZOYDiA2tEsdwqqXY5YZb1GL3k7oqb5hm0K7O9d3u21jH1xuohGIRKzaKFJa8RvFDb1bR_5txb9IsrANr9jKXGvMx7t6flUIhhIe_M1yvb8MBJNU4/s1600/Thermal_Plate002.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNs510pmmwZ1wgDidUlaHkHouMN01ZOYDiA2tEsdwqqXY5YZb1GL3k7oqb5hm0K7O9d3u21jH1xuohGIRKzaKFJa8RvFDb1bR_5txb9IsrANr9jKXGvMx7t6flUIhhIe_M1yvb8MBJNU4/s400/Thermal_Plate002.jpg" width="400" /></a></div>
<br />
The final step in construction is to program the Arduino to measure the temperatures and send those temperatures (in order of grid position) to the computer. With this many sensors we found that we were straining the capacity of the microcontroller: although the ATmega328 chip on the Arduino board has 32k of program space, it has only 2k of RAM. This RAM is used by the serial and One-Wire communications libraries as well as by our program, and when the RAM is full the Arduino behaves erratically. Our solution was to store the array of sensor addresses in the 1k array of EEPROM on the microcontroller. This required a second Arduino program (<a href="http://physics.csuchico.edu/%7Eeayars/code/address_storage.ino.html">address_storage.ino</a>) which was run once to store the sensor address array in EEPROM. Once that program did its job, we uploaded our final program, <a href="http://physics.csuchico.edu/%7Eeayars/code/ThermoPlate.ino.html">ThermoPlate.ino</a>.<br />
<br />
The ThermoPlate.ino program operates in two steps after the initialization procedures: first, it sends out a “broadcast” message on the One-Wire bus telling all sensors to record the current temperature. Next, it goes through all the sensor addresses stored in EEPROM. For each address it sends a temperature inquiry to that address, converts the sensor response to °C, and sends the temperature as text down the serial line to the computer. When the Arduino has gotten the temperature from each sensor it sends an EOL character to the serial port, then repeats the process. That’s the final output of the device: line after line of serial data, each line containing 100 temperatures in left-to-right, top-to-bottom order. With our 16-MHz Arduino, it takes just under 2 seconds to measure all points, with the limiting factor being the speed of the One-Wire bus itself.<br />
<br />
The computer has to be able to listen to the apparatus and make sense of
the incoming data. Since the incoming data is simply text, there is a
wide range of possible tools to use for this purpose, ranging from
LabVIEW to IDL to C++. For simplicity, we chose to write our program, <a href="http://physics.csuchico.edu/%7Eeayars/code/TempMovie_py.html">TempMovie.py</a>,
in Python. This program captures each line of data coming in the serial
port, splits the line into individual temperatures, rearranges those
temperatures into a grid, and then draws a filled contour plot based on
that grid data. One can set the temperature scale in the program to
cover the expected range of values, and if desired the program will save
the raw data for later analysis. The figure below shows a single frame
of output of TempMovie.py when a small bag of ice was placed at the
upper right and a hot soldering iron was placed near the center. <br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLJhbrrDcRzA-c3zVDmPa-5u0MeBSKatgnF3s07LmsFSdPtoz9gIsrS0q0rfG16f_38m_zDAeTRw91u05QLns3joBayMtdTZECSuk3PZvX0EmhQkChrELelS4wRjmOSOt7l8Mavnr4Sis/s1600/SolderIron-IceBag0025.5.35.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLJhbrrDcRzA-c3zVDmPa-5u0MeBSKatgnF3s07LmsFSdPtoz9gIsrS0q0rfG16f_38m_zDAeTRw91u05QLns3joBayMtdTZECSuk3PZvX0EmhQkChrELelS4wRjmOSOt7l8Mavnr4Sis/s400/SolderIron-IceBag0025.5.35.png" width="400" /></a></div>
The image changes as the plate moves towards its new equilibrium state, and one can observe the heat flow in real time. For the sequence of images shown below, the plate was hit with a flame from a propane torch, which was removed after a few seconds. (Time in the video below is sped up by a factor of 4.) Time-dependent thermal data such as this can be compared to numeric solutions of the Heat Equation.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dxvG9lWI9L5jTGLwfcaj7Trlh3l9Om9NyoQBl347ghBlagm0bApj7LQxLVbR7mXF4dtlw4MkjqbpCDpRHcT' class='b-hbp-video b-uploaded' frameborder='0'></iframe> </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Note: These temperature sensors can detect changes as small as 0.1°C. If you look closely at all of these images, you can see that an area near the lower left corner of the plate is about 0.3°C warmer than the rest of the plate, due to the power dissipation of the microcontroller.<br />
<br />
This technique of using multiple DS18B20 sensors controlled by a single Arduino can be used for one-dimensional experiments as well. Twenty-five sensors, evenly spaced along a meter of copper pipe, would make a wonderful replacement for the typical half-dozen thermocouples we’ve all used and hated as undergrads!<br />
<br />
The sensors can be ordered from <a href="http://www.newark.com/maxim-integrated-products/ds18b20/ic-thermometer-12bit-0-5-c-to-92/dp/37K7656?in_merch=Popular%20Products">Newark.com</a> or <a href="http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_865936_-1">Jameco.com</a>. For our thermal epoxy we used "Arctic Silver Alumina" from <a href="http://newegg.com/">Newegg.com</a>.Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com3tag:blogger.com,1999:blog-38893335957684232.post-9010677184070316562012-05-16T19:07:00.000-07:002012-05-16T19:10:44.767-07:00Off-topic, but... AT&T sucks.For the past several years we've gotten our internet through AT&T DSL. Unless you want to support Comcast with your money (and nobody with an interest in net neutrality does) AT&T DSL has been the only option in this town.<br />
<br />
I got tired of slow network. Calling AT&T did no good, they claimed things were fine. So I measured the actual speed. Repeatedly!<br />
<br />
It just happens that I have access to a pair of very nice servers at my work; I wrote a script on my home machine that downloaded a small file from one of them and recorded the download speed every 15 minutes. An identical script on the second server served as control: should the problem be the server rather than the DSL line, the second server would show it.<br />
<br />
After sitting through more than a year of dreadful AT&T service, here are the results.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAXrW3SbiEAJt0WxmMc9PEoRX9_HCdzIctchKWadurDSxKOlxSSgFtnuQmder_ufGiX7LNx0uobaG_WbTd9m2lTag8qdZGZeaxCXZQZwafqeQEmWuTDuHq75ZilVire-02nJ1SEv-7nVE/s1600/total_ATnT.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAXrW3SbiEAJt0WxmMc9PEoRX9_HCdzIctchKWadurDSxKOlxSSgFtnuQmder_ufGiX7LNx0uobaG_WbTd9m2lTag8qdZGZeaxCXZQZwafqeQEmWuTDuHq75ZilVire-02nJ1SEv-7nVE/s400/total_ATnT.png" width="400" /></a></div>
Notes:<br />
<ul>
<li>Up through the end of April of this year, my actual download speed was at most HALF the advertized "up to" speed. For most of last year, I got a quarter of the advertised speed on average.</li>
<li>The jump in speed at the end corresponds to the date at which many of my neighbors gave up and got Comcast. Speeds after that point are still less than 2/3 the advertised "up to" speed.</li>
<li>The "control" server (graph not shown here) showed a flat constant speed of nearly 100 Mbps. In other words, the limiting factor was the transfer, not the source.</li>
</ul>
Conclusions: AT&T sucks, and we need for them to have some serious competition in this area. <br />
<br />
They just switched me to "U-Verse" (still the same "up to 1.5 Mbps" speed) so we'll see if that's any improvement. I'm not holding my breath, and the script is still running.<br />
<br />
Oh, and here's the code, which was executed every 15 minutes by cron.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">#!/bin/bash</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">DATESTRING=`date "+%Y-%m-%dT%H:%M:%S%t"`</span><br />
<span style="font-family: "Courier New",Courier,monospace;">DOWNLOADSPEED=`curl -s -o /tmp/whatever -w '%{speed_download}' http://REDACTED/randomblock`</span><br />
<span style="font-family: "Courier New",Courier,monospace;">echo "$DATESTRING $DOWNLOADSPEED" >> /REDACTED/speedresults.txt</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">rm /tmp/whatever</span><br />
<br />
<br />
<br />
<br />Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com2tag:blogger.com,1999:blog-38893335957684232.post-24451531447182687342012-03-21T12:19:00.000-07:002012-03-21T12:19:46.995-07:00Driving multiple Sparkfun 7-segment displays with an ArduinoI'm currently helping a couple of engineering students finish a senior project that didn't get finished last year. Long story... Anyway, it's a bicycle brake tester being built for <a href="http://paulcomp.com/" target="_blank">Paul Components</a>. The mechanical design is great, but they had trouble with the electronics.<br />
<br />
Part of those electronics involved writing numbers to a pair of <a href="http://www.sparkfun.com/products/9764" target="_blank">Sparkfun 7-segment displays</a>. There's a lot of discussion on the Sparkfun board about these: apparently they're difficult. I had some issues making them work ---baud rate, for example, which should be set to 9600 in setup() not 2400 as stated in some references--- but it's relatively straightforward once those issues are straightened out. <a href="http://physics.csuchico.edu/%7Eeayars/code/display.pde.html">Here's my code</a>, in hopes that it'll be helpful to anyone else trying to write to several 7-segment displays simultaneously. <br />
<br />
The serial TX line (second pin given in the SoftwareSerial declaration) should be connected to the RX pin on the corresponding Sparkfun breakout board; the RX line in the SoftwareSerial declaration should be left unconnected. I've only tested it with two boards at a time, but it should work with as many as you have room for on the Arduino. It works fine for just one display, also!Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com1tag:blogger.com,1999:blog-38893335957684232.post-80639662148947341612012-02-12T18:53:00.000-08:002012-02-12T18:53:58.594-08:00Remote key-switch operationOne of my colleagues, <a href="http://phys.csuchico.edu/%7Esdmayor/index.html">Dr. Shane Mayor</a>, has built a very nice <a href="http://phys.csuchico.edu/lidar/">LIDAR system for atmospheric research</a>. It's located at a remote site, at the end of a dirt road, and everything about the system can be controlled remotely <i>except</i> the main pump laser power supply. That supply has a key-switch, which has to be manually turned to activate the system. He asked me to see what I could do to make it all remote-controlled.<br />
<br />
Due to the cost of the laser, and Dr. Mayor's unwillingness to void the warranty, my suggestion that he just replace the key-switch with a computer-activated relay was met with some resistance. He absolutely did NOT want me to do anything inside that case! So instead, I built a servomotor key-turner.<br />
<br />
The basic idea is to use one of the spare digital lines on his main National Instruments control board to signal the servo controller. When the line goes high, the servo turns the key to the 'on' position, and when the line goes low, the servo turns the key to the 'off' position. Any simple microcontroller should be sufficient for the task: rather than commit an entire Arduino board to the job I just used an Attiny85. Still overkill, but it's so cheap that I don't stock anything cheaper in my parts bin anymore!<br />
<br />
Here's the circuit:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8Ya_tjrDf2Y4WR9mRbrlyZzRKNm_9myWYESVAWzjcrDXLrXI6r3JoJHBg6hzERX76O5l55MUCJu-mDrJNZQaRyvTLJJFq-jizWJvjWeCBI6Jhu-B5dl00AcqAl2uDbJkZWj-EhKFwsL4/s1600/remote-key0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8Ya_tjrDf2Y4WR9mRbrlyZzRKNm_9myWYESVAWzjcrDXLrXI6r3JoJHBg6hzERX76O5l55MUCJu-mDrJNZQaRyvTLJJFq-jizWJvjWeCBI6Jhu-B5dl00AcqAl2uDbJkZWj-EhKFwsL4/s400/remote-key0.png" width="400" /></a></div>And here's the board, which I etched using <a href="http://www.pcbfx.com/main_site/pages/start_here/overview.html">Pulsar's "Fab-in-a-box" toner-transfer paper</a>.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9zyDRdKg3M4cQulf8o4ZT-ZxkBST3-fc4mzZDH8IZpI6KWfHDjI0Q9BEotJxOZAzDLWs8mZ8AdnHv9qnA-RE-e692WlG8dBd5eUVjHJO-xBqtEkhvtedX0wa0WatkkZ5n-94tsR6MB2c/s1600/remote-key1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="125" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9zyDRdKg3M4cQulf8o4ZT-ZxkBST3-fc4mzZDH8IZpI6KWfHDjI0Q9BEotJxOZAzDLWs8mZ8AdnHv9qnA-RE-e692WlG8dBd5eUVjHJO-xBqtEkhvtedX0wa0WatkkZ5n-94tsR6MB2c/s320/remote-key1.png" width="320" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNK9frmFi4gWpWxUS-5CBM3Qazz3AyAT4tSq3tK1punbHJ00MmK7VJw9hrbndrI4BGszjmXQBdhoIm25jDEro07ecSzl8QOd_U0qqC98kh7VMiWgMsgNWV-q3ZVy8prYGmrfpWn1KXJvI/s1600/remote-key2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="126" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNK9frmFi4gWpWxUS-5CBM3Qazz3AyAT4tSq3tK1punbHJ00MmK7VJw9hrbndrI4BGszjmXQBdhoIm25jDEro07ecSzl8QOd_U0qqC98kh7VMiWgMsgNWV-q3ZVy8prYGmrfpWn1KXJvI/s320/remote-key2.png" width="320" /></a></div>The software uses <a href="https://github.com/fri000/Servo8Bit">Ilya Brutman's Servo8Bit library</a>, and I programmed the Attiny85 using <a href="http://hlt.media.mit.edu/?p=1695">MIT's High-Low Tech</a> instructions. <a href="http://physics.csuchico.edu/%7Eeayars/code/remote_key.pde.html">Here's my code</a>. There's a 6-pin ISP header on the board (J1), which I use with an Arduino-as-ISP programmer.<br />
<br />
I used the top of a scrapped project box to mount the servo directly above the key and hold the servo output shaft coaxial with the key. The actuator consists of a rubber stopper with a slot cut in it, mounted on a servo control arm. The slot in the stopper fits over the key so that the servo turns the key directly.<br />
<br />
It took one re-programming cycle to make the microcontroller turn the servo the right direction (what kind of key turns <i>left</i> for on, anyway?) and then a very simple LabVIEW program to control the digital line to the servo, but that's it! Works great.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi23-VVa-PvPFbspbytcaFse-rUe7FY9SMw6lvvha48JxGC3h4PZmwU7m-zg3GwOUkMVES026yU7FuxSjSE5TPgLTQxfzpaRI6Vevei-ix9opV6V-an1EfinkvjMkOShSu4INBuBlZ9J5c/s1600/R0011047.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi23-VVa-PvPFbspbytcaFse-rUe7FY9SMw6lvvha48JxGC3h4PZmwU7m-zg3GwOUkMVES026yU7FuxSjSE5TPgLTQxfzpaRI6Vevei-ix9opV6V-an1EfinkvjMkOShSu4INBuBlZ9J5c/s400/R0011047.jpg" width="400" /></a></div>Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-63148255627383591572011-12-05T13:35:00.000-08:002011-12-11T10:31:22.032-08:00Christmas-tree water-level alert<u>Update 12/11/11:</u> A fix to the program--- changed to capSenseRaw() instead of capSense(). The problem with capSense() is that it auto-adjusts the output for touch sensing, rather than absolute capacitive measurement. capSense() reports whatever capacitance it observed the first time as zero from then on. This means that if the water level is high when the Arduino is turned on, high will be interpreted as dry... And it's not very convenient to make sure the sensor is outside the tree-stand whenever you first turn the lights on! Kinda misses the point of this whole exercise if you have to take the sensor out, dry it off, turn the lights on, put it back... But using capSenseRaw() takes care of the problem.<br />
<br />
One other note: the sensor has to be very waterproof! The 4 coats of polyurathane were marginal: I've since added a thin coat of silicon RTV and it works much better. If water touches the electrode strips, it shorts out the capacitor and the sensing function returns -2, which leads to erroneous reports of low water level.<br />
<br />
-- --- ----- ------- ----------- -------------<br />
<br />
About a year ago I made a Christmas-tree water-level sensor that didn't hold up well. <a href="http://hacks.ayars.org/2010/12/christmas-tree-water-level-sensor.html">Here's a link, but don't make that one</a>. It had a flashing LED, then an audible alarm, to let you know that the water was either low or gone. But why use an LED? As "Joe" suggested in his comment last year, the tree has a lot of lights on it already <i>and why not flash them instead?</i><br />
<br />
Good idea, Joe. Thanks!<br />
<br />
The functional problem with last year's model is that the copper traces used for the water-level sensor corroded quickly, and the device was useless in less than a week. The fix I came up with this year is to use a capacitive measurement of water level instead of a conductive measurement. This method (and the necessary <a href="http://www.arduino.cc/playground/Main/CapSense">CapSense library</a>) is described on the Arduino Playground wiki as an idea for a proximity sensor. Since water has a very high dielectric constant, the presence or absence of water significantly changes the capacitance of a pair of copper traces. Measuring the capacitance of those traces then gives you a measurement of water level while keeping the traces isolated from the water.<br />
<br />
Here's my sensor. It's just a strip of strip-type protoboard. (It's 4 traces wide, but I'm only using 2 traces.) It's been covered with 4 coats of spray-on clear polyurethane, so it is (one hopes) completely waterproof. There are two neodymium magnets glued to the back so I can mount it to the inside of the Christmas-tree stand. I forgot to put something in the picture for scale, sorry: it's 9cm long.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs9V6y1-N2yYPj1TwyWYzyBmT5X2TvEyYIFGUXCDHM1-tfDVlEcpZh3PWqxD_HIkYg3Hz5qc1WfMAFgSTpeWICQaCsDs5TH1QBU3BFkF3OCfwAU6q1GHYMrPNtQahHP6b4FoXOXUszA-E/s1600/CIMG0741.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs9V6y1-N2yYPj1TwyWYzyBmT5X2TvEyYIFGUXCDHM1-tfDVlEcpZh3PWqxD_HIkYg3Hz5qc1WfMAFgSTpeWICQaCsDs5TH1QBU3BFkF3OCfwAU6q1GHYMrPNtQahHP6b4FoXOXUszA-E/s320/CIMG0741.jpg" width="320" /></a></div>With this improved sensor, I can now use the CapSense library to measure water level without worrying about corrosion of the copper traces. And I probably should have stopped there, but Joe's suggestion just seemed to good to pass up. So here's the schematic for the rest of it:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3dh9z9rdRGr-Mp_4ApS9UH5WJEwMoyZt6qxLO3Be6EOKPCXRMnJckulaavcMo48A02x72ZqMX_xwZiVhnYGWkFPjS9eW73TmAM6sOwGkoh7nmxCMs1Kt5ib09GrT3R__RVA9lT9NqBvg/s1600/waterlevel-schematic.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3dh9z9rdRGr-Mp_4ApS9UH5WJEwMoyZt6qxLO3Be6EOKPCXRMnJckulaavcMo48A02x72ZqMX_xwZiVhnYGWkFPjS9eW73TmAM6sOwGkoh7nmxCMs1Kt5ib09GrT3R__RVA9lT9NqBvg/s400/waterlevel-schematic.png" width="381" /></a></div>Everything inside the dashed lines is built into a small box. The box has a plug receptacle on the top, into which are plugged the tree's lights. Power to that receptacle is switched by a relay, controlled by an Arduino Pro Mini. (The Pro Mini and relay are powered by a 9V wall-wart transformer, also mounted inside the box.)<br />
<br />
If the Arduino detects a "good" water level, it leaves the relay alone and the lights plugged into the receptacle stay on continuously. When the water level drops to "fair", the Arduino cuts the lights briefly once every 5 seconds. When the water level drops below that, the Arduino flashes the lights once a second. Here's the box: I wrapped it in shiny paper to help it "blend in" under the tree.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg17PncED9A_QgvxBlJ-iGi0hLuBTdNY9RPJCxE9za2Hcv3xgoQEJazmQLN_R-QmhOtU2K1iv-bX3Z5nfDDCP25zkEL_dZOqkf0ZkKC00rzhBmhtiElVRZmybRGnebNoSa8ZLJhSjFb_5g/s1600/CIMG0740.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg17PncED9A_QgvxBlJ-iGi0hLuBTdNY9RPJCxE9za2Hcv3xgoQEJazmQLN_R-QmhOtU2K1iv-bX3Z5nfDDCP25zkEL_dZOqkf0ZkKC00rzhBmhtiElVRZmybRGnebNoSa8ZLJhSjFb_5g/s320/CIMG0740.jpg" width="320" /></a></div><a href="http://physics.csuchico.edu/%7Eeayars/code/waterlevel.html">Here's the code</a>. The values of "fair" and "good" will depend on the exact geometry of your sensor and sensor cable. Uncomment the serial lines in that code and see what values are coming back from the Arduino to determine what levels are appropriate for your setup.<br />
<br />
A note for the Arduino-haters: Yes, this could be done with an ATtiny85. Here's why I decided to use a whole Arduino this time:<br />
<ol><li>You need fairly precise timing to measure capacitance repeatably with the CapSense library. That means you need an external crystal rather than the microcontroller's internal oscillator.</li>
<li>The 12A relay I used needed 9V to activate. (My local Radio Shack didn't have a 5V relay that could switch more than 1A.) An ATtiny needs 5V at most, so I would need a voltage regulation circuit.</li>
<li>I needed to know the values coming out of the CapSense routines so as to be able to set the cutoffs for "good" and "fair" in the final program. That meant I needed a serial link back to the computer for the setup process.</li>
<li>Put all this together and hey, it's an Arduino. The Arduino is built already, and I have to write an exam this week also.</li>
</ol>But yeah, it'd be cheaper and more elegant if I just used an ATtiny85. :-)<br />
<br />
Update: Since I have the memory available, <a href="http://physics.csuchico.edu/%7Eeayars/code/waterlevel2.html">I tweaked the program a bit</a>. Instead of a fast blink when the tree gets dry, it now blinks "water... water... water..." in Morse code.Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com9tag:blogger.com,1999:blog-38893335957684232.post-42685147527163420812011-09-14T22:42:00.000-07:002011-09-14T22:46:56.718-07:00HovercraftStefan and I cleaned out the garage last weekend. We found some useful scraps of plywood, and plastic sheeting, and a roll of duct tape, and a leafblower that nobody was using for blowing leaves. Rather than just throw them away, we decided to stick them together first and THEN throw them away. So we built a hovercraft.<br />
<br />
This is not the usual electronics-related hack; it has nothing to do with microcontrollers or teaching physics. But it was fun... and it's definitely a hack! Here's how to build your own.<br />
<br />
Start with a piece of plywood with an area of 7-9 square feet or so. Circular would probably work best, but anything roughly symmetric should be fine. Cut an off-center hole in it. Cut a piece of plastic sheeting about 6" larger than the plywood.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJDaTMH1DQxzM6p5Fuq_j2qgnuaDz7uV9lPV9oUXGL2WVPTduvme2h-q4GNS6V0EKA44ma_2dt43aAKZEhvhSnmplcCFt7OH514e9tTXfxpSd8Oi54cvCERISxN-n0TZ9U5Tkt8QNFO4w/s1600/IMG_8478.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="266" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJDaTMH1DQxzM6p5Fuq_j2qgnuaDz7uV9lPV9oUXGL2WVPTduvme2h-q4GNS6V0EKA44ma_2dt43aAKZEhvhSnmplcCFt7OH514e9tTXfxpSd8Oi54cvCERISxN-n0TZ9U5Tkt8QNFO4w/s400/IMG_8478.jpg" width="400" /> </a></div><div class="separator" style="clear: both; text-align: left;">Put the plastic under the plywood and fold the plastic loosely up over the edges. Tape the plastic down with duct tape. Staple through the tape every 1-2 inches, then put a second strip of tape over the staples to seal it. It should be evenly loose, not tight!</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVIEsHPynKCeBQvx7QsSD8IZrixglYFMTYlAQeKhwAjJrRSoTMVCo4DVdRCr29UR0QO0chRKk5RtSMoRTukxHTiGEKFx6-DBRfL7eBpuQ5TgErWQa-ZzBrVO21NGpz8KTPEql9F-mMahc/s1600/IMG_8480.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYKpaVvQImPFDV45J3YRSP9AlkMVVoFPp5dVmrhoM0WKrvKFKYZSTzejV7p7DtzBFhddBMf_ZmSugBTkJBtJZf1pAHosCn8piK5HbFTA_9bI1NXhekaKVb6ZJ5Yogpghe6hQID-53zV7o/s1600/IMG_8482.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYKpaVvQImPFDV45J3YRSP9AlkMVVoFPp5dVmrhoM0WKrvKFKYZSTzejV7p7DtzBFhddBMf_ZmSugBTkJBtJZf1pAHosCn8piK5HbFTA_9bI1NXhekaKVb6ZJ5Yogpghe6hQID-53zV7o/s320/IMG_8482.jpg" width="213" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmAYruUuiF0ikNEK9ELcikX5k24wS6hRSZMO4asHAzjjKIPWYB8kHhAKdEX2BtSjHyCLDLMzHOEGW5Psqfp91iHjwWJXgETIetKXFBasRl4oft4W3ot7sWOAJbzSOOId6tPa9omvIt0Bk/s1600/IMG_8485.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmAYruUuiF0ikNEK9ELcikX5k24wS6hRSZMO4asHAzjjKIPWYB8kHhAKdEX2BtSjHyCLDLMzHOEGW5Psqfp91iHjwWJXgETIetKXFBasRl4oft4W3ot7sWOAJbzSOOId6tPa9omvIt0Bk/s320/IMG_8485.jpg" width="212" /></a></div> We put the staples too far from the edge in these pictures, and had to put in a second row of staples closer to the edge. More duct tape! Make sure the plastic is completely sealed to the plywood, because when it comes off your hovercraft will stop hovering.<br />
<br />
Now turn it over and cut four (roughly) symmetric holes around an 8-inch circle in the center. We just cut slits a little more than 2 inches wide. We then fed duct tape through the holes so that the center of the plastic was attached to the plywood. Anchor it firmly with more staples, and reinforce the plastic around the holes with —you guessed it— more duct tape.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnl110_zHFZ6utpH9DiWFFcvUJ5lH0fNTIiA2-1uMCJutPNaMaVHVcEB5d3Bk2_ckaHYVCMLoGqtANySLVUAe6vXAtw1iaA8XN4CtALlBwgv1bDVgUuBqFi4XzJnFcjJb6S42Z4PwqpQg/s1600/IMG_8486.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="131" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnl110_zHFZ6utpH9DiWFFcvUJ5lH0fNTIiA2-1uMCJutPNaMaVHVcEB5d3Bk2_ckaHYVCMLoGqtANySLVUAe6vXAtw1iaA8XN4CtALlBwgv1bDVgUuBqFi4XzJnFcjJb6S42Z4PwqpQg/s200/IMG_8486.jpg" width="200" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl7sxFzudsBiCgcAICL3YWAUEVpGKxij9S26q05by80v3TWCE5aLiNq_a2q1X_WUukjR9x0eDpQc9fBweHH034rmqNDng74-9MyPuEYZurDAAYsbj8pF83gMh22mGQDD6S4M0TefDqCIQ/s1600/IMG_8487.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="132" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl7sxFzudsBiCgcAICL3YWAUEVpGKxij9S26q05by80v3TWCE5aLiNq_a2q1X_WUukjR9x0eDpQc9fBweHH034rmqNDng74-9MyPuEYZurDAAYsbj8pF83gMh22mGQDD6S4M0TefDqCIQ/s200/IMG_8487.jpg" width="200" /></a></div>Air can now blow in the hole in the plywood from the top, inflate the plastic into a flattened donut shape, and exit through the holes in the center. The filled plastic "bubble" makes a skirt for the hovercraft.<br />
<br />
Next, turn it right-side up again and attach the leafblower. We used more plastic and duct tape and staples... Lots of staples... More duct tape... and eventually got something that would direct the air through the hole without too much leakage.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRhjrvbM7WjayjSLtgUW9CmfcDLRXtGydSGT2sc_JmJ0uyt7l44aI96VigB6yoD9SBo2fSxmG1d086-B8j9tYhVKX0Jge_EV0dXfmasX1lsBkf3BY8Q9kJn_CjpO4vZASeBqJ2XQVeddA/s1600/IMG_8489.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="132" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRhjrvbM7WjayjSLtgUW9CmfcDLRXtGydSGT2sc_JmJ0uyt7l44aI96VigB6yoD9SBo2fSxmG1d086-B8j9tYhVKX0Jge_EV0dXfmasX1lsBkf3BY8Q9kJn_CjpO4vZASeBqJ2XQVeddA/s200/IMG_8489.jpg" width="200" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVSZ5bYi7zdAIqFvQ5eLgkc1LaQbcraZVF-yU35icqlPAWE0ZCvd4NBA12P46CvQll_8Z8DjIJVA4vubS4_6PfqCIEXSYcOqjz8sVO4tPeIG8PPr1yV0nryXIuBu504D9FLmxE4Oip4QM/s1600/IMG_8490.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="132" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVSZ5bYi7zdAIqFvQ5eLgkc1LaQbcraZVF-yU35icqlPAWE0ZCvd4NBA12P46CvQll_8Z8DjIJVA4vubS4_6PfqCIEXSYcOqjz8sVO4tPeIG8PPr1yV0nryXIuBu504D9FLmxE4Oip4QM/s200/IMG_8490.jpg" width="200" /></a></div><br />
Sit on top and turn the blower on — you're good to go!<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA-LPG1fMW7K979EmodSeADRODiohc2Z1MSZJDU_zO0S9t1UYbe_-UPM1ynfVgdR2NiNI1_SG-4eFcL5jafyErzP-ekK-1fLnP7P6yXVcTQ_7oFva17WdS1liFsi2JxhlG-7UGoqJRUsU/s1600/IMG_8491.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="265" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA-LPG1fMW7K979EmodSeADRODiohc2Z1MSZJDU_zO0S9t1UYbe_-UPM1ynfVgdR2NiNI1_SG-4eFcL5jafyErzP-ekK-1fLnP7P6yXVcTQ_7oFva17WdS1liFsi2JxhlG-7UGoqJRUsU/s400/IMG_8491.jpg" width="400" /></a></div>Obviously a gas-powered leafblower would be an improvement — this one is limited in range by the 50-foot extension cord. It's still fun for sliding around the driveway, though!Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0tag:blogger.com,1999:blog-38893335957684232.post-64507009194187920182011-08-25T17:00:00.000-07:002011-08-25T17:01:39.750-07:00How long until Christmas?I have kids. They have questions. One of their big questions, all year long it seems, is "How long until Christmas?" Here's one way to answer that question.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLmFNvvO50e9y4eq0qtJmPIMuLboyGNDDBRNyQR1oVuMB4lTWnGRsp-1oNJel0DsYd8kRqt4EqeJXtKOtRZ_NCJLO1xYzuHsLHBx1lyHlt_7itk1EZ6tByiOZxBip_BPGzQg_LD0y4dsk/s1600/CIMG0519.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLmFNvvO50e9y4eq0qtJmPIMuLboyGNDDBRNyQR1oVuMB4lTWnGRsp-1oNJel0DsYd8kRqt4EqeJXtKOtRZ_NCJLO1xYzuHsLHBx1lyHlt_7itk1EZ6tByiOZxBip_BPGzQg_LD0y4dsk/s400/CIMG0519.jpg" width="400" /> </a></div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">The circuit consists of three main elements: Arduino Pro Mini, DS3231 real-time clock (RTC) breakout board, and a standard 2x16 LCD. </div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">The Arduino Pro Mini takes power (raw) from the 9V battery through the toggle switch. The Vcc output of the Arduino's regulator (5V) is used to drive the LCD and the clock. Here's the <a href="http://physics.csuchico.edu/%7Eeayars/code/countdown.pde.html">program on that Arduino</a>. The program reads the time from the RTC, calculates the number of seconds between 'now' and a hard-coded 'targetDate', then from that time differential calculates and displays the number of days/hours/minutes/seconds remaining. It does this roughly 4x/second, which makes a nice ticking-second countdown. When the countdown reaches zero, it displays "Merry Christmas!" and goes to sleep.</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">The Arduino uses I2C to communicate with the RTC. I used a homemade DS3231 breakout board with a battery backup for my RTC, but one could use the more standard <a href="http://www.sparkfun.com/products/99">Sparkfun DS1307 breakout</a> as well. In either case, my <a href="http://hacks.ayars.org/2011/04/ds3231-real-time-clock.html">DS3231 library</a> works fine. The code provided above does not set the clock: it assumes the clock has been set previously. I used the setClock.pde sketch from my DS3231 library to set the clock using the serial port, and no hardware changes are required to make that program set the clock on this circuit.</div><br />
The LCD is a standard <a href="http://www.sparkfun.com/products/9054">2x16 LCD with the HD44780 driver</a>, as shown <a href="http://www.arduino.cc/en/Reference/LiquidCrystal">here</a>.<br />
<br />
Nothing particularly fancy, but I just happened to have all the necessary parts sitting on my workbench anyway so I threw it together one evening. You can of course change the target date and message in the software so it works for any other event you might want. At this point in the semester, I'm leaning towards counting the seconds until the Physics 202B final...Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com3tag:blogger.com,1999:blog-38893335957684232.post-72667399324008055422011-08-03T07:15:00.000-07:002012-12-14T13:14:58.794-08:00Simple Arduino data-collectionAt this year's "Arduinos in the Physics Lab" workshop at the <a href="http://aapt.org/">AAPT</a> meeting, one of the participants asked for a simple way of using the Arduino as a tethered A/D converter for data collection direct to a computer. This is my quick & dirty demonstration solution.<br />
<br />
<a href="http://physics.csuchico.edu/%7Eeayars/code/senddata.pde.html">Here's the code for the Arduino</a>. It waits for a single byte 'N' to arrive on the serial port, then once that byte arrives it sends out N data pairs formatted as tab-separated millis() and analogRead() values. The readings are separated by roughly 10 milliseconds. This version of the code only reports the values of analog pin 0 (A0), but it can be easily modified to return other (or more) ports.<br />
<br />
For the computer end, I used Python: <a href="http://physics.csuchico.edu/%7Eeayars/code/grabdata_py.html">here's the code</a>. This was done on a Macintosh, with <a href="http://www.scipy.org/PyLab">Pylab</a> installed so I can use matplotlib to handle the plotting nicely. On Linux or Windows the port will be described differently, and if the program fails for you on the line 'import pylab as pl' then ... well, install pylab on your system. It's a great wrapper package for scipy, numpy, and matplotlib. The program expects two arguments: the number of points to collect and the filename where points should be saved.<br />
<br />
Here's a sample output plot, showing relatively meaningless data from a light sensor.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmxf6soY_3COlkDrkve6Vr8QjM9_UsJbj9ldopHNBEkkh2ziXHI-WSK8zbM6pp_QOEeepQg2SScr3Q78QLiBqPTgfdd-wsFvEHKTD-v_2PanTjdk4xykEoVvQZcHa-MisoD3sNegsScJU/s1600/grabdata_output.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmxf6soY_3COlkDrkve6Vr8QjM9_UsJbj9ldopHNBEkkh2ziXHI-WSK8zbM6pp_QOEeepQg2SScr3Q78QLiBqPTgfdd-wsFvEHKTD-v_2PanTjdk4xykEoVvQZcHa-MisoD3sNegsScJU/s320/grabdata_output.png" width="320" /></a></div>
One glitch I found was that there needs to be a short delay between starting the serial communications to the Arduino and sending the request for N data points. I do not know whether this is a problem with the Arduino in general, or with the Arduino Uno I was using as a testbed, or with the pyserial library, or with the Macintosh implementation of pyserial... It was a mess trying to figure out what was going on, though, because when in interactive mode everything would work perfectly but the exact same commands in a Python script would not work. The difference of course is that I would take several seconds to type commands in interactive mode, and it t<span style="font-family: inherit;">ook me a long time to figure out what was causing the problem! The solution I used is in line 37 of the code:</span><br />
<div style="font-family: inherit;">
time.sleep(1.5)<br />
The sleep value (1.5 seconds) was determined by trial and error. ser.flush() should work also, but I did not find this to be the case.</div>
Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com1tag:blogger.com,1999:blog-38893335957684232.post-41285113566859498142011-06-25T15:08:00.000-07:002011-06-25T15:09:11.557-07:00Stereo Camera rig<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVk0YjuL_lbnHu35KetM2cAbFfngqO3RQdvJzW0tWpH27RBAUozMKSHSZVmgqwibOX0osa2ssjTLKLq2bCJ5sOW1EUU7xfcWUA5Jrj316AHG25DBXqfkK8NBgbKUKR8aE-bE9D2pQlALs/s1600/IMG_0442.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="162" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVk0YjuL_lbnHu35KetM2cAbFfngqO3RQdvJzW0tWpH27RBAUozMKSHSZVmgqwibOX0osa2ssjTLKLq2bCJ5sOW1EUU7xfcWUA5Jrj316AHG25DBXqfkK8NBgbKUKR8aE-bE9D2pQlALs/s400/IMG_0442.jpg" width="400" /></a></div><br />
This is something I've been wanting to try for awhile: I'd like to take pictures I can use with an old-school <a href="http://courses.ncssm.edu/gallery/collections/toys/html/exhibit01.htm">stereoscope</a>. It seems like a simple enough idea: you just need two pictures of the same thing, taken from a few inches apart. I've seen it done with just two cameras —no external synchronization, just push both buttons at the same time — but it seemed like I could probably synchronize things a bit better than that.<br />
<br />
Ideally, it would be perfect to set things up so that one camera was a master and the other a slave: exposure and zoom parameters would be set on the one, which would then be duplicated on the other. The <a href="http://chdk.wikia.com/wiki/CHDK">Canon Hack Development Kit (CHDK)</a> gave me some hope that this might be doable, but I haven't found any straightforward way of setting up a master/slave relationship, so instead I used cruder methods. The cameras use a CHDK script to time how long power is applied to the USB connectors, and depending on the pulse width the cameras either zoom in, zoom out, or shoot.<br />
<br />
The pill-bottle on the left contains a 4-AA battery pack, 5V regulator, some buttons, and an ATtiny85 to convert button presses to appropriate-length pulses for the cameras. It's not ideal, but it does give me synchronized zoom and shoot capacity using the one set of controls on the pill-bottle.<br />
<br />
Here's the <a href="http://physics.csuchico.edu/%7Eeayars/code/stereocam.bas.html">code for the cameras</a>, and here's the <a href="http://physics.csuchico.edu/%7Eeayars/code/stereocam.pde.html">code for the ATtiny85</a>. One thing I found out by extensive trial and error is that the signal at the USB connector must be 5V. Less than 4.5V does not work, at least on these eBay-special A590is cameras. <br />
<br />
I still think there should be some way of having one of the two cameras tell the microcontroller its settings, and have the microcontroller set things to the same values on the second camera. That would allow much easier use of the excellent controls available on the A590is camera. But someone else will have to figure that one out. Send me a link if you know of someone who's successfully managed this!Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com1tag:blogger.com,1999:blog-38893335957684232.post-34802431628164830962011-06-21T21:59:00.000-07:002011-06-22T18:27:41.849-07:00Morse-code trainerMy kids are learning Morse code this summer, so I threw together this little circuit to help them learn. And to make it more fun...<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGfRHAMpiHU_so-3II9btegkFVoGExXICV_WaCI5I7DsYTAPgRKRLTzyFNjCWsZpL-C5d6-0vZmJZB_GlVXIRemuGrfmwd58fBD7k4qk7GpTJLOsllC6whz0uZV2lrUEzpGVtdngDXndw/s1600/morse_schematic.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="202" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGfRHAMpiHU_so-3II9btegkFVoGExXICV_WaCI5I7DsYTAPgRKRLTzyFNjCWsZpL-C5d6-0vZmJZB_GlVXIRemuGrfmwd58fBD7k4qk7GpTJLOsllC6whz0uZV2lrUEzpGVtdngDXndw/s320/morse_schematic.png" width="320" /></a></div>It uses an ATtiny85 ($2.26 at digikey.com) to drive a piezo beeper (≈ $3.50 at Radio Shack.) The ATtiny85 takes 5.5V max, so I built the circuit on a piece of strip-board so as to fit onto the back of a 3-AA-cell ($3 or so at Radio Shack) battery pack.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifBzJBqDDxpnU99ufGCAHq99M-2tJXBdRuH2zBWQTLskBCiuOMJFc0t3eib1TQSTyObBKcbt0Zbujl5hzZLELtUs27giGln-qHLMywVuRIR9xjy2inxOlCWQoJ_U3AqPQ6cPnxJdBfOy8/s1600/IMG_7843.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="265" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifBzJBqDDxpnU99ufGCAHq99M-2tJXBdRuH2zBWQTLskBCiuOMJFc0t3eib1TQSTyObBKcbt0Zbujl5hzZLELtUs27giGln-qHLMywVuRIR9xjy2inxOlCWQoJ_U3AqPQ6cPnxJdBfOy8/s400/IMG_7843.jpg" width="400" /> </a></div><div class="separator" style="clear: both; text-align: left;">To program it, I used <a href="http://hlt.media.mit.edu/?p=1229">MIT's "High-Low Tech" ATtiny85 core</a> using an Arduino as an ISP programmer. I actually built a 6-pin ISP header into the board, so I don't have to pull the chip out to reprogram it as you would with MIT's instructions, but that's neither here nor there. Using an Arduino core allows me to use all the Arduino tools I'm familiar with, but I don't have to spend $20 or more on a full Arduino when all I really need is one output pin and a couple kb of program space. The ATtiny85 is perfect for this: plenty of memory and dirt cheap. (Actually, an ATtiny25 would work with the amount of memory this program takes, but ATtiny85s are so cheap you don't save much buying the ATtiny25.)</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div style="text-align: left;"><a href="http://physics.csuchico.edu/%7Eeayars/code/morse.pde.html">Here's the code</a>. When the device is powered up, it waits 3 seconds then puts out the message at the desired speed. The message repeats until power is removed. Currently the message is "SOS the moon rover has broken down and I am stuck in the trash can in the garden shed." Once the kids decode it, they'll find a small Lego moon rover there as a prize.</div><div style="text-align: left;"><br />
</div><div style="text-align: left;">Changing the speed of the Morse output is easy: just increase or decrease the definition of DOTLENGTH and everything adjusts proportionally. Changing the message is equally simple: just change the value of message[] in the source code. As written, it can handle up to 255 characters in the message. The program can handle upper/lower case, numbers, and some punctuation.</div><div style="text-align: left;"><br />
</div><div style="text-align: left;">The program will also work with an Arduino, of course. You can even change the value of OUTLINE to 13 and the Arduino will use the built-in LED. (No circuit required, just a bare Arduino!)</div><div style="text-align: left;"><br />
</div><div style="text-align: left;">I know Morse code is pretty much obsolete now. You don't even need it for a ham license any more... but all the more reason to learn it! </div><div style="text-align: left;"><br />
</div><div style="text-align: left;">.... .- ...- . ..-. ..- -. .-- .. - .... .. - .- -. -.. . -- .- .. .-.. -- . .. ..-. -.-- --- ..- ..- ... . .. - .-.-.-</div>Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com5tag:blogger.com,1999:blog-38893335957684232.post-176493132488945522011-05-09T19:33:00.000-07:002011-05-09T19:33:56.509-07:00Arduino-based event counterI teach Modern Physics here at CSUC, and we occasionally use isotopes with half-lives of a year or less (such as Zinc-65 and Cadmium-109) for energy-calibration sources for a gamma-spectroscopy lab. I thought it might be fun to try measuring the activity of one of these sources over time and thus get a looooong-scale half-life data-set for students to play around with. Or maybe watch background nuclear count rates as a function of time for a couple months and see if we can locate the sun and/or galactic center from the cosmic ray count rate as a function of time and/or season.<br />
<br />
I didn't want to dedicate an entire computer and LabVIEW seat to the project, and besides I haven't yet seen a six-month period here during which our power didn't go off at least once. I figured it'd be nice to have a cheap self-contained module that did nothing else but count and log the counts. Here's what I came up with:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA4py7I4Xg8dBCb1tdcrKIHzLY5leUZ_pz-_t3OuAqjBuGbVOuovxq_JjTtCov4bd7wtNaCYjFkB7DDZ5-HRmEb6hfZmYUL0ne9gm_zB4Zo7u0DBHj8Tybq5twB5AzOuxiFn7SL_80568/s1600/scaler-working.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA4py7I4Xg8dBCb1tdcrKIHzLY5leUZ_pz-_t3OuAqjBuGbVOuovxq_JjTtCov4bd7wtNaCYjFkB7DDZ5-HRmEb6hfZmYUL0ne9gm_zB4Zo7u0DBHj8Tybq5twB5AzOuxiFn7SL_80568/s400/scaler-working.jpg" width="400" /> </a> </div><br />
The control unit is an Arduino Pro Mini, 328/3.3V/8MHz. It talks to a DS3231 real-time clock to get time-stamp information, and counts nuclear events (or any other digital signals) using an interrupt. Every hour (or so) it saves the event count to the SD card, with time-stamp information at the beginning and end of the interval, and starts another interval. The board has a large capacitor and a zener diode so that if the power fails the Arduino immediately saves the current count (with time-stamp) and writes a warning in the file to let the user know what happened. When power resumes, so does the counting — on the next line in the file with a new time-stamp, of course. When you're ready to stop collecting data, flip the switch and pull the SD card: everything is saved in ASCII format on the file "DATA.TXT"<br />
<br />
It can comfortably count events at up to 10ks/s. Possibly more, but I've not tested it past that rate as that's two orders of magnitude faster than what I need. There is also a count/don't-count switch, a battery backup on the RTC chip, an ALD1701 op-amp follower making sure that the input pulses are 3.3V-safe by the time they reach the Arduino, and of course an LCD that provides helpful information such as the time/date, count, and occasionally an error message. <br />
<br />
A <a href="http://physics.csuchico.edu/%7Eeayars/code/Scaler.zip">complete parts-list, EagleCAD schematic and board layout, and Arduino programs are available here</a>, should you want to make your own. I use the <a href="http://hacks.ayars.org/2011/04/ds3231-real-time-clock.html">DS3231 library</a> I wrote earlier, so you'll need to either grab that or modify my code to use your own clock routines if you'd prefer. The board layout I put together has larger-than-necessary pads —particularly on the vias— to facilitate 2-sided board production if you're using the toner-transfer method.<br />
<br />
In order to set the clock, you'll need to run the SetClock.pde program on the Arduino once. (It's provided in the above link.) This program uses the serial port connection to the Arduino to set the DS3231 clock: send the string "yymmddDhhmmssx" just once, and after that the clock will be fine until the CR1220 battery runs out in 10 years or so. (i.e. "1105092190115x" for 2011 May 9 Monday 7:01:15pm.) After the clock is set the first time, load and run the scaler.pde program for actual data collection.<br />
<br />
<br />
Good luck with it, and feel free to contact me with any questions if you try making your own.<br />
<div style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdBTkh6AlFyCFhMx-sNMknZLQSVgoL-hHrQHYNtwtj4gX_gOqzth82q9yFGnBos3yhuUVc_5OP-DLevZ-YzFyZCdyn6yPhDCqZyjrHY8TJbH0SKjlZBrUuC3O1wg4Ejjhnxx_lv5yENmw/s1600/scaler-circuit.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpIVrQu-isnxoZaSjcMA9bcYUVMlibIoTTlLrWg-SjI_U8NOiMVut_SFea06Qc5pchXekO2La13AqwTUgZAGWXRupGYmvL7U5Yz2UiE8fy7VyisI6VGLIbWzT2eb2iZIdFLkfHfHk9hxA/s1600/scaler.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpIVrQu-isnxoZaSjcMA9bcYUVMlibIoTTlLrWg-SjI_U8NOiMVut_SFea06Qc5pchXekO2La13AqwTUgZAGWXRupGYmvL7U5Yz2UiE8fy7VyisI6VGLIbWzT2eb2iZIdFLkfHfHk9hxA/s400/scaler.png" width="400" /></a></div><br />
</div>Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com1tag:blogger.com,1999:blog-38893335957684232.post-12824170928443698512011-04-04T16:49:00.000-07:002011-04-04T16:49:33.382-07:00DS3231 Real-Time ClockI've used the DS1307 Real-Time Clock (RTC) for a few projects in the past, but I'm currently working on several datalogger projects that use both RTC and SD-card. The problem is that the SD card won't survive 5V, and the DS1307 won't work at 3.3V. That particular clock chip needs a minimum of 4.5V according to both the datasheet and some inadvertent "experimental verification".<br />
<br />
Rex Belli (One of my students and an all-around bright guy, contact me if you're hiring a summer intern) pointed me towards the DS3231 as a possible replacement. It has several advantages over the DS1307:<br />
<ul><li>It runs fine on either 3.3V or 5V.</li>
<li>It has a built-in oscillator: no external crystal required.</li>
<li>It has two built-in alarms that can drive an interrupt pin, so if you just need a periodic interrupt signal this chip can in many cases do the job without a microcontroller.</li>
<li>It' rated to 2 minutes per year (max) drift. (My best DS1307 clock drifts about 2 minutes per month!)</li>
</ul>One disadvantage is that the DS3231 doesn't have the eprom storage that the DS1307 has, but you can cheat and store seven bytes in the alarm registers if you had to.<br />
<br />
I wrote an Arduino library for it, so if you want to use this clock chip with that microcontroller it makes things a bit easier.<br />
<br />
Here's the library: <a href="http://physics.csuchico.edu/%7Eeayars/code/DS3231.zip">DS3231.zip </a><br />
The header file (DS3231.h) is extensively commented, and there are several example sketches included as well. Enjoy! If you use the library for anything interesting, send me an email. I'd be happy to hear what's been done with it.Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com16tag:blogger.com,1999:blog-38893335957684232.post-30191480315804563602010-12-05T12:15:00.000-08:002010-12-08T22:39:31.412-08:00Christmas-tree water-level sensor<span style="font-size: small;">UPDATE, 4 DAYS LATER: Don't build this one. The problem is the sensor: as a couple folk over at Hack-A-Day predicted, the copper sensor strips grow crystals that conduct enough to short out the sensor and give a false "ok" reading. One predicted it'd last a month, which would have been fine, but no... 4 days. That's it. I'll look into other metals (Stainless steel? Platinum? :-) ) as well as other ways of driving the sensor such as the polarity-reversal ideas mentioned by Tom and jpa below. Other suggestions are welcome too, of course.</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">Meanwhile, it's back to trying to just reach down into the stand to feel the water level.</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">-- --- ----- ------- ----------- -------------</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">Well, it's that time of year again. I'm not allowed to go into stores between Thanksgiving and Christmas — it's a long story involving singing Santa dolls, inflatable snowmen, and spandex bike shorts; and I won't tell it here — so since I can't go shopping I use my time more productively. Or at least I do some hardware hacking...</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">We have a very nice Christmas-tree stand: it's a tall, heavy, cast-iron chunk that does a wonderful job of holding our tree up. The problem is that it's difficult to determine how much water is in the stand, or whether the tree is getting any water at all. Occasionally our tree will drop all its needles, or spontaneously combust, at which point it becomes obvious that the tree needed more water; but it'd be nice to have some earlier indicator.</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">I discovered MIT's "High-low tech" site recently, and they have a <a href="http://hlt.media.mit.edu/wiki/pmwiki.php?n=Main.ArduinoATtiny4585">nice tutorial on using the Arduino to program ATTiny45/85 chips</a>. So I decided to use an ATTiny85 to make a Christmas-tree water-level sensor.</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">The circuit itself is dirt simple: Battery, ATTiny85, LED, resistor, buzzer, and water sensor. That's it.</span><br />
<div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLyUhVfTMt-RPENqZ803LzsmB4B-l7F2G0hxmsvK4jzMJWnmOqTt0HNX8OWDhqItWDuW_0i5GcNnQiuxhGn2uLjtgajX4A0ILAM0KOQtlLtqS5RAZQp6PSVb-HIihFIbDpRU-3e-udwQY/s1600/treesaver-circuit.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="271" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLyUhVfTMt-RPENqZ803LzsmB4B-l7F2G0hxmsvK4jzMJWnmOqTt0HNX8OWDhqItWDuW_0i5GcNnQiuxhGn2uLjtgajX4A0ILAM0KOQtlLtqS5RAZQp6PSVb-HIihFIbDpRU-3e-udwQY/s400/treesaver-circuit.png" width="400" /> </a></span></div><div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;">The battery is a 3-cell AA battery pack (4.5V), and the buzzer is some random piezo buzzer that's been sitting in my parts bins for years.</span></div><span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">The sensor consists of a strip of proto-board with three traces: two long, and one cut about an inch shorter. The way the water sensor works is the pull-up resistors in the ATTiny85 (about 20k) hold the inputs high by default. If a sensor wire and the ground wire are immersed, the small current through the water pulls the corresponding input low. If the water covers all three traces, that's good. If the water gets below the level of the short trace then pin PB3 goes high to indicate low water level, and if the water gets below everything then pin PB4 goes high to indicate very low water level.</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">The <a href="http://phys.csuchico.edu/%7Eeayars/code/treesaver.pde.html">program</a> checks the state of lines PB3 and PB4, and makes the LED blink repeatedly if the level is low. Should the level get very low, the program turns on the buzzer as well. Note: if you're making one of these yourself, make sure the difference in length between sensor wires PB3 and PB4 is enough that the tree won't go from "fine" to "buzzer" in one night. Otherwise the thing wakes you up early in the morning!</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">Here's the device, as I was testing it in a cup of water. The ground strip is becoming slightly discolored due to something electrochemically interesting going on, even with the low voltage and low current of this application. That discoloration should not interfere with operation, though.</span><br />
<div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA8NV1-GXosQua9uhGcky7nbyUVDjgwxZbIOboinR6fZUmRVbZpUwN1fivnLJuWq_1FPfVRpMlpHvlIjz_dqtBlWnXVxzedNBiiFd08JTf0aisXaq4BnosMSwWCBeCLnA0Wm0Umlgzw1o/s1600/IMG_7015.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="265" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA8NV1-GXosQua9uhGcky7nbyUVDjgwxZbIOboinR6fZUmRVbZpUwN1fivnLJuWq_1FPfVRpMlpHvlIjz_dqtBlWnXVxzedNBiiFd08JTf0aisXaq4BnosMSwWCBeCLnA0Wm0Umlgzw1o/s400/IMG_7015.jpg" width="400" /></a></span></div><span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">To mount the device, I hot-glued magnets to the back of each piece. </span><br />
<div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX6-n-CNKDJptTIow2kQ8RpWdJqCa4x6BREnPPVYu4BVj8pYxCnIfkX4ikcP_Xg1MiLnmR0-EmL_d_fqJrSRyvuHd3soF5xtMcbwialo10k_z7jifrqsycZ6NLljZ-42g7C_dptOSFAsw/s1600/IMG_7017.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="265" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX6-n-CNKDJptTIow2kQ8RpWdJqCa4x6BREnPPVYu4BVj8pYxCnIfkX4ikcP_Xg1MiLnmR0-EmL_d_fqJrSRyvuHd3soF5xtMcbwialo10k_z7jifrqsycZ6NLljZ-42g7C_dptOSFAsw/s400/IMG_7017.jpg" width="400" /></a></span></div><span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">The magnets make it easy to mount the sensor and circuit:</span><br />
<div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7WdTq-eXTL2ELc-d9TzYut99rKL7hzS9z_EFFklzPRHXEajlhLXiETUB6vrzZtvHd8PQhaWPb3E4ursctzNBl_LdXLzfn4-QuU-KJ5x6CHx4qWsDJduilCySHCOIhwzuSsOoCUXHtL8o/s1600/Treesaver-mount.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7WdTq-eXTL2ELc-d9TzYut99rKL7hzS9z_EFFklzPRHXEajlhLXiETUB6vrzZtvHd8PQhaWPb3E4ursctzNBl_LdXLzfn4-QuU-KJ5x6CHx4qWsDJduilCySHCOIhwzuSsOoCUXHtL8o/s320/Treesaver-mount.png" width="320" /></a></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPvq9E5u6XqrVAX4BuQvaIJrIahPSWqSwqP1gG9l1SuG32mH6VMNqc60E9G45lnv4XJwwnre3CyC2J9lTbETKt_7D8sBjm3F9hPTWkI9Yg_EK10h7_oc-Fu5KXdd-OctNpLeglI018iLM/s1600/Treesaver-mounting.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTUTUinoGi5E8pQXN7kToVhIF2vhAZXu7k9580u_RNv8EQhwPcSoyR66yLPMHv9InrNzGQRlloSH44n3gRzSA_4YDQaav_LuKflkVBmNhBBkHvXfzg9JMEBxP8CVRIjmbQFxtS5wnYDfw/s1600/Treesaver.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a></span></div><div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;">Here's the final product, tucked up under the branches at the top of the stand. It's out of sight unless you duck to look under the tree, and it's much easier to check the water level than before!</span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpXQHzZEQdV2i7V7JfGlZ7FgNLXHgvjqHjFc6Sq0szT9y3FwSPGw5zDEZAUWkB1c9YN5tdXIF-a2UWPDC_bathQlZdSQTFLrN5BlFnMxkY7BYzP1OSkDoNRug3tx4KGLxYsGAXaQLffGc/s1600/IMG_7018.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="266" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpXQHzZEQdV2i7V7JfGlZ7FgNLXHgvjqHjFc6Sq0szT9y3FwSPGw5zDEZAUWkB1c9YN5tdXIF-a2UWPDC_bathQlZdSQTFLrN5BlFnMxkY7BYzP1OSkDoNRug3tx4KGLxYsGAXaQLffGc/s400/IMG_7018.jpg" width="400" /> </a></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><br />
</span></div><div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;">The same method could be used with an Arduino instead of the ATTiny85, and the <a href="http://phys.csuchico.edu/%7Eeayars/code/treesaver.pde.html">program</a> would work with an ATTiny45 or -25 also. (The compiled code uses fewer than 900 bytes.) If you re-wrote the program in PICAXE Basic, a PICAXE-08M would also work. </span></div><div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;"><br />
</span></div>Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com16tag:blogger.com,1999:blog-38893335957684232.post-44056474845511521612010-11-19T13:03:00.000-08:002010-11-19T13:03:54.518-08:00Improved Fan CartIn an earlier post I described an <a href="http://hacks.ayars.org/2010/06/arduino-controlled-physics-lab-fan-cart.html">Arduino-controlled fan cart</a>. The driver I used was an L293D quad half-H chip, because I had one handy and was out of simpler parts at the time. It's always bugged me that I was just controlling speed on that cart, since it's possible to control direction with an H-bridge also.<br />
<br />
I'd also gotten several suggestions of other features the fan-cart could have; and I've learned a bit about EagleCAD recently too, so I went back and re-did the device. Here it is: Fancart v2.1. I sized the board so that it fits in the board-holder notches on the top of the PASCO fan cart.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHM26RF2u1QlD6fv63YOR3BfhCfC59WCAVNGubpxjPQkUzBxQN-MDtVczAN_aUv9z9UqMV0ZuwjzQWGD2Ddx-9v4GX4o-8CGQfVQzdvNC56QH_SxMqUSr8z5vzoD_pmUKtAI4geN8J3NI/s1600/IMG_6984.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="265" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHM26RF2u1QlD6fv63YOR3BfhCfC59WCAVNGubpxjPQkUzBxQN-MDtVczAN_aUv9z9UqMV0ZuwjzQWGD2Ddx-9v4GX4o-8CGQfVQzdvNC56QH_SxMqUSr8z5vzoD_pmUKtAI4geN8J3NI/s400/IMG_6984.jpg" width="400" /> </a> </div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: left;">The three buttons set the mode, speed, and time. Any of the three parameters can be read by pressing the corresponding button: the setting will blink on the corresponding LED. For example, if the speed is 2/3, then pressing the speed button will cause the green LED to blink twice.</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Any parameter can be set by holding the corresponding button for two seconds and then releasing it. The parameter LED will turn off, and each subsequent press of the button advances the parameter through its cycle of values. For example: to change the speed from two (default) to one (lower speed), hold the speed button for two seconds then release it. The green LED will turn off. Press the speed button again and the green LED will blink three times (speed is now 3). Press the speed button once more and the green LED will blink once (speed is now 1). Press either of the other buttons to accept the change and go back to normal run mode.</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">There are three modes available in the current program:</div><div class="separator" style="clear: both; text-align: left;">Mode 1: The fan toggles between on and off each time the sensor sees a magnet. This is what the previous fancart did.</div><div class="separator" style="clear: both; text-align: left;">Mode 2: The fan turns on when it sees a magnet, and then turns off T seconds later, where T is the time setting. The current program has available T settings of 1-4 seconds, although that's easy to change.</div><div class="separator" style="clear: both; text-align: left;">Mode 3: The fan reverses each time it sees a magnet. This is kind of fun: one magnet in the center of the track results in anharmonic oscillation.</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">It's easy to put in other modes, or even to completely change what the buttons and LEDs do. The Arduino has 30k of memory, and this program uses only 2.5k so far...</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">One note about the magnetic sensor: instead of the reed switch on the previous version I'm now using an AH182 Hall effect sensor. The advantage of this sensor is that it's more sensitive, it has hysteresis so no debouncing is necessary, it's completely insensitive to vibration, and it's much smaller. The disadvantage is that it takes three wires instead of two, and the polarity of the magnet matters. But overall, it's a great improvement!</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0PUJMS3FALEv3uChBdwIGxZ767eHQ_VRK2D1pMujR5Atirc2apjxED8QwnSrh42r5nC4UpG8PhsXTHUUQq2HFGqyU8IRFohoN5WS1S-xfhwilOMudKQSXTlcl5EqG-eHrZ3p9ph61fbw/s1600/IMG_6993.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="265" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0PUJMS3FALEv3uChBdwIGxZ767eHQ_VRK2D1pMujR5Atirc2apjxED8QwnSrh42r5nC4UpG8PhsXTHUUQq2HFGqyU8IRFohoN5WS1S-xfhwilOMudKQSXTlcl5EqG-eHrZ3p9ph61fbw/s400/IMG_6993.jpg" width="400" /></a></div><div class="separator" style="clear: both; text-align: left;"><br />
<a href="http://physics.csuchico.edu/%7Eeayars/code/fancart2.pde.html">Here's the code</a>, and here are the <a href="http://physics.csuchico.edu/%7Eeayars/code/fancart.zip">EAGLE files</a>.</div>Dr. Ayarshttp://www.blogger.com/profile/11192509765516630383noreply@blogger.com0