Skip to content


Simple/Beginner’s PHP Website Template

This silly little ‘guide’ is meant for beginners in PHP. It’s a super quick template you can begin a website with (I claim no copyright to the code I wrote below, do what you want with it). Managing a site is much easier if the common elements are made dynamically, and for this it is best if you begin with clear, simple standards you can pick up on again later when you return to editing the site.

My code here is meant to be ‘quick and dirty’, getting the job done in the most obvious of ways. It can of course be used around CSS styles, and note also that a proper site would have the standard HTML/head/body tags. In the template code below, common template elements (header and footer) are included in each web page. This way, only one template file must be edited if site-spanning template pieces must be altered. That is, one page holds links which appear in a menu on all pages in the website, for instance. It is a bit redundant, but the .tpl.php files are stored in the sub-directory ‘tpl’ within the root directory where index.php stays.

Note that PHP5 allows included files to inherit variable scope from the parent page – this way, the variables $curPage and $rootDir are passed along to the tpl files. From this, simple switches can be made depending on what the current page is, for instance keeping hyperlinks from appearing when you’re currently on the linked page.

Note also that there are (at least) two ways of going about making a PHP website template. One way is how I show here, where individual pages include template pieces while themselves showing the content. Another way would be to have a main page which assembles the entire page, putting the template together and then putting in content, so to the user it may actually look like the same page.

So..Hopefully this quick little demo will prove useful! Enjoy.

index.php: <?php $curPage = 'Home'; $rootDir = '.'; include("$rootDir/tpl/links.tpl.php"); echo 'content here'; include("$rootDir/tpl/footer.tpl.php"); ?>
about.php: <?php $curPage = 'About'; $rootDir = '.'; include("$rootDir/tpl/links.tpl.php"); echo 'about this site here'; include("$rootDir/tpl/footer.tpl.php"); ?>
links.php: <?php $curPage = 'Links'; $rootDir = '.'; include("$rootDir/tpl/links.tpl.php"); echo 'Links Page'; include("$rootDir/tpl/footer.tpl.php"); ?>
links.tpl.php: <?php $homeLink = "<a href='$rootDir/'>Home</a>"; $aboutLink = "<a href='$rootDir/about.php'>About</a>"; $linksLink = "<a href='$rootDir/links.php'>Links</a>"; //Main site links
if($curPage == 'Home') $homeLink = "Home Pad"; echo "$homeLink | $aboutLink" ." | $linksLink"; echo '<hr />'; ?>
footer.tpl.php: <?php echo '<p>Footer information</p>'; ?>

Posted in How-To. Tagged with , , , , .

SMF Forum Hacker/Spammer – avatar vulnerability

Simple Machines Forum is a really great free and open source script for running a forum.  There were some vulnerabilities in earlier versions, however, and a forum I run seems to have become victim to one such attack.  A user under the name ‘krisbarteo’ was able to register, then create an avatar picture which somehow gained him access to editing some of the files in the SMF script files.  There was a one-line string added to the top of these which was obfuscated by a base 64 bit code.  This looked like so (the actual code is a very long string and was cut up here): <? /**/eval(base64_decode(’aWYoZ …  … fX19′)); ?> This caused the php to emit a bunch of links in hidden HTML so that certain Google search hits to my site would redirect to the spammer’s sites. Fixing the issue took awhile, but only because so many pages had been infected.  I got bored of opening each page and made a regex search using grepWin to mass-delete the string. 

