4 – bit Piano

November 22, 2015 § Leave a Comment

Hi folks, I’ve been working on lab 6 of the Embedded Systems – Shape the World course. Here is my 4-bit piano in all it’s glory:

The algorithm uses periodic interrupts that steps through the profile a sound wave (32 steps in this case). The interrupt period for each step vary depending on the pitch we would like to play. The faster the period, the higher the pitch. The buttons from left to right correspond to C, D, E, F notes respectively.

This lab really made me think about how electric keyboards are made and programmed. A lot of work must have been made to digitally profile numerous instruments, I also imagine the programming to be very sophisticated to play multiple notes simultaneously. I wonder if periodic interrupts are used in general electric keyboards similarly to this lab, and if so, whether or not interrupts are nested in another to superimpose different pitches together to play several notes simultaneously?

Anyways, on to the next lab.

Learning ARM Cortex M4 – TM4C123G

November 12, 2015 § Leave a Comment

Embedded Systems Shape the World Lab 5

Embedded Systems Shape the World – Lab 5 – Traffic & Pedestrian Lights

I found an excellent course teaching an introduction to embedded systems. It is called Embedded Systems – Shape the World and the course uses the ARM TM4C123G microcontroller for their labs. I came late to the party, as the course has already ended, and I couldn’t wait until it restarted in January 2016, so I decided the dig up old lectures, and labs, and just started doing them on my own.

I came across this course while I was interested in expanding my knowledge in embedded systems into something beyond a hobby. After building a self-balancing robot on an arduino platform, I quickly realized that arduinos are pretty limited in performance, flexibility, and is expensive compared to alternative microcontrollers. A quick comparison between the ARM TM4C123G vs the arduino Uno will reveal that the TM4C123G out performs the arduino in many aspects, and guess what. What the article doesn’t tell you is that the TM4C123G is way cheaper too!

In the version I’m taking, EE319K, I’m glad the first 4 labs had to be done in assembly language. It really helped me understand what was really going on when C code was executed.

I just completed lab 5, building a Finite State Machine in C to emulate traffic and pedestrian lights. Check this out:

Self-balancing robot like a growing child

October 11, 2015 § Leave a Comment

self-balancing robot
Building a self-balancing robot, Roboty, teaching it how to balance and to avoid running into things is like having a child. To understand where I am getting at, let me share with you my story of building a self-balancing robot.

The journey of this self-balancing robot begins with a micro-controller, an embryo, still tethered to its mother (the laptop) through an usb cable (the umbilical chord). A simple hello world sketch brings this young embryo to life.

WIlfrid – “Hi Roboty!”
Roboty – *blink, blink*
Wilfrid – *blink blink*
Roboty – *blink blink*
Wilfrid – “Okay, let’s give you some wheels so you can do more than just blink”
Roboty – *blink blink*
Wilfrid – “Okay, I’ll give you Bluetooth and a big ass lipo battery so that you got plenty of juice as well”

With that, the robot gain new motor functions, and autonomy as it evolves into a small frame with wheels, motor controller, and a giant lipo battery (4S2P 4000 mAH). The umbilical chord is now severed, and the self-balancing robot can communicate and be programmed wirelessly through Bluetooth.

The initial frame was very crude. Fragile as it was made of some MDF boards that I found lying around in my closet, and held together by screws and 0.25″ stand-offs.

This was what Roboty looked like:


Like a toddler the robot can’t quite stand up yet, but it can crawl on the floor, bump into things, and say gaga.

Wilfrid – “Okay, now try moving your wheels”
Roboty – *turns on wheels, and darts across the room*
Wilfrid – “TOO FAST!” *runs after Roboty*
Roboty – “gaga”
Wilfrid – “Ehh, I didn’t program that!”

For a toddler to stand up, they must understand what it is like to be upright. I prop this young robot on its two wheels, the robot begin to understand the physics of this world through its IMU sensor, capturing acceleration and gryo data.

Wilfrid – “This is what it feels like to stand up, Roboty”
Roboty – *splits out a bunch of yaw, pitch, and roll data*
Wilfrid – “Yea I know, this is a lot of information to take in. At least you didn’t have to go through the trouble of getting your IMU sensors working!”

Here we are making sure the sensors are outputting properly, and that the interrupts were setup properly to read encoder values:
Testing Sensors

It must now understand how to coordinate their wheels so that it can remain upright. I attempt to get the robot to balance on its wheels with a PID algorithm, to stabilize the pitch at 0 degrees.

Wilfrid – “Roboty, you must balance on your two wheels by moving them towards where you are leaning. If you feel you are leaning faster towards that direction, you must move your wheels even faster to compensate! Your goal is to try to stand straight up without any wobble.”
Roboty – *confused, wobbles, then face plants and runs off*
Wilfrid – “Dammit I need to program a kill switch for this” *chases after Roboty*

