Tuesday, October 28, 2014

DE0 and Assembly

Its been a while since the last post, but the future posts will definitely make up for that (be excited). As a small post, I can show you all something I've done for a class called Programming Digital Systems. PDS, as it is called, instructs on the architecture of embedded systems as well as the use of assembly as a language. Assembly is remarkably tedious, but very rewarding when functional. My future project, to be unveiled soon, will uses assembly exclusively.

Directional Arrow Scroll

/* John Dunn        */  
/* Oct, 28 2014        */
/*          */
/* This program goes through a series of screen states, then restarts. */
/* If PSHBTN1 or PSHBTN2 is presse the states are reversed.  */
/*          */
/* Register Usage:        */
/* - r5: Current State of Button after ldwio from r16   */
/* - r7: Delay Counter       */
/* - r8: Current State       */
/* - r9: State Counter (Starts at 8 and is checked for r9==0)  */
/* - r13: Direction indicator (0 is R2L, 1 is L2R)    */
/* - r14: Base Address of the current set of states (R2L or L2R)  */
/* - r15: HEX3_HEX0 Base Address      */
/* - r16: Pushbutton 1&2 Base Address     */

 .text
 .global _start
_start:
 movia r13, 0    /* Initially have go right to left. */ 
 movia  r14, R2L_STATES   
 movia  r15, 0x10000020 
 movia r16, 0x10000050   
     ldw  r8, 0(r14)   /* Load the STATE into r8. */
     addi  r9, r0, 8         /* Set our STATE counter to 8. */

CHECK_R2L_RESET:
 bne r13, r0, CHECK_L2R_RESET /* IF the Direction is L2R, GOTO CHECK_L2R_RESET. */
     beq  r9, r0, R2L_RESET    /* ELSE the Direction must be R2L. */
      /* See if the state counter is at 0. */
      /* If it is, GOTO R2L_RESET. */ 
 br DO_DISPLAY    
CHECK_L2R_RESET:
     beq  r9, r0, L2R_RESET    /* ELSE the Direction must be L2R. */
      /* See if the state counter is at 0. */
      /* If it is, GOTO L2R_RESET. */
 br DO_DISPLAY 

R2L_RESET:
     movia r14, R2L_STATES   /* Reset the State address back to */
      /* the base address for R2L_STATES. */
     ldw r8, 0(r14)   /* Load the first state into r8. */
     addi    r9, r0, 8   /* Reset the State Counter to 8. */
     br      DO_DISPLAY
L2R_RESET:
     movia r14, L2R_STATES   /* Reset the State address back to */
      /* the base address for L2R_STATES.*/
     ldw r8, 0(r14)   /* Load the first state into r8. */
 addi    r9, r0, 8   /* Reset the State Counter to 8. */
 br DO_DISPLAY

DO_DISPLAY:
 stwio r8, 0(r15)   /* Display the value in r8 */
     addi r14, r14, 4       /* Get address of next state*/
     ldwio r8, 0(r14)   /* Load the next state into r8*/
     subi r9, r9, 1         /* Decrement the state counter*/
 
 ldwio r5, 0(r16)   /* Load the current state of the Pushbuttons to r5. */ 
 beq r5, r0, NO_BUTTON  /* If a button isn't pressed, GOTO NO_BUTTON. */
 beq r13,r0,SET_DIR_L2R  /* If the Direction is R2L, GOTO SET_DIR_L2R. */

SET_DIR_R2L:
 addi r13,r0,0   /* Change r13 from 1 -> 0. */
 br L2R_R2L_SWITCH_RESET  
SET_DIR_L2R:
 addi  r13,r0,1   /* Change r13 from 0 -> 1. */
 br R2L_L2R_SWITCH_RESET

L2R_R2L_SWITCH_RESET:
 addi    r9, r0, 8   /* Reset the State Counter*/
     movia r14, R2L_STATES   /* Reset the State address back to the base address */
     ldw r8, 0(r14)   /* Load the first state into r8 */
 br WAIT