^(<\? /\*\*/eval\(base64_decode).*\s*<\?php
and replace with:
<\?php
I found a program called Regex Coach which was invaluable for this. I can only say that it worked for me, of course, and if anyone else is going to try it then they should make a backup. More details on the fix are here: http://www.simplemachines.org/community/index.php?topic=338877.0 Figuring out how to do a regex search led me to this java regex string testing site: http://regexpal.com/ Also, this site is very good at explaining regex expressions: http://www.regular-expressions.info/completelines.html

Posted in Programming, Software, Troubleshooting.

Tom Lehrer – National Brotherhood Week

I discovered Tom Lehrer, a humorist piano player from the mid ’40s through the 60s, just now when reading The Ancestor’s Tale: A Pilgrimage to the Dawn of Evolution by Richard Dawkins (HIGHLY recommended book).  Tom was mentioned in one of the captions for his song which is marked to play in the style ‘A little too fast’ (I Wanna Go Back to Dixie is the song).

This was one of the first songs I found on youtube, "National Brotherhood Week":
http://www.youtube.com/watch?v=aIlJ8ZCs4jY

And there are plenty more just as entertaining!

There is more information about Tom Lehrer in a book I randomly found, Seriously Funny: The Rebel Comedians of the 1950s and 1960s.  Google has a preview of Seriously Funny here.

Posted in Art, Humor, Random, Short Post.

Flash, FlashDevelop, AMFPHP and AMF Remoting – A Getting Started Guide

Introduction

Some months ago I began a project involving Flash for making visual representations of data.  The learning curve was steep at the beginning, mostly because of so much confusion between all of the Adobe (and formerly, Macromedia) products.  There’s Flash, ActionScript, Flex, AIR, ColdFusion, Director, and so on – and on top of that there are a small number of acronyms and catch terms such as AMF, RPC, FLA, SWF, MXML, to name a few…and what the heck does CS4 stand for?  I’d like to clarify a few of those things in this article, plus talk about a setup that works very well for me – Best of all, the setup I use is completely free (as in beer) and is also mostly open source.

Definitions

First of all, the difference between Flash and Flex is a little hard to explain but you already know what Flash is – it is the multimedia platform which had first become popular when owned by Macromedia, and is now continued by Adobe.  Flash was first designed for interactive (vector, primarily) animations, but has evolved in functionality, and is used for streaming media from YouTube, for instance.  Flex is essentially a framework built on top of Flash, and allows a programmer-style (rather than more of an animator) approach to creating Flash media.  There are in fact two versions of Flex, one is from Adobe and the other is open-source.  Flex targets the creation of applications rather than animations.  Since Flex is built on Flash, I tend to say ‘Flash’ when I (also) mean Flex. For a better explanation of the differences between Flash, Flex, and others, this article is very good: http://www.scottklarr.com/topic/39/adobe-air-vs-flash-vs-flex-vs-microsoft-silverlight/

Flash is well-suited for Internet applications and especially games, but seemed to be a good platform for data visualization and even user interfaces across the Net because it is designed around easy access to graphics rendering as well as distribution within websites.  Unlike Microsoft Silverlight, which serves a similar purpose, Flash is well-established, has a large community following, and has open source options.  Silverlight is definitely getting better and may surpass Flash in some technical aspects, but I chose Flash because it is more established, and Flash applications work well in Firefox, IE, and other browsers. Files with the FLA suffix are working files for Flash movies.  They can be produced by the Flash editor (Flash CS4, etc.  CS, by the way, stands for "Creative Suite" and seems to be a title which ties the core Adobe software together).  Flash movies can be written in ActionScript, or MXML (an XML-based markup language), or typically some combination of the two – ActionScript can be embedded within MXML, or various items such as buttons and text fields can be created directly through MXML. 

FlashDevelop is an Integrated Development Environment (IDE) which can create Flash movies and animations, and which I find useful and will talk about in the next section of this article. Once compiled a SWF (ShockWave Flash) file is created.  This is the end-user-visible, animation prone, Internet-ready file, and SWF files are played by the Flash player, either in stand-alone mode or typically within a web browser. In my project I needed a way of getting data from a database, and discovered what is called ‘AMF Remoting‘ or Remote Procedure Call (RPC) to tie Flash together with PHP, so that I could use PHP as a middle-man script to access an MSSQL database. AMF stands for ‘ActionScript Message Format,’ (see http://osflash.org/documentation/amf for a better description).  What it does is serialize Flash objects and send them along a network as a binary datastream, to be turned back into objects at the receiving end.  Compressing everything as a binary stream makes it a very efficient method for transport, and while AMF was originally a proprietary format (used by Flash and ColdFusion, another development platform which I don’t cover here), it has since been opened up and can be used in conjunction with ASP, PHP, and more.  So in other words, an object floating around in Flash can be squeezed into binary data, sent to a PHP script which receives it and translates it into an object in PHP and which can then be used within PHP.  The process works vice-versa too, of course.  Have a look at http://theflashblog.com/?p=414 for a good beginning explanation of AMF and more.

It is important to note that a Flash application has no knowledge of ‘who’ it is sending AMF information to or getting it from.  Objects are serialized with AMF0 or AMF3 encoding (AMF3 coincides with the release of ActionScript 3), then sent along to a receiving service of some sort.  Since I prefer usable platforms which are free and/or open source, I found AMFPHP and have had good luck with it.  AMFPHP creates native PHP objects out of the data (or tries to), and regular PHP scripts can then use those objects and do all the things that PHP does well, such as access databases and so-on.  AMFPHP can also send data back to Flash, which Flash receives and handles as an event, and can re-form the data into its own native objects as well.

An Environment Which Works for Me

I’ve already described most of the pieces necessary for the environment that I like using.  The main component which makes Flash programming rewarding is FlashDevelop. 

FlashDevelop

(FD) is an amazing free and open source IDE for writing ActionScript and Flex applications for Flash.  It will work alongside the Flash IDE for doing the programming behind the objects drawn in Flash and saved within a FLA file, or you can use it stand-alone as I do, and use fancier programming to create and position the objects within code.  FD works with .Net, and there is only a Windows version available.

Setting Up the Environment

So let’s get started actually putting all of the pieces together!

The Flash Player Itself

Well of course, in order to do anything with Flash, you need the player to play it….  I really only bring it up because Adobe actually offers a special debugger version of their player that could be quite useful.  I actually haven’t used it (FlashDevelop and a lot of trace statements have been enough so far), so I can’t say much about it, but I imagine if I spent some time on it, it would be invaluable for larger projects than what I need to do.  One minor point I should bring up, is that not all Flash movies out there are perfect…so with the debugger version you might get some annoying pop-up dialogs telling you in which way those movies are flawed, even if they don’t outright crash.

The download site is below.  Scroll down for debugger versions.  Choose carefully!  There are browser plug-in, standalone, and various other versions for different operating systems and browsers.  One nice thing is that you can have the stand-alone version running alongside the browser version, though.  It does no harm to install one on top of the other, except if I remember right it might complain when installing an old version on a new one.
http://www.adobe.com/support/flashplayer/downloads.html

Flex SDK

To compile anything with FD, you also need the Flex SDK:
Flex 3
Flex 4

You can check this ‘broken’ link in case a Flex 5 comes out before I edit this article…
http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex

At the time I’m writing this, Flex is up to version 4 as beta, so I would recommend the latest 3.4 release.  Flash player is at version 10 and may require Flex 4; check this out if you plan on programming for it.  Adobe’s download pages are confusing, if you search for Flex download, it seems you may pull up pages which link only to Adobe Flex, or the one I’ve linked to which also has the open source version, plus closed-source libraries to add into the open source version which gets it to the full closed source functionality…  It’s up to you what you want to do, but I suggest spending a few minutes poking around there to get a better understanding.  You can install the package upon download now, or wait until you have everything else you need, as is described next:

FlashDevelop

Download FD from the site:
http://www.flashdevelop.org/

Releases for download are listed in the Download forum thread.  When I first tried to get going, the installation was tricky for lack of understanding the different components.  Someone on the FD site was nice enough to post these directions for installing FD to me:

1. Make sure .NET is installed (it usually is)
2. Make sure Java is installed (it often is)
3. Download and extract the Flex SDK (latest milestone release is best)
4. Install the browser plugins from the Flex SDK’s runtimes directory
5. Run the external player (or associate if necessary) the external player in the runtime directory
6. Download and install FlashDevelop (I prefer the latest development version)
7. Configure the path to the Flex SDK and the external Flash player if necessary
8. Restart Windows (usually not necessary, but sometimes it helps)

In our case there is also:
9. Install and configure AMFPHP on a proper PHP server

AMFPHP

As described earlier, AMFPHP is a free, open source PHP service for handling AMF Remoting.  This enables the benefits of programming in both PHP and Actionscript using AutoComplete (code completion) in environments which support it, since you can work with the objects directly.  Binary serialization is also very fast, and AMF requires far less coding than previous methods of sending data to/from Flash (i.e., outdated methods such as wrapping data up into XML and sending that along, or using GET/POST methods with arrays).

Get AMFPHP here:
http://www.amfphp.org/

Setting it up AMFPHP is very easy (unzip it to the wwwroot directory and set permissions so it can be used); while using it may at first be a bit tricky.  Code you create for remoting will reside in the amfphp/services directory.  Base objects (as sent/received via AMF) belong in the amfphp/services/vo directory (VO stands for Value Object, and it seems the term has been replaced with ‘Data Transfer Object,’ or DTO)  VOs, reside under directories which match the package within Flash (PHP doesn’t natively support packages, but it can be emulated by PHP code).  Additionally, services can be tested to some degree using amfphp/gateway.php. 

At this time, do some searching to find sample remoting code to get yourself going on the coding end.  Eventually I may post a brief sample to illustrate using it.  This article may help:
http://www.joshuaostrom.com/2008/07/01/amfphp-class-mapping-primer-19-beta/

PHP Editing

For editing PHP files, I highly recommend PDT; PHP tools for Eclipse:
http://www.eclipse.org/pdt/

That’s a completely different tutorial and there are plenty of sites which can describe using it.  I like it because it is free and open source, and it works great for managing PHP projects, and it has excellent code completion for PHP.

Debugging

This guide wouldn’t be complete without mentioning debugging.  There are inherent challenges when doing something like Remoting, which make coding for it a bit precarious.  Finding the issues with a large amount of code or when new at the technique can be particularly difficult, and this is where a good debugging proxy can come in.  Specifically, Charles and ServiceCapture are two which can see remoting VOs and their data directly.  They essentially work by intercepting data sent down a network connection and displaying it in some human-readable format.

Charles was recommended by the AMFPHP website (if I remember correctly), and ServiceCapture was recommended directly to me, but there are others, some free and/or open source.  See, for example:
http://www.carehart.org/blog/client/index.cfm/2006/11/28/alternative_http_debugging_proxies

 

Conclusion

Hopefully this run-through is as useful to you as it would have been to me when starting up!  Good luck in your Flash Remoting endeavours.

Here are a few additional resources:

FlashDevelop help forums:
http://www.flashdevelop.org/community/

Another Getting Started article:
http://www.senocular.com/flash/tutorials/as3withmxmlc/

Flex code coloring schemes for FlashDevelop:
http://www.flashdevelop.org/community/viewtopic.php?f=10&t=2573
http://flashdevelop.org/community/viewtopic.php?t=2860

Posted in Article, Computers, How-To, Programming, Projects, Work. Tagged with , , , , , , , , .

A philosophy of philosophy

I started reading this book, "How to build a mind" by Igor Aleksander – a somewhat outdated book on so-called artificially intelligent systems, and systems which model thought processes similar to animals and humans.  The book touches on thoughts of what it means to "be conscious," among other things.  It seems the majority of the first chapters are about philosophical aspects of brain-building from "hardware" as built by humans, and while I had grabbed it from the library thinking it would be more about the actual physical side of things, so far it has been interesting if not a little light reading (well, quick at least, I’ve been over these sorts of thought-games before from such excellent books as "The Mind’s I").

That’s more intro than I had intended.  What I want to bring up is how apologetic Igor has so far seemed to be in how he deals with the naysayers for one, but more so with the matter of the philosophers who came before him – specifically, the many thousands of years of philosophical ideas which have been developed before him on the topic of "consciousness," as loose a word as that is, beyond probably the level of thought which I (nor he, likely) could hope to comprehend in some reasonable amount of time spent thinking.  So there are many schools of thought on the nature of consciousness, from that it stems from the physical structure of the brain, to it being some part of an ethereal soul, e.g., and so on.  Philosophers do not even agree amongst themselves on its nature, or better, how to tell if some thing has the property of "consciousness."

I’m not intending to jump in and debate this topic of mind.  It is there to illustrate a feeling about philosophy which I’ve felt building up in my head.  It appears to me that philosophy per se, in such topics as brain-building, where engineers and scientists can possibly build a physical model, is parallel in many ways to the type of thinking which theoretical scientists do.

It is a simple idea but I want to be clear about what I am getting at.  Since I’ve been through some amount of physics, I will use that as an example:  There are theoretical physicists, and there are experimental physicists.  It is typical that one spends their days drawing pictures while mapping out equations and programming computers to solve them, while the other plugs together electronics and computer systems with vacuum chambers and chemicals.  Never mind the often amusing banter and quarrel between the two about which of these disciplines is "better," it isn’t often that you get a physicist who is smack in the middle; there is usually a preference for building systems which take real-world data, vs. pushing the understanding and mathematics behind how the physical systems work.  When you do get a thorough mix between theorist and experimentalist, I have a feeling it makes for an astounding physicist, and it seems to me that Feynman was one of these, despite his claims of being a theorist.

To put it explicitly, theoretical physicists are every bit as important as experimental physicists.  Theories are necessary for experimentalists to know what to look for, and how to look for it – while experimental data is necessary in order to distinguish which theorist is closer to the truth and which one is truly off his rocker after all.  One side can push the other can push the other…  that is the way it is supposed to work; a dialog, like all science should be.  Now I do have a preference for the experimental side of things, because for one, when I set to learning about physics, I wanted to learn about the real world, what is true about it.  Theoretical physics is all in the brain, as is philosophy, and the seemingly best theoretical description of something is useless to describe the real world, if in fact the experiments show that it does not work that way.  Perhaps it can be altered to match the real world at best, or prove a good model within some limits (as Newtons equations do until relativity takes over).  I should note that there is a difference between theory, model, and experiment, and modeling does not relate enough to this article to spend time talking about it now.

In any case, that brings me to the point.  My philosophy on philosophy, at least as it relates to for instance the study of consciousness, is that it should be treated much like theories in science. Philosophical theories may certainly be interesting to think about, whether they are true or obviously not (like ancient Greek theories of gravity).  And for a long time I felt that that was just about the only use to it.  In fact I must admit that I still feel this way about certain people I’ve met in the field.  But like scientific hypotheses, philosophical arguments might just be able to point to answers to very real and very worthwhile things.  There may be those philosophies and philosophers who remain so far removed from reality as it applies to building a brain, but in this sense, philosophy can very well provide engineers and scientists with important questions to work on; and those same engineers and scientists can produce conundrums in philosophy (and ethics!) which we simply have not faced before in human history.

To lay out some examples:  It is a tough philosophical question of how one should live.  Does one follow the saying, "tit for tat," or is there another, better method?  Arguments can be made to justify just about any method of living.  It turns out that the field of game theory has come to show that "tit for two tats" tends to give better results in the long run.  There are certainly exceptions and I am not about to treat this scientifically enough to delve into it and provide sources; it is simply better for a group’s survival and so also an individuals’ to follow this model.  Being too much of a pushover is not advantageous, nor is being incredibly unforgiving.  So in this case a philosophical debate has been worked through by physical (or computed) models.  Like theoretical physical models, some philosophies were closer to the truth than others.  It is not worthwhile to be apologetic to those philosophies which got booted out, it is as useless as it is to cater to the theories which have been shown to be untrue.  Not that we should now start ignoring them completely; for one there is always a chance that the experiment had been wrong somehow, or perhaps does not actually apply to the theory/philosophy as it was first assumed.  For two it is dangerous to throw things out without a second look, in terms of advancing science.  There are many examples of the person with the correct theory being ridiculed and ignored before the science finally caught up and proved them out.  And then there is the practice of properly documenting things; why the theory is believed to be untrue, and so on.  If it only to make for good history, or it may prevent others from thinking to hard about something which has already been laid out.

A second example is how science has pushed philosophical questions. Professor Vladimir Chaloupka at the University of Washington has an excellent inter-disciplinary course outlining how this is so.  One such discussion is that, while many (especially including those in charge of large countries) may feel that war is a valid recourse or even first course against some wrong, never before have we had in our hands the ability to literally destroy all of human life on this planet.  With that, the philosophical question of how one should lead their life may deserve a thorough revisit…

This is about as far as I’ve come in my reasoning.  I’m sure this has been thought out before; I still dislike seeing the treatment of philosophy as if it is some ultimate grand thing, beyond the common person, when it has raised more questions than it has answered, and hasn’t exactly solved the world’s problems.  I’ll end by saying that, in this respect, science has done exactly the same!


 Buy it from me on amazon!

Posted in Article, Physics. Tagged with , , , , .

Hamsters!

 

Hamsters caught my attention when a friend showed me this picture:

from the site:

http://www.novaksblog.com/2007/08/26/stumble-on-sunday-3rd-part/

And in a search to find out just how much hamsters can really stuff into their pouches I came across these irresistibly cute videos:

Hamster!
http://www.youtube.com/watch?v=rfqNXADl3kU


http://www.youtube.com/watch?v=P-l-jshNYkA

So then my brother purchased one for me for Christmas.  She’s quite cute and usually entertaining, at least when she isn’t preoccupied with being ornery and/or escaping from her cage.

My cat hardly seems to notice her unless, for instance, she is climbing on her back.  This usually makes my cat angry, but only if she sees the hamster in action and so knows what it is back there digging claws into her side.  Or perhaps it is humiliating to have food items nest on one’s self.

 

Posted in Humor, Random, Short Post.

Kasou Taishou

Kasou Taishou (In hiragana that would be かそうたいしょう, but see the footnote*…) has become one of my favorite Japanese shows.  It has been around Japanese television for quite a few years, and  I came across it while looking for videos where I could hear Japanese being spoken on YouTube, and there are many episodes on there now.  The premise is that it is a gameshow in which anyone can enter.  Contestants use costume and props in order to enact a scene of some sort, from every day things to imaginary situations; but the show format encourages a great amount of creativity in presentation, especially in visual ‘effects’ which might be easy to do with video editing but are in most cases quite elaborate when done ‘live’ in front of the small studio audience.  So for instance a character might float in the air by means of being held up by people dressed in black who blend into the background (sometimes referred to as ‘ninjas’).

There is a panel of judges who dish out points based on how good they think the skit was.  They seem to be quite generous and the point system does not seem to mean much – so long as they get over 14 points they are given a medal by a Japanese woman dressed as a bunny…There are reasons I have a soft spot for Japan, you know…

The show really needs to be seen to understood.  If you are fluent in Japanese or able to figure out how to click on the links, the television station website for it is at:
http://www.ntv.co.jp/kasoh/past/index.html

Below are just a few of the skits that really stood out to me, but I could list plenty more!

 

Conductor Orangutan

Japanese Talent Show : Scuba Diving

Hot!

Cursed Room

 Conductor Orangutan  Scuba  Hot!  Cursed Room
       

Mogul Skiing

Chameleon

All Messed Up

Japanese Talent Show : Baseball World Record

 Mogul Skiing  Chameleon  All Messed Up  Baseball World Record
       

Olympic Games Highlights

     
 Olympic Games Highlights      
       

 

* I’m very new to writing out Japanese, and the hiragana above doesn’t seem to pull up proper search engine results. It means something like, "masquerade prize" with the kanji choices 仮装 and 大賞 and a lot of help from the awesome translation site http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi . Apparently my choice of kanji is close, given the Japanese from Wikipedia: "欽ちゃん and 香取慎吾の全日本仮装大賞; Kinchan and Katori Shingo’s All Japan Costume Grand Prix"

Posted in Humor, Japan, Random. Tagged with , .

Woodcarving

Woodcarving has been a hobby of mine since discovering that I could do it a number of years ago.  It is one of the rare things that came naturally to me; most of my other hobbies have taken years of work to get to any decent level of skill.  Most of my carvings end up as gifts for friends or family, although I am thinking more and more about making some to sell.

 Abstract
This is the first carving I made, and I titled it "Abstract."  It has a loose ball on the bottom corner, and a suspended ball in a cage, held by an arm of wood on the side.  I was very fortunate to find this piece of driftwood when I started, as it was very easy to carve and has a wonderful color and texture.  This piece is fragile, and has gotten dropped and so has a few parts which have been glued back together.

 On the Verge of Something
This one is titled "On the Verge of Something," because as I was carving it I kept feeling that it was going to become something else…yet it never quite got there.

Twist - Woodcarving
"Twist" is the title I gave to this piece.  There is a loose ball contained at the top.

Posted in Art, Projects.

Scientific Proof of the Flying Spaghetti Monster!

Indeed His Great and Tasty Noodliness exists, and our lab was blessed with His appearance during a bake-out of the vacuum chambers.  We have yet to encounter Real Pirates, but assume that our lab’s collective adherence to the observance and recognition of International Talk Like A Pirate Day has not gone without notice by His Tomato-Sauciness. 

FSM sighting!

Indeed in these rare photographs one can see clearly His Noodly Appendages reaching out from under the foil wrapping as if to touch fellow Pastafarians with His Slimy Tomato Sauce. 

Another view of the FSM

Posted in Experiment, Humor, Short Post. Tagged with , , , , .

Homebuilt laser!

Back to Ultracold Atomic Experiment


Of all the cool projects I’ve been involved in during my school career through my Physics career, I’ve got to say that getting to build a custom laser is the one I’m going to have the most fun talking about.  Not that it is the most interesting project ever…but come on, a home-built laser!  It should be a requirement for getting a Physics degree.

The laser light itself is supplied by a laser diode, this one is actually a commercial one used in DVD reader/recorder units.  The experiment requires the use of light locked to a 671nm wavelength, but this is not in the range of commonly available commercial lasers.  Laser diodes actually emit a range of frequencies around a central frequency, which can be shifted by heat and also stimulation of a particular frequency.  In fact by shining light at precisely the desired wavelength of light back onto the diode, this increases the diode’s emission at that one frequency, and can narrow the amount of light emitted at other frequencies.

The trick we will use in achieving a 671nm wavelength is to use a Littrow-mount feedback system.  Light from the laser is shined onto a diffraction grating, which reflects most of the light.  A small amount of light is reflected at precise angles based on its wavelength, (as is expected from the physics of diffraction gratings), and the grating’s first-order reflection is made to reflect back onto the laser diode.  By changing the orientation of the grating, a particular wavelength can be made to shine back onto the diode (again, this is explained by the basic science of diffraction gratings – like a shiny CD, wavelengths hitting a grating are reflected at angles proportional to their wavelength), and so select the desired wavelength to stimulate in the diode.

The zeroth-order reflection (essentially the mirror reflection off of the grating) is reflected from a mirror, then out parallel to the original beam path.  The grating and mirror are mounted as a unit on a swing-arm in front of the diode laser, so that rotation of the mirror/grating unit can be achieved by a piezo-electric unit.  This allows the first-order reflection to be locked onto the laser, while not (largely) affecting the attitude of the outgoing beam.

The parts I have made were all from plans which the professor in charge of the Ultracold Atoms Experiment obtained through a group he had worked with at Berkeley.  So producing the whole system was quite straight-forward and took about a week of actual work in total, once all the parts were together.

Bare laser mount

In the picture above, the diode mount is a modified lens mount with aluminum blocks attached to the front end (the laser emits to the left of the photo).  The aluminum block with an angled cut and Allen screws on top will hold the diffraction grating, and the aluminum bar it sits on holds the mirror, as seen below:

Laser, Grating, and Mirror

The laser diode itself is behind the bluish collimating lens, which can be adjusted by turning the threaded steel ring around it.  The black cylinder around this is a commercial diode mount, with a layer of "thermal goop" between it and a modified mounting unit, with more goop between it and the modified lens mount.  The thermal paste helps heat get to the laser diode efficiently.

Down the front of the laser

Laser and Base

The unit as seen above sandwiches a thermoelectric cooler (TEC, also known as a Peltier device), which acts as a "heat pump" when current is applied to it, by moving heat from one side of its body to the other (the red and black wires attach to it).  This is all attached to a massive (about 7-8 lbs.) brass block, and its mass and a rubber sheet below it help to dampen vibrations which might make their way through the optics table.  Everything sits inside a housing box, which is lined with Acoustiblock material to keep out sound vibrations traveling over the table.


Back to Ultracold Atomic Experiment

Posted in Experiment, Physics, Projects, Work.

Shoot First, Alien Autopsy Second

This news article struck me as funny:

http://www.telegraph.co.uk/news/newstopics/onthefrontline/4342884/RAF-ordered-to-shoot-down-UFOs.html

Posted in News, Short Post.

Key Fob Hassle

 

I have a Hyundai with a key fob which locks the door with one click and sets the alarm with another.  The alarm is in fact nearly useless, as it does not go off when the car is bumped or anything, nor would it be set by a broken window, but it does go off when I open the door.  I mean with the key of course, since the door was locked to begin with.

Not only this, but while annoying the heck out of all persons nearby, there is nothing I can do to shut the damned thing off, except for some magic combination of buttons on the key fob which I have not completely figured out yet, and which seems to work only 5 seconds after pushing it.  Oh, and beyond this there is the ignition which will not allow accessories nor engine to be turned on with the key.

I can however open the door with the key, crawl in the car with the alarm blaring, shut the door behind me and wait until three or four cycles of the alarm finish, at which point it will stop because the door is shut.  I can do anything I want when in the car, save for start the engine and go anywhere.  Once the door opens again the alarm trips afresh, of course.

I think this design is not only obnoxious, but it could be worse.  For one, it recently forced me to stay a few extra days at my parents’ place when I lost the key fob, yet still had the key in possession.  Fortunately they had the spare fob as we found later, but I can easily imagine a scenario of someone absolutely needing to drive away at that moment, but with only a key in hand they cannot.  I’ve looked everywhere for ways to manually override the thing – a few websites mentioned things like turning the ignition to accessory, off, and back on with certain amounts of waiting at each position.  One website had the thought that there would be a valet override switch under the dashboard which could be used to silence and subsequently reset the alarm.  But neither seem to be the case for my car.  Nope, and the Hyundai dealer service department was adamant that it was a ’safety feature’ and there was no way to disable or override it – but of course I could avoid using the key fob if I did not like it (?!).  Ridiculous.

At $80 for a spare fob, it seems that the biggest reason to do this is to make a little money in selling more key fobs.  Bah!  The only thing I can understand is that it makes the car more difficult to steal outright, but I am sure somebody willing to steal the car would prepare with enough knowledge of the electronics panel to do it regardless.  I just want to know how to get that knowledge myself, so I don’t face the same situation again.  Please leave a comment if you know how to override this thing, I think it is knowledge that anyone who owns one of these cars should have.

On the topic, I hear one can purchase a fob for a Hyundai car for cheap on eBay, and then take the car into the dealer, who will set the car’s system to recognize the new fob’s code, for free.  Only two fob signals can be recognized by the alarm system at once, but you can purchase other fobs having the same code from the dealer.

Posted in Bad Engineering, Car, Pet Peeve, Random, Short Post.

Falafel King II

This little restaurant either changed owners or just food and name, and is now serves Greek food.

I’ve been once and had the Veggie Plate, a sampler of common vegetarian Greek items.  The dinner plates there are priced on the higher end of cheap food ($8.99 for the plate meals, and there are cheaper options), but they come with a large plate full of food, Greek salad or soup, and a pita.

The staff was friendly, I believe they are not Greek (someone suggested ethiopian?), but they had accents and were very concerned whether we enjoyed the meal.  One person I was with is a joker about not liking the food, but the waitress didn’t know whether he was joking or not.

My plate was absolutely delicious!  There were two dolmades (I could taste grape flavor in the grape leaves), two falafel (fried with a thick crunchy shell – I haven’t had them like that but they were really good), mounds of hummus and baba ghanoush, and various leafy greens with a really good Greek dressing over them all.  Food to savor!

I am definitely going back!

Posted in Restaurant, Review.

DIY DNA

I really enjoy hearing about groups of people who take the pursuit of knowledge into their own hands and build or create crazy projects.  That’s why I was excited to hear about people with home-built biology labs in their homes, in this article: http://www.newscientist.com/article/mg20126881.400-rise-of-the-garage-genome-hackers.html?page=2 The article links to this site, which talks about some current projects and has resources for getting together with a local group: http://diybio.org/

Posted in Miscellaneous.

Ultracold Atomic Experiments

I have been working for some time with an Ultracold Atomic Experiment group at the University of Washington.  This has been one of my more enjoyable jobs, and has kept me busy machining parts, soldering together circuits, building lasers, taking pictures, and all sorts of other fun things.  The entire series of chambers is pulled to a very pristine vacuum – around 1E-10 torr or better.   Achieving such a good vacuum is a very involved and interesting process.  One of the steps is to heat the chamber walls to release embedded atoms so they can be pumped out; Below is a picture of the chamber wrapped in band heaters and other heating elements, which are each supplied power by one of the many variacs seen floating around the chamber.

Variacs!

The experiment will be trapping Lithium (Li) and Ytterbium (Yb) atoms, which get boiled off from separate ovens, slowed through Zeeman slowers, and combined into the central Magneto-Optical Trap, where they are further cooled by evaporative cooling until finally cold enough to settle into the lowest energy quantum state as a Bose-Einstein Condensate (BEC).  The projects I am or have been involved with include:

  • Create or Update Documentation for most projects
  • Data Acquisition Software and Hardware
    • Working with National Instruments Hardware and Software (interfaces with break-out boxes listed below)
    • Interfacing with Atticus/Cicero control software developed by a group at MIT
    • Digital Camera
      • Research and set-up of camera
      • Programming of User Interface
  • Construction of Electronics and Other Hardware
    • Diode Laser Lock Boxes
    • Lithium and Ytterbium Oven Control Units (Torture Units Li and Yb…)
    • 12 and 40 amp MOSFET switch boxes (BFW Housing Boxes)
    • Analog and Digital Isolation Break-Out Boxes
    • Enhancement Cavity Mode Lock Box
    • RF Driver boxes
    • 671nm Littrow-configuration laser
  • Create website for group
  • Take Photographs of experiment and lab
  • General Tasks
    • Troubleshoot/testing of various lab hardware and circuits
    • Organizing and maintaining electronics and other areas of lab (Research and purchase electronics parts)
    • Creating and now maintaining shared computer file system, software, and datasheets
  • Unicycle to Electronics Shop and back

Posted in Experiment, Physics, Projects, Work.

Company List for Motion Control Parts

 Back to Motion Control home


A short list of companies from which to purchase parts for motion control.

Digi-Key:
www.digikey.com
A very large assortment of electronics.  Their site, however, is entirely text-based–so if you know what your part looks like but don’t know what it’s called, this is a tough place to find it!  They do have links to pages of their catalog in PDF format–a really inefficient way to search for parts…

Jameco:
www.jameco.com
Nice selection of parts, and a nice-looking Internet store.  Good search engine, nice product pics, and low prices.  The site was very slow at one time.  WATCH OUT–items are priced by the part, but Jameco sometimes doesn’t sell individuals–it’ll say ’sold in quantities of XX’.

Alltronics:
www.alltronics.com
Specializes in purchasing and reselling surplus electronics and gadgets. Their prices are very low, and while they have a decent picture and description for pretty much everything they sell, I can’t say their site is altogether easy on the eye. What’s nice though is that basically the entire site-map is in the index on the left side of their site, which is also searchable.  They tend to have lot of unique items that come and go.  The best part about Alltronics is how they charge for shipping–they actually weigh your order and then charge only the exact amount.  $15-order minimum.

Newark:
www.newark.com
Very nice-looking site.  No actual pictures of items, but many items have (extremely small) illustrations or documentation in PDF format.

Radio Shack:
www.radioshack.com
Highly overpriced, and their stock in most electronic components is dwindling (at least in my area).  Buy here only if you need a local place to go, if you need low quantities of a (common) part right away, or if you need something at some odd day of the week.

Allegro:

The manufacturer of the UCN 5804 chips.


Groups:

FIRST
Seattle Robotics Society


Misc:

eBay:

Search under "step* motor." Smaller steppers (Nema 17 and 23–the 5804 can’t handle larger) should be available for <$5.

 

 

Posted in Article, How-To, Projects. Tagged with , , .

Parts list for beginning motion control

 Back to Motion Control home.


This list was compiled quite a few years ago in conjunction with and for Bruce Shapiro and his course, ‘From Bits, to Bytes…to Bots‘.

It is intended to aid in finding all of the right parts quickly and cheaply, through each phase of learning control via a computer parallel port.

How much will you spend? Depending on how good you are at scrounging, plan on at least $30, though if you’re stocking up on decent motors it may be closer to $80!


The_Parallel_Cable
LEDs
Resistors
The Chips

The Motors
MISC


Who are we ‘promoting’?
A list of companies listed here, and a few organizations.


The Parallel Cable:
www.digikey.com
www.jameco.com
Needed to interface the circuit to the printer port. Unfortunately, no ready-made male 25-pin to 26-pin socket exists (that I know of). You may be able to order them custom-made, or make them yourself using parts
from Digikey or Jameco:

PARTS: JAMECO $ DIGIKEY $
 
25 pin IDC D-sub male connector 12335 1.89 ? ?
26 pin IDC socket connector 138333 0.42 ? ?
25 conductor flat cable 105697 6.29  (10 Ft) ? ?

Bruce says:
"The press-fit connectors are easy to use, but take some practice. Make sure you check the alignment BEFORE pressing the two halves slowly in a vice."

top


LEDs:
www.alltronics.com
Individual LEDs are probably the easiest to find part. These are cheap and usually run at 1.5, 3, or 5 volts. Too much voltage can pop them, so careful!

The bar graph LED is a little more difficult to find.  I got one for just over $3 at Radio Shack (the only part they had that I needed…)  I know Alltronics sells them, but am not sure the catalog number…

PARTS: ALLTRONICS $ DIGIKEY $
 
10-digit Bar Graph LED ? ? ? ?

top



Resistors:
www.jameco.com
www.digikey.com

Resistors are actually easier to come across than LEDs, but finding the right one is sometimes a task.  In order to protect the parallel port while plugging wires into it, we suggest using a very high resistor value–up to 1K.

Bruce writes:
"…the resistor value I use is 1K.  This limits the current through the LED’s to <5ma, which can be kind of dim– but I wanted to make sure that I wasn’t straining the output capabilities of the port.  So far, I’ve used many tens of laptops, and have never had a problem with a parallel port.

The SIP resistor network is carried by Digikey and Jameco  — Jameco #97877.  Just remember to place it with the common lead connected in the right spot (grounded)."

If you are not sure how to read resistor color bands, there is a little tutorial here.

Single Resistors
Any place that sells electronics components will have

SIP (Single In-line Resistors

PARTS: JAMECO $ DIGIKEY $
 
SIP resistor network 97877 2.60 (10) ? ?

top


The Chip(s):
www.alltronics.com
www.newark.com

PARTS: Alltronics $ Newark $
 
UCN5804B 93I002 4.50 09F1557 4.50

top


The Motors:

www.alltronics.com
www.newark.com
www.ebay.com

NOTE:
Currently Alltronic’s site has the amperage for their 6-wire unipolar stepper (22M010) wrong. It claims 0.35 V, but the motor actually requires 1.35 V.

Bruce writes:
"The power supply needs to give 5V for the 5805 chip, and the voltage of your stepper (12V in my case). You can use a single 12V supply, and then use a 5V regulator (7805, or 78L05) to get the 5V. The 5804 chip can handle up to ~35V (check this) and ~1.2 amps / phase). Your motor will have to stay within these bounds. Unipolar means that electricity flows through the motor’s windings in only one direction. 5, 6, and 8 lead motors will allow this configuration. Check out one of the many stepper motor tutorials on the net to understand this. Bipolar drives result in more power, but require more electronic sophistication. I have not found a single chip like the 5804 that will take step and direction signals and output directly to a bipolar (4-wire) motor.

"One source for a stepper to use can be found in old floppy drives. The key features are: 5,6,or 8 wires; rated voltage <35, and rated amperage <1.2. Jameco lists a few, but the ones they have that are <$10 are ‘coarse’ — meaning they have a step angle of 7.5 degrees. These will work– but I like really smooth motion (look for 200 steps/rev or 1.8 degrees).

You may have to scrounge for the ‘perfect’ one of these!"

top


MISC:
Still looking for resources regarding power supplies, and a way to connect one to a breadboard.

top


Good luck in your motion control endeavors!

 

Posted in How-To, Projects. Tagged with , , .

Getting Started With Motion Control

Motion Control

Companies

Parts

Outer Links:

http://www.taomc.com/

http://www.taomc.com/bits2bots/

Posted in Article, Projects. Tagged with , .

Michelson Interferometer – Part 2

This is the portion of my physics group project report that I wrote.

Interferometer Page 1


Measuring Static Frictional Forces using Interferometry

Interferometer Setup
Fig. 1:  Interferometer Setup and Labels
Fringes from Michelson Interferometer
Fig. 2:  Interferometer Fringes

Introduction

It is often not understood that even when dealing with static friction, application of less-than-critical sheering forces (that is, forces which do not cause breaking of static friction) creates an actual displacement between an object and the surface it rests on. The amount of movement is typically very small and barely if at all visible (displacement can be large enough to be seen when, for example, the surface is a rubber mat). When the sheering force is let off, static friction becomes a restoring force, returning the objects to its original position respective to the surface. This restoring force can be thought of as spring tension, and in this thinking ought to be proportional to object displacement.

This experiment sought to verify the linear F = k x relationship of static frictional forces between various materials at less-than-critical sheering forces. Very precise measurements of displacement were measured using a Michelson-type interferometer. The results showed a definite linear relationship between applied force and displacement of the test object for Styrofoam and particleboard surfaces.

Procedure

The first goal achieved was forming the ‘fringing’ patterns with the interferometer. The basic setup follows the Michelson interferometer design.

As shown in Fig. 1 , the beam emitted by the Laser (while a laser pointer is shown, a HeNe laser was used for actual collection of data) passed through one or two Lenses . The Lenses simply made the laser beam diverge and created a larger beam for viewing. The beam then hit the Beam Splitter , separating into two partial beams. Each partial beam bounced from a mirror back onto the beam splitter so that they overlapped and projected as a spot of light on a viewing surface (in the direction of the sheet of paper in Fig. 1). The Reference Mirror held a fixed position and created a reference beam. The Test Mirror was attached to a movable Test Block , and the surface under the block could be changed.

More difficult was developing the apparatus to precisely add and measure sheer force to the Test Mirror. The resulting design is shown in Fig. 3 (NOTE–Figure 3 isn’t here yet). The end of a Fishing Line was attached to a hook on back of the Test Block . The Line passed through the two Static Pulleys and terminated at the Force Probe . The Moveable Pulley could then be pushed into the Fishing Line, causing a Tension felt equally by both the Force Probe and Test Block. It should be noted that the Test Block and Force Probe were adjusted carefully so that they were directly aligned with the Fishing Line. In this way, the Pulley system ensured that only the desired vector component of force was applied to the Probe and Block.  When everything was secured properly, this system worked remarkably well and tension could be applied and held fairly precisely by hand.

A computer captured data directly from the calibrated Force Probe. To take a data run, the apparatus was first adjusted so little or no force acted on the Test Mirror and Force Probe. The state (bright or dark) of the central dot (see Fig. 2) was noted, the force was captured and 0 was entered as the fringe number. The Moveable Pulley was then pushed into the Fishing Line until the central dot grew into a ring with its alternate state in the center. The force was again captured and entered as fringe # 1. For example, in Figure 2, the initial central dot is red. If tension were applied to the Test Block, it would grow into a ring with a dark spot in its center. The dark spot becomes the new central dot, and was counted as one fringe when it became the same size as the original bright spot.

This process was repeated for multiple surfaces, and for most runs it was verified that as tension was let off the same number of fringes disappeared as had previously appeared. For the final run of a surface, the attempt was made to capture data until holding the Moveable Pulley became too difficult or the static friction bonds were broken and the Test Mirror slid out of position.

Interferometer Page 1


 

Posted in Article, Experiment, How-To, Physics, Projects, Work. Tagged with , .

Michelson Interferometer Part 1

This article describes the physics project I was involved in.

Interferometer page 2


Interferometry: Measuring Displacement on a Molecular Level

Our project is to very precisely measure static frictional forces between various materials. The high precision comes in using a Michelson-type interferometer.

Interferometer Setup
Fig. 1:  Interferometer Setup and Labels
Fringes from Michelson Interferometer
Fig. 2:  Interferometer Fringes

An interferometer overlaps two beams of same-frequency laser light. This creates an interference pattern due to the wave nature of light (Fig. 2). A laser pointer is shown above (Fig. 1), which is replaced by a Helium-Neon laser for the actual experiment, in order to gain more significant digits for the wavelength. As shown, the beam is first passed through two lenses. The only purpose for this is to make the laser beam diverge and ultimately create a larger beam for viewing. After the lenses, the beam is split into two partial beams using a half-silvered mirror (a beam splitter). Each partial beam is bounced from a mirror back onto the beam splitter so that they overlap and project as a spot of light on a viewing surface (in the direction of the sheet of paper in Fig. 1). One mirror holds a fixed position and creates a reference beam. The other test mirror is attached to a movable block. The surface under the block can be changed, and a measured force can be applied to it. Static frictional forces act to hold the block in place, but not without allowing some movement. When the force is let off, the block returns to its original position as if held in place by springs.

The interference pattern formed has the appearance of tree rings, with alternately bright and dark circles. What we are interested in is the central ‘dot’ which may be initially bright or dark. When the test mirror is shifted forwards or backwards, the central dot will grow or shrink. Assuming the central dot was initially bright, as it grows it will turn into a ring and a dark dot will appear at its center. As this dark spot grows, it also turns into a ring with a bright spot at its center, this pattern alternating. As the test mirror is shifted back to its original position, the rings will converge into alternately colored central dots. The appearance of each alternate-color dot corresponds to the test mirror having shifted its position by a quarter-wavelength of light – that is, 1/4 of 632.8 nanometers for the Helium-Neon laser ultimately used. This is roughly just over 1,100 times the diameter of a carbon atom!

Interferometer page 2


 

Posted in Article, Physics, Projects. Tagged with , , .