After some tuning to the PID algorithm…We finally get it right… but interestingly it runs off into one direction.

Wilfrid – “Okay Roboty, I know this is our 100th time doing this, but I got a good feeling about this one”
Roboty – *Stands upright*
Wilfrid – “Yay! You can stand!”
Roboty – *Runs off into one direction, smacks into the couch, turns around and face plants*
Wilfrid – “Okay… now I just need to teach you how to stay put…”

Now that we’ve stabilized the pitch, we need another slower PID loop to control the position so that the robot does not run off. If I were to redo this project again, I would use a state-space-controller to control the two outputs simultaneously.

Wilfrid – “Yay, Roboty, you can balance now and stay put!”
Roboty – *blink blink*
Wilfrid – “Okay, now let’s see how well you can reject external disturbances” *Smack, Smack*
Roboty – @_@ *Wobble Wobble*
Wilfrid – “Yeap, you know how to balance now!”

One day, while going home on the TTC. I couldn’t help but wonder how well it rejected disturbances on the subway. As I took the robot out of the bag, people looked at me strangely, and wondered what the heck was this big sketchy looking thing. To be fair, it did have a bunch of visible wires, and a giant lipo battery on top… to make it worst, there is a LCD displaying a number (voltage) on the top of the robot.

If security was around, I’m sure they would have a lot of questions for me.

Removing scratches from eye glasses

March 23, 2014 § Leave a Comment

I wouldn’t say I am a person who takes really good care of my belongings because, in 2 years, my new glasses already have a build up of scratches that blurs my vision and drives me crazy.

I did some quick research online on how to remove those scratches, and this was what worked for me:


  1. Liquid Metal Polish
  2. Microfiber cloth
  3. A lot of elbow Grease


  1. Put a dab of liquid metal polish onto the microfiber cloth20140322_204628
  2. Rub the polish onto the scratched surface of your lens in little circles until the scratches are removed
  3. Rinse the glasses in warm water and dry with a cloth to check for scratches
  4. repeat steps 1-3 until all scratches are removed



20140322_194108 20140322_194104






March 6, 2014 § Leave a Comment

Creativity sometimes come out of collaboration. I was  showing my girlfriend some of the Rhino 3D features. As I explained each feature, I did something random to the model using that feature. At the end, this was what we ended up with. A random duck :)


Earbuds Just for Fun

February 24, 2014 § Leave a Comment

Sometimes the best way to learn a new software is to follow some tutorials. That is exactly what I did when I wanted to learn Rhino 3D. Rhino has some really great tutorials on their website, and they were really fun to follow. The end result was an awesome looking earbud with our company logo on it! Excellent, one-step closer to being an awesome designer!

Sentry Scientific Earbuds

Fishing Lure Retaining Case

February 24, 2014 § Leave a Comment

Sometimes when you are a fisherman, it is common to take out your bucket of fishing lures to find them all tangled up.

A client in Florida seeks to solve this problem with a new way to store fishing lure and lines. He brought me on board to help take his idea through from conceptualization to commercialization.

The project began at the ideation phase: communicating specifications, concept drawings, features, manufacturability. Three months later, we ended up with an injection molded plastic retaining case, neatly packaged in blister cards, produced at less than a buck. This product is now sold in fishing equipment stores all over North America.

I present the Rigrap:



Rigrap in use:


Rigrap packaged neatly in blister cards and a display stand:

Display Hand Taking Prooduct Image


Adjustable Pipe Scanner

October 23, 2013 § Leave a Comment

While working for Eclipse Scientific, I was given the opportunity to build a product from the ground up. The problem was that our test engineers had to bring 3 pipe scanners (sizes Small, Medium, and Large) with them to test sites for various sized pipelines. The goal of the project was to design one adjustable scanner to accommodate pipe diameters of all sizes. By the end of the work-term I was able to put together a prototype that did just that.

The adjustable pipe scanner features an aluminum frame that can hold up to 8 ultrasonic transducers. The frame is used in conjunction with Jireh’s Billy Goat drive platform, and a spring loaded encoder. This pipescanner, with it’s drop down bracket accessory is capable of accommodating pipe sizes from 6″ dia to 42″ dia.


When using this scanner to scan welds on pipes, water will flow into the billy goat through a hose, and will flow out of a manifold into the channelled acrylic blocks contacting the surface of the pipe.

As the water flows through the channel and makes its way to the pipe’s surface. It acts as a medium, bridging the surfaces of the acrylic block and pipe surface so that the ultrasonic sensor (sitting on top of the acrylic blocks) can penetrate deep into the pipe, to detect weld defects, without any noise from gaps.

The scanner will ride around the pipe with an encoder keeping track of the scanner’s position such that the exact location of any defects, if found, can be known.