R2L_L2R_SWITCH_RESET:
 addi    r9, r0, 8   /* Reset the State Counter*/
     movia r14, L2R_STATES   /* Reset the State address back to the base address */
     ldw r8, 0(r14)   /* Load the first state into r8 */
 
WAIT:
 ldwio  r5, 0(r16)   /* Wait for the button to be released */
 bne r5, r0, WAIT

NO_BUTTON:
 movia r7, 250000   /* Here we will delay. */ 

DELAY: 
 subi r7, r7, 1
 bne r7, r0, DELAY
 br  CHECK_R2L_RESET:
 
 .data

R2L_STATES:  
 .word  0x00000079
 .word  0x00007949
 .word 0x00794949
 .word 0x79494940
 .word  0x49494000
 .word 0x49400000
 .word 0x40000000
 .word 0x00000000

L2R_STATES:
 .word  0x4F000000
 .word  0x494F0000
 .word 0x49494F00
 .word 0x4049494F
 .word  0x00404949
 .word 0x00004049
 .word 0x00000040
 .word 0x00000000
 .end

GOBUFFS Cheer Screen

/* John Dunn        */  
/* Oct, 28 2014        */
/*          */
/* This program goes through a series of screen states, then restarts. */
/*          */
/* Register Usage:        */
/* - r7: Delay Counter       */
/* - r8: Current State       */
/* - r9: State Counter (Starts at 23 and is tested for r9==0)  */
/* - r14: Base address of STATES      */
/* - r15: Base address of HEX3_HEX0     */

 .text
 .global _start
_start:

 movia  r14, STATES  
 movia  r15, 0x10000020 
     ldw  r8, 0(r14)   /* Load the STATE into r8. */
     addi  r9, r0, 23        /* Set our STATE counter to 23. */

DO_DISPLAY:
     beq  r9, r0, RESET     /* If we have finished all the states, GOTO RESET. */
 stwio r8, 0(r15)   /* Display the value in r8. */


     addi r14, r14, 4       /* Get address of next state. */
     ldw r8, 0(r14)   /* Load the next state into r8. */
     subi r9, r9, 1         /* Decrement the state counter. */

 movia r7, 500000   /* Here we will Delay. */ 
DELAY: 
 subi r7, r7, 1
 bne r7, r0, DELAY
 br  DO_DISPLAY
RESET:
     addi    r9, r0, 23   /* Reset the State Counter*/
     movia r14, STATES   /* Reset the State address back to the base address */
     ldw r8, 0(r14)   /* Load the first state into r8 */
     br      DO_DISPLAY

 .data
STATES:
 .word 0x00063000
 .word 0x00300600
 .word 0x06000030
 .word 0x30000006
 .word 0x303D3F06
 .word 0x00000000
 .word 0x303D3F06
 .word 0x00000000
 .word 0x0000007C
 .word 0x00007C3E
 .word 0x007C3E71
 .word 0x7C3E7171
 .word 0x3E71716D
 .word 0x71716D00
 .word 0x716D0000
 .word 0x6D000000
 .word 0x00000000
 .word 0x2908010D
 .word 0x30090906
 .word 0x1901080B
 .word 0x2908010D
 .word 0x30090906
 .word 0x1901080B
 .end
-John "Large Finite State Machines are Large" Dunn

Thursday, August 14, 2014

C++ Yahtzee Game

Second post in 1 day!

Wow, so many things to post, so little time! This time I'm going to be briefly explaining my final project for a summer class I took called Data Structures.

I've always been a fan of Yahtzee, since a kid my parents have engrained the full scorecard into my mind. Whether I'm in a pub or at a friends house, I still have the ability to write down a Yahtzee scorecard on nearly anything. So, when it came to doing a self created final project for a C++ Data Structures, I naturally jumped at the chance to emulate my favorite game. The purpose of the project was to create a program on your own design and do a complexity analysis. A complexity analysis is  simply a data representation of how a program performs if you increase the input size dramatically. For instance, in my Yahtzee program, I varied the number of players from 1 to 100, then counted the number of overall operations and operations of each statistically significant function. An operation counted as anything that accessed or changed a current data structure.

