Showing posts from 2012

Using Audacity as an Oscilloscope

A good oscilloscope is hard to afford. Spending money on a mediocre one doesn't seem to justify the stiff cost of even low-end scopes. In the meantime, I found a workaround! :-) Why did I need an oscilloscope? I've been wanting to crack my truck's keyless entry transponder code for a while now. I finally got around to it and succeeded with the help of a $5 315 MHz wireless receiver module from, an old headphone cable, and a free audio editing program named Audacity. Below is a screenshot of the captured code:
With an old broken headphone (2.5 mm) jack, I connected the receiver's output to the input of my laptop. 
Note: This could be dangerous! Do not do this unless you know what you're doing. Connecting a high powered circuit to your computer's sound card will probably fry the sound card and your computer!  Once connected, I powered up the receiver from a USB port and hit record while simultaneously hitting the lock button on my truck transponder. …

Simulink on Arduino!

From the Mathworks website:

Run Simulink models on supported target hardwareSimulink provides built-in support for prototyping, testing, and running models on low-cost target hardware, including Arduino®, LEGO®MINDSTORMS®NXT, PandaBoard, and BeagleBoard. You can design algorithms in Simulink for control systems, robotics, audio  processing, and computer vision applications and see them perform with hardware. This hardware support is also available inMATLAB and Simulink Student Version.

Once I get it working, I'll post a short tutorial.

Cool Matlab discoveries!

I just discovered two very neat and useful Matlab functions on

1) Matlab has the ability to take a symbolic expression and convert it to Latex. I find this especially useful when I solve a complex problems and the output has a lot of different braces, etc. Simply render the Latex output and see the output more "Mathematically".

2) Matlab also has hash tables similar to Perl!

EDU>> variable = containers.Map
variable = 
  containers.Map handle   Package: containers
  Properties:         Count: 0       KeyType: 'char'     ValueType: 'any'
  Methods, Events, Superclasses
And adding values:
EDU>> variable('Peter') = 'Paul'; EDU>> variable
variable = 
  containers.Map handle   Package: containers
  Properties:         Count: 1       KeyType: 'char'     ValueType: 'any'
  Methods, Events, Superclasses

EDU>> variable('Peter')
ans =

The Sentients: Making an Exception

A quick story I had to write for my Mobile Robotics class. We had to write a Sci-Fi story involving a team of mobile robots.

Making an ExceptionA swarm of robotic creatures, known as Sentients, is the sustaining force behind our planet’s civilization. They are responsible for transporting and moving everything on the planet to its destination. They are small and modular, run off the energy transmitted by the sun, and have a device in them that cancels the planet’s gravitational effect on them. This allows them to fly very efficiently.
One Sentient could easily fit in the palm of one’s hand. It has a small hand like claw with full degrees of freedom in any direction. It looks like something between a human hand and the tentacles of an octopus. When larger deliveries were to be made, say for example delivering and moving a piano, dozens of Sentient robots would form an enclosing structure around the package, and in unison, pick the item up and deliver it to its destination.

These creatur…

Tracking an LED with OpenCV

I have become very interested in using webcams to track objects and calculate their relative position in a space. My trusty friend OpenCV 2.4 came in handy. I used Harpia on Ubuntu 10.04 to generate some old, flaky code to track the green LED on an Arduino Mega. I pulled all the functions out of the Harpia code and put them in my own C program. (Code on Github shortly) Since LEDs have a pretty steady color, I took a photo of the LED with the webcam I was using, and then calculated the color value the LED was emitting. From this, I can output X,Y coordinates for the LED in the frame. Below is a quick video I made showing the tracking interface:

Gauss-Seidell Iterative Method for Power Flow Analysis

Probably the most exciting and interesting thing I learned this Summer in school is using the Gauss-Seidell Method to solve a Power Flow Analysis problems

The Matlab code below is posted on Git.

{edit} Code is not working. I get a slightly different answer than what I'm supposed to. I've got to run through it but I'm a bit too busy with school right now. :-)

Good Engineering Student Study Habits

One of the lessons any Engineering student learns is that no matter how smart you think you are, there will always be one or more classes that will force you to work hard. For most, that means most classes. Here are some lessons I've learned. They are common-sense, but not commonly followed.
Take Notes! Hearing, writing and seeing new concepts and information is crucial to learning. Pay attention, interact with the instructor, and take copious notes.Review. Review class notes every day some time after class. Every day you go to 3 or more technical classes learning things that you probably never imagined existed before. When you learn things in class, they are in your short-term memory, but with so much information to cram into your brain, much is easily lost without further review. A good practice is to create time slots for each class you attended each day and review your notes for that class. You'll find places where you didn't finish out a sentence or equation. Fill in t…


Our Electrical Engineering Department at Auburn University has a list service that they use to send out email notifications. Usually it's general stuff such as recruitment events, new classes opening up, etc. The other day, when I opened up an email from them, Google Chrome thought the email was in Estonian! See screenshot below... :-)

Innovative Humanitarian Products Organization

