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:

11713522_10153468840364111_11813626_n

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.

Where Am I?

You are currently browsing entries tagged with Engineering at Wilfrid Ngo.