The backbone for this program are 4 main data structures. The first two structures are the most basic. They are structs called Dice and yahtStats. The Dice struct contains two arrays which are used to save and roll the dice.


struct Dice{
  array<int,5> dice;
  array<int,5> savedDice;
};


YahtStats contains most of the statistics involved with the program, including the number of operations. RollsPerNumber, which is an array of the yahtStats struct, is particularly interesting because it shows the distribution of each value of dice rolled over the course of the entire game.


struct yahtStats{
  int operations = 0;
  int autoPlay = 0;
  
  int mainOp = 0;
  int rollDiceOp = 0;
  int printDiceOp = 0;
  int printRollwithSavedOp = 0;
  int autoSaveDiceOp = 0;
  int saveDiceOp = 0;
  int getQtysOfDiceOp = 0;
  int autoConfirmScoreOp = 0;
  int confirmScoreOp = 0;
  int autoScoreTurnOp = 0;
  int scoreTurnOp = 0;
  int autoPlayTurnOp = 0;
  int playTurnOp = 0;
  
  int numPlayers = 0;
  int playerTurn = 0;
  int turnRolls = 0;
  bool keepRolling = true;
  int totalRolls = 0;
  int turns = 0;
  array<int,6> rollsPerNumber;
};


The next data structures are two classes called Scorecard and Score. Scorecard uses the object Score as a data type to fill a 2D array of width 18 and height of the number of players in the game.

Score has two attributes, score and hasBeenScored. ”score” contains the actual integer value of the Score, while hasBeenScored is a boolean field which is set to true if the score is set for the first time. The reason for this is to allow to check if scores equal to 0 have already been scored as 0, and are not just empty categories.

class scorecard{
private:
  int numPlay;
  Score ** playerScores;
  array<string,100> playerNames;
  
public:
  scorecard(int numPlayers);
  ~scorecard();
  
  void setNumPlay(int num);
  void setPlayerScore(int player,int section, int score);
  void setPlayerName(int player, string name);
  int getNumPlay();
  Score getPlayerScore(int player, int section);
  string getPlayerName(int player);
  void printDivider(int numPlayers);
  void print(int numPlayers);
  
};

class Score{
private:
  int score;
  bool hasBeenScored;

public:
  Score();
  ~Score();
  
  void setScore(int s);
  void setHasBeenScored(bool hBS);
  int getScore();
  bool getHasBeenScored();
  string getHasBeenScoredStr();
};
Below is a dependency chart for the main method. Simply put, the main method gathers the mode of which the user would like to play, either standard or auto-play, and the number of players. Based on these inputs, it iterates through either playTurn or autoPlayTurn enough times to fill the scorecard with scores.
The pseudocode for playTurn and autoPlayTurn are shown below.

void playTurn(yahtStats * stats, Dice * myDice, scorecard * myScorecard){
  1. Roll the dice between 1 and 3 times.
  2. Save the dice between 1 and 3 times.
  3. Score the turn.
}
void autoPlayTurn(yahtStats * stats, Dice * myDice, scorecard * myScorecard){
  1. Find a random number of rolls between 1 and 3.
  2. Iterates through for the number of rolls indicated by the randomly generated number.
  3. AutoSave the dice.
  4. autoScore the turn.
}

A critical portion of this project was to do a complexity analysis. I chose to do my analysis based on the number of players. Because my independent variable was linear, and each player had a set number of turns to complete, I hypothesized that the program's complexity would increase linearly. To test this, I made the auto-play mode. Since the outcome score-wise was irrelevant, I chose to randomize the player input at any opportunity. In this way, I simulated the average game with players. While convenient, it did not replace the high scores of an actual AI player. To keep track of the operations, I placed incrementing counters at places inside of each local function inside main.cpp.
 These counters can be found in the yahtStats struct.