I am able to proudly say I'm part of the IHPO (Innovative Humanitarian Products Organization). We design and develop products that are cheap and able to make a difference in the developing world. Our first product was an electrical device (our founder, Grant Moore is an Electrical Engineering student), which uses salt water to make chlorine for sterilizing water, etc.

We are currently entered into a competition to win $5000 and need everyone's help. The competition gives $10,000 for the presentation with the most views, and $5000 for the 2nd - 5th places. We are currently in 5th place, but to solidify our win, we'd still love as many views as possible. Watch the presentation below or click the link:

Keep track of your IP address and internet connectivity

Below is some code I wrote to email me whenever my computer's IP address changes and log it to a file. I nifty side effect is it keeps track of when my internet connection is down as well. Copy this code and insert your own email address and run on a schedule such as cron.

No post for today's Computer Systems

We covered the all to crucial and important interrupts in Computer Systems today but alas, I was still occupied with Digital Electronics and the wonderful and sometimes mysterious world for transistors and couldn't take real good notes. For my own review and the benefit of the world, I'll write up a summary of HCS12 interrupts when time permits. Sorry...

Using Google Command Line Tools to post my Computer Systems Notes

Below is some code I wrote to post my Computer Systems notes online every day after class:

  1 #!/usr/bin/env perl
  2 use strict;
  3 use warnings;
  5 unless(defined $ARGV[0]){
  6    print "$0 [file to post]\n";
  7    exit;
  8 }
  9 my @date = ($1,$2,$3) if $ARGV[0] =~ m/Computer_Systems_(\d{4})(\d{2})(\d{2}).txt/g ;
 10 my $title = "Computer Systems Class Notes ".join('/',@date);
 11 my @infile = `cat $ARGV[0]`;
 12 my @template = `cat blank.html`;
 13 # Get rid of blank lines...
 14 my $tmp = pop(@infile);
 15 while($tmp =~ m/^\s*$/g){
 16    $tmp = pop(@infile);
 17    #print "tmp got $tmp\n";
 18 }
 19 push(@infile,$tmp);
 20 open(FH,">$ARGV[0].html");
 21 foreach(@template){
 22    if(m/{{{TITLE}}}/g){
 23       $_ =~ s/{{{TITLE}}}/$title/g;
 24    }
 25    if(m/{{{BODY}}}/g){
 26       $_ =~ s/{{{BODY}}}/@infile/g;
 27    }
 28    if(m/^\s*$/g){
 29       next;
 30    }
 31    print FH "$_";
 32 }
 33    close(FH);
 34 #  
 35 print "goog…

Class Notes 2012/02/13

; #1 Write a program to compute the following
;A1 = (B1 - C1) - (D1 + 8)

;Use only direct/extended addr. for all memory references.

ldea B1; A=B1
suba C1 ; A = (B1-C1)
ldab D1 ; B = D1
addb #8 ; B = (D1 + 8)
sba ;
staa A1 ;

;Use only constant offset indexed addr. for all memory references.

ldx #A1
ldaa 1,x ;A=B1
suba 2,x ; A=(B1-C1)
ldab 3,x ;B=D1
addb #8 ;B= D1+8
sba ;A=(B1-C1) - (D1 + 8)
staa 0,x ; staa x

;Use auto-increment indexed addr. for all mem references.

ldx #A1 ;
ldaa 1,+x ; A = B1
suba 1,+x ; A = (B1 - C1)
ldab 1,+x ; B = (D1)
addb #8 ; B = (D1 + 8)
sba ; A = (B1-C1) - (D1 + 8)
staa 3,-x ; A1 = A

;Use register offset indexed addr. for all mem references.
ldx #41
ldab #1
ldaa b,x ; A = B1
ldab #2
suba b,x ; A = (B1 - C1)
ldab #3
suba b,x ;A = (B1 - C1) - D1
suba #8 A = B1 - C1 - D1 - 8
ldab #0
staa b,x A1 = A

;Define 2 20-byte arrays,
; 1) Copy one byte at a time, using indexed add…

Class Notes 2012/02/10

ORG $800
vec1 dc.b 1,2,3,4,$FF
vec2 dc.b 0, $FF, 3, 5, $80
count ds.b 1
ORG $4000
ldx #vec1 ; x->vec1
ldy #vec2 ; y -> vec2
ldab #5 ; init loop counter
clr count ; clears the count
loop: ldaa 1,x+ ;vec1[i] -> A
cmpa 1,y+ ;compare vec1[i] with vec2[i]
blt next ;if vec1[i] < vec2[i] then branch
inc cont
next: dbne b, loop dec. loop counter + branch if it's !=0

Next example: Write a program to compute the dot product of vectors a + b. Assume the vectors contain unsigned 8-bit values and ignore any carries...

a (dot) b = sum from i to n of a_i*b_i = a1*b1 + a2*b2 + ... a_n*b_n

; Variables
vecA ds.b 5
vecB ds.b 5
result ds.w 1
counter ds.b 1

; Code
ORG $4000
ldx #vecA
ldy #vecB
movb #5, counter
movw #0, result ; We move word because multiplying two bit numbers results in word (???)
loop: ldaa 1,x+
ldab 1,y+
addd result ; Goes into register D
std result ; Put the result stored in D back into result.
dec counter