Originally, I had the autoPlayTurn function print off the scorecard each time. For reference, the scorecard looked like something below.


By printing the scorecard each time a turn was finished, I printed off the scorecard numPlayers^2 times. This resulted in the following exponential complexity plot based on operations.
After removing the offending quadratic printing, the complexity plot became very linear, which proved my original hypothesis.

In the end, this project taught me the value of complexity analysis and data structures. It was good project to work on because it had a medium high code complexity and great "Fun Factor". For those of you who would like to try out the program, it is available here: Yahtzee.

-John "My computer is at 1% so I have to FINISH THIS QUI"

Friday, August 8, 2014

The Idea Forge in Review

Hello Readers,

Over the course of the summer I have learned much about how to manage groups of people to achieve a larger end goal. While there were a few hiccups along the way (the necessity of locking castors for tables, etc.), work on the Idea Forge has gone better than imagined. We have nearly completed construction of 20 whiteboards of two unique designs, three work tables, and seven design tables.

With each of these projects, the goal was to make something functional and visually stimulating. To show just how easy this is to accomplish, I have created a venn diagram illustration.


Sufficed to say, it was a challenge to make this happen. I was part of the second round of employees to come through the project, and as such, I had some catching up to do with the projects. After a short while though, we were organized as a group and were working as a well oiled machine.

Upon arrival, there were a few things mostly completed, including the whiteboards, and some things that needed lots of work, like the design and work tables.

The first issue we ran across with the design tables was squaring the frames. Made out of galvanized piping, the frames could be described as "artisnally crafted", each table is unique. It took almost a week of shifting and cranking with pipe wrenches to make the seven frames level and square enough to add on the steel angle bars that would serve as a rim for the specially designed wood table toppers. Even though we made the steel frames as square as possible, it was still necessary to muscle the bars to slot connecting bolts through to the galvanized base. We certainly do not envy those who have to manipulate those frames in the future. Given the opportunity, we should have gone with a more exact material, like fully cut and bored steel bars. This would have made the construction process 100% easier, even if it did put the tables on the far left of our Venn Diagram above. That being said, the final products with the galvanized piping look incredible and will be functional for many years to come.

The work tables presented a whole other host of issues. Breakdowns in communication between multiple supervisors had given us, the student workers, a limited view on the purpose of the tables. One minute we would hear the tables would see light construction work, like assembling small pieces of acrylic, and the next we would be expected to have the table support an entire engine block.

At some point as a group, we got frustrated enough that we confronted our superiors and had them detail specifically what they required. After this event, we were able to move forward with renewed purpose and energy. The design was finished shortly thereafter and we spent a whole day constructing the work table. Made from 80-20 aluminum, these work tables were lighter, stronger and more expensive, than their galvanized pipe counterparts. Since then we have constructed two additional tables, bringing the total number of work tables to three.

The most fun that I had working on these projects was designing and crafting the design table toppers. We ended up constructing three tables with sealed and stained Colorado beetle kill pine, two tables stained with gears branded into them, one table with a looping gear and chain design inlaid into the table, and a final table with an inlaid steampunk blimp.

Overall, this summer job has been an eye opening experience. It has confirmed my interest in the engineering field and peaked my desire to become involved with engineering management.

Please take a look at the pictures posted below. They show just some of the people who have put in the hard work necessary to make this project a success.

...

Thursday, July 3, 2014

Steampunk Lamp

Hey Guys!

Long time no real completed projects, so I figured give you the low down. Last month I had some pretty major jaw surgery, and while I was healthy enough to do some casual bike repair, I didn't have the patience for a full project. However, I now have the wonderful opportunity to help out my school in a management role for the new Idea Forge.

The Idea Forge, which has taken on a "Steampunk" theme, is a new project design and construction laboratory in the Fleming Law building. A group of 20-25 students, myself included, are designing worktables, whiteboards, and other furniture to be used in the construction and design rooms of the Idea Forge.

Before I had arrived, the group of students had to design these pieces of furniture from scratch, model them in SolidWorks, and test their designs before putting them into production. Upon arrival, I started working with the design table work crew. The tables were already roughly constructed, but not fully completed.

Today, I had the pleasure of working with Jeff Carlson on a steampunky lamp project that would help illuminate the design tables. In the end, we designed a lamp that utilized an Edison bulb and galvanized steel. What was really novel though was the repurposed valve connected to a dimmer switch inside of a 2" diameter pipe. The end result was quite satisfying.

-John "This job isn't really a job" Dunn


Wednesday, June 4, 2014

Robot Dot Printer

Hello all,

Well, the end of my sophomore year has finished, and with it, half of my college career...hopefully. At the tail end of every semester, design classes kick into high gear and students produce some extraordinary results. For the end of our electronics design lab, my partner and I decided to create a robot dot printer. For those who haven't seen our robot before, here he is, Geoff, with a face lift.

Figure 1: Geoff with his printer face.
Introduction
”Theoretically, this should work” was probably the most commonly used phrase in our final project days. The goal of our final project was to create a robot that is able to print discrete images using sharpies actuated by servo motors. To complete this goal, we had to construct a printer assembly that would be placed on the rear of our robot, and developed code for the Arduino to drive servos with pulse width modulation such that sharpies moved in a linear path.
Figure 2: Block diagram of our system.
We also had the idea to use a Sparkfun manufactured PWM shield (Fig. 3a)that had the ability to
drive the 8 servo motors. Unfortunately, luck was not on our side, because the board had a faulty powerpage3image1256
management system. To sidestep this issue, we settled for only using 6 servos, which was the maximum the arduino could provide. 

Design of Printer Assembly
Next, something that actually worked! Originally we had planned on using solenoids to actuate the Sharpies. After connection between the solenoids and markers became a dubious prospect at best, we opted for a more accurate, and more Arduino friendly method of actuation, the humble sub-micro servo. The servos allowed us to use PWM to accurately push and pull the Sharpies.
The first issue we ran across was constructing servo horns to connect servo and Sharpie. Using a laser cutter and some 1/8” acrylic, we were able to manufacture horns that fit our application wonderfully. A slot was cut along the length of the arm which allowed the Sharpie to side back and forth on its vertical path. This movement minimized the torque on the servo motors.
Figure 3: Printer Assembly. Due to the buggy nature of the PWM shield, we decided to remove the outside servo assemblies in favor of using the built-in PWM outputs of the Arduino. 

Figure 4: Connection between Sharpie and servo.
Figure 5: Printer assembly. By laser cutting the printer assembly, the servos were able to be press fit into the holes 
without any screws. This accuracy was accomplished through many iterations. 

PWM Servo Control
Servos are controlled by pulse width modulation. Different pulse widths are associated with different positions, shown in Fig. 6. In our robot, we use three positions: Storage (fully up), Set (down but not touching), and Print (down and touching). We ran across issues with power regulation when we tried to drive all 8 servos from PWM shield, so we defaulted to using the six PWM pins available on the Arduino. However, eight PWM outputs were required to control the six servos and two robot wheels. Two additional PWM outputs were made by manipulating Arduino digital output pins with strategic timer interrupts. This created a PWM signal suitable to be a voltage reference to the robot motor controller. 


Figure 6:
Explanation of pulse width modulation with servos. 

In order to print designs, servos would have to be in specific positions at specific times. The process of printing would be to 1) Push Sharpies down, 2) Move forward, 3) Change positions of Sharpies, 4) Repeat. Using a linked list method explained graphically in Fig. 7.
Figure 7: 
This diagram explains the basics of linked lists. A data structure was created print col that contained a list of values, 0 or 1, and a pointer, or link, to the next print col. At the start, the servos are given the list at the first print col. The dots indicate that the servos are in the up position. After all servos are positioned according to the current list, the robot moves forward an increment, then changes the position of Sharpies to the list in print col 2. This process is repeated until the print sequence is completed. 
Results
In order to have an operational robot dot printer, the Sharpies had to be properly calibrated. Calibration was as simple as manipulating the servo horns on the servo head such that the tip to be of the ground when the servo was in a high position, and on the ground in the low position. The results of a simple pattern print is shown in Fig. 8.
Figure 8: Results of  a simple pattern test.
-John "I've been in bed for a month because my face is broken" Dunn

Monday, April 28, 2014

Effects of Ground Planes on a Six Element Yagi-Uda Antenna

Hey Anyone,

This is the most recent project I have worked on for my Wireless Systems class. It was a very difficult class with more material that time, but in the end we all had a general understanding of how wireless systems work. This report is on the effects of ground planes on a six element Yagi-Uda Antenna. This was my first real IEEE conference format report, and I'm proud of how it turned out. If you have any suggestions on how I could improve my technical writing or formatting, I welcome the input. A link the paper pdf can be found here: Effects of Ground Planes on a Six Element Yagi-Uda Antenna.
Cheers,
-John "up till 5am" Dunn

Tuesday, April 15, 2014

Motor Encoder Based Speed Control PCB

Hey team,

In the course of one of my classes, Electronics Design Lab, my partner, Alex Mault and I saw the chance to improve upon the design of our robot, affectionately named Geoff. Our goal was to take a messy breadboard and make an easy to use PCB from it. The result of our efforts worked remarkably well (meaning it worked exactly the same as before) and reduced the area of the circuit by two-thirds.

Figure 1: Our original, messy breadboard.
Figure 2: The beautiful, simple PCB copy.
The circuit we planned to replicate was a motor encoder feedback system, which uses the optical encoder output of a 10 V DC motor to maintain a constant angular wheel speed. Below is the block diagram  of this system for the right and left wheels of our robot, which are independently regulated by a microcontroller (Arduino).


While Geoff (our robot) is in motion, it's motor encoders output a 50% duty cycle square wave with a frequency proportional to the speed of rotation. For more information on Optical Encoders and how to build one, check out my previous post here. This square wave is sent to a 555 chip, set up as a one-shot circuit. A one-shot circuit outputs a pulse of fixed width on every rising edge of the input. Since the input of the one-shot 555 varies, but the pulse width (T_on) is fixed, we can achieve a variable duty cycle output. This output is fed into a voltage amplifier which regulates the ~3V input into a 5V output.

The speed control block is where all the magic happens. First, the output of the voltage amplifier is put through a basic RC circuit. What this does is create a primarily DC voltage with amplitude proportional to the duty cycle of the input signal. This DC voltage can be described as the "current" state of the motor.

For a moment, consider the robot ascending a slope. Given a constant voltage and current input, the robot would tend to slow down. By slowing down, the duty cycle output of the one-shot 555 decreases, and the DC "current" state of the motor decreases. If we use a voltage follower, where the reference voltage is given by a microcontroller to be either high or low, we can pull the dropping "current" DC voltage higher, which maintains the speed of the wheel equal to the reference voltage.

The packages we used were TL272 (Op-Amp) and LM555(One-shot 555). These are shown in the block diagram above.

To create the PCB that replicated this system, we first constructed a fully functional breadboard circuit. Taking these values, Alex created an EAGLE schematic and board layout. I then proceeded to hand make a two-layer board, which turned out to be a very tedious, but ultimately rewarding process, as the board worked just as planned.

The EAGLE project files.

- John "I really should be writing this lab report right now" Dunn


Figure 4: Left wheel 555 one-shot. 
Figure 5: Right wheel 555 one-shot 
Figure 6: Headers.
Figure 7: Voltage followers for right and left.
Figure 8: Right speed control.
Figure 9: Left Speed Control
Figure 10: PCB layout.

Friday, March 14, 2014

Mathematica Taylor Approx. and Error Bounding for Calculus 3

Hello All,

I was doing my Calculus 3 homework, which involved finding second and third order taylor approximations and their error bounds for a two variable function, and was getting tired of taking so many partial derivatives.

As an aid, I wrote up a Mathematica program which, when given a function of two variables, point on the function, and error bounds |x-x0| <= dx and |y-y0| <= dy, outputs the taylor approximations up to third order and the second and third order error bounds.


Mathematica File for Taylor Approximation and Bounded Errors

Edit: I recently added the graphs and the FindMaximum function to show at what points where the |f_xx| , |f_yy|, and |f_xy| achieve their maximums within the bounds of error.

Some screenshots from the program:






- John "Programming is a Crutch" Dunn


Wednesday, February 5, 2014

Optical Encoder

My most recent project was spurred from a lecture in my electronics design lab class. The goal of the class is to create a autonomous robot that preforms a unique function.  The robot consists of two driving wheels and a castor stabilizer wheel in the rear. Autonomy would be a relatively simple task for a micro controller. But there's a catch, in this class we must construct our own circuitry from the ground up. A type of component we are given are optical encoders, one for each wheel, which are used for speed and distance calculations.



Simply put, an optical encoder is a device that converts the angular position or motion of a shaft or axle to digital code. As shown in the figure below, a light source is shone through a rotating disk with a code track. If the disk is in a position such that the light source can shine through a code track hole, the photodetector puts out a high or low voltage, depending on the circuit.
http://zone.ni.com/cms/images/devzone/tut/b/82f98d1a421.gif
As the disk revolves, we start to see a square wave form. Note that a 50% duty cycle waveform, or a waveform that is on for 50% of the time, is produced only when the the code track has evenly spaced holes of equal parts hole and blocking material.


This sort of device seemed simple enough to replicate, so a week after that lecture, I sat down with some cardboard, a DC hobby motor, a bright red LED, and a photoresistor, to see what I could come up with.

As a prototype, I created a very basic cardboard box and disc. After connecting the disk to a DC hobby motor and running at high RPM, I foresaw an issue. Due to the inaccuracy of cutting with scissors, the center of mass of the disk was not at the axle. This resulted in a very unstable spin. Complications also occurred when testing the bright red LED and photoresistor.  When I flashed the LED at the photoresistor and probed the output, the flash was indistinguishable from the ambient light in my dorm room. At least, it wasn't giving me the nice square wave I was looking for.


The solution was to use an infrared emitter and receiver pair. To mediate the center of mass problem of the disk, I choose to construct a box and disk using a laser cutter, which is far more accurate than scissors.


Once constructed, the laser cut disk and IR emitter/reciever system worked beautifully, producing the pulse wave I was looking for. In my finished encoder, I only used four holes approximately 5mm wide at 0, 90,180, and 270 degrees. This produced a 90% duty cycle.


While this project was simple enough, it took a bit of time to work out some of the kinks. The end product was worth the effort, and I can now make calculations to determine the angular speed, frequency, and inertia of the disk. At least to me, this is quite exciting.



If you have any suggestions on how I might improve this design, please fell free to comment below!

Also, there are reasons we have web-controlled power supplies. One of those reasons is attached below.




-John "I was scared for my life filming this" Dunn

Monday, January 27, 2014

4th West Bed Lofting System

The Almighty 4th West Bed Lofting System
I'd like to take the opportunity to look back on one of my favorite construction projects, the extended bed loft, remembered fondly by most as "4th West".

First, a bit of background on the project. When my friend and I first moved into the dorms freshman year, we had big plans to create a truly epic room setup. Even at the summer orientation, we had taken measurements of the room and sketched a few ideas of how to improve it's design. As it stood, the was fairly spacious. Vaulted ceilings, multiple windows, and standard furniture (desks, drawers, etc.) all allowed for inherent creative layouts. We toyed with ideas like making a knee high platform for our desks or a raised shag carpet area where we could put a conch and TV. Through brainstorming, we realized that our ideas were bigger than the square footage of our dorm. Our first thought to remedy this was to bunk our beds.

In most dorm rooms, the beds are set on university provided frames without any notches or attachment points for bunking. The only hint that bunking might be an option are four 1/4" holes atop each bed post. This means that to loft a bed, one would have to buy and cut metal rods into about 3" sections which could connect stacked bed frames. The benefit to lofting beds include a more open floor space, increased storage, space for activities, and a sense of juvenile spirit. Downsides include the danger of falling out of a high bed, subpar structural integrity, and fire code violations.

While a McGyver'd bed railing might have been a guard from fall protection, my roommate and I thought it best to construct our own, structurally safer, more extensive, lofting system. This would solve our square footage issue and grant us the opportunity to make something unique in the dorm system.

The design we settled on would take advantage of the vaulted ceilings in our room, which reached up to heights of roughly 14 feet at the peak.  The blue shaded are of the block drawing below, expertly crafted in Excel,  shows the part of the room we proposed to construct a platform with 8' clearance.
Top-Down View
The black line represents the scale outline of the room.
The blue shaded region shows the area lofted.
The four rows on the bottom are unshaded because of an overhang.
As a side note. It would be interesting if somebody who is actually knowledgable on such topics would critic our work. We are always looking to improve.

Neither my roommate nor I had any formal construction education, but throughout the years we had picked up on most of the standard practices from other projects.  The goal of the design was to create a lofted area for our beds in the vault of the ceiling. Later on in the project we would add a half level "terrace" in the 4'x8' area not covered by the loft. This would serve as both a place to put our desks and as a step up to access the bed area.

With a final design in mind, we set about making technical drawings. Initially, we hand drew our structure on you guessed it, engineering paper left over from the previous day's calc homework. In an effort to be a bit more professional, we asked a mechanical engineering major to replicate our shoddy drawings in CAD.
Once we got all the materials together, we started actual construction. Because of the width of the stairwell in our dorm, we had to take out the window screen and feed the 12' 2x6's up from the ground outside. The length of these boards also posed an interesting challenge in maneuvering skills inside the room. We started by erecting the six 4x4 posts and screwing them into a rectangular frame on the top. Next we laid out joists that would support any weight placed on top of the structure. The last step was to add 1/2" plywood flooring to the top and supporting braces to the posts.  After a few homey touches, we had a finished product.

However, the fun did not stop there! After news of our extravagant lofting system had spread throughout the dorm, we starting hearing from our University. We had expected this, as a large wooden structure in university housing has the tendency to be attract fire code violations. In preparation, we had gone through the housing handbook and reviewed the fire code. In the strictest sense, we were only breaking one rule, which involved the minimum proximity to the sprinkler heads. To show we were willing to do anything to keep our new loft, my roommate and I wrote up a formal 18-page proposal and submitted it for review by the university. Four weeks and a visit from the director of facilities later, the university deemed the structure not to code and ordered that it be removed.

Over the course of this project we learned many things. Not all of which were engineering and construction. Understanding the proper rules and regulations of the space you working with is just as important as the project itself. Even if you do something super cool, like 4th west, the rules are in place for a reason. If something happened, the consequences can always be magnified ten fold. That being said, we wished with all of our hearts that it could have stayed.

-John "It was like rolling out of bed...onto a shag carpet bed" Dunn

Friday, January 24, 2014

Greetings!

Hello all!

I am a sophomore electrical and computer engineering major at  CU Boulder. Over the almost two years I have been here, I, along with others, have embarked on a number of fun, outlandish projects. From constructing a loft in my dorm room (That story later...) to hacking through electronics projects like digital clocks and LED cubes, the diversity of projects gone through is limited only by my friends' and my creativity and determination.
The purpose of this blog is to show you what myself and others have been working on recently. If you have any suggestions for projects, please let me know! I love diving into new topics and projects head-first.

Hope you guys enjoy all that is to come.

-John "This is My First Post EVER!" Dunn