Friday, December 31, 2010

[FYP] finishing touches on type II and type III

happy new year~

type III

type II

Monday, December 20, 2010

[FYP] TYPEIII prototype

mobile chair like self balancing device that is capable of moving one person.

arduino UNO as the MCU
flexiforce sensors for maneuvering
wheel chair hub motors.

Tuesday, November 23, 2010

[DSA] General Maths Algo

Long long long time ago.....
Programs are written in C++ to solve mathematical problem, not much of user click here and there on the GUI. Mathematical problem can range from calculating relative distance, trajectory etc.

To make life simple, there was "math.h" in C(include math in c++) to help make the calculation. "math.h" alone might not be sufficient to cover each and every possible scenario, hence some programmer do have their custom class to do the math related to their program.

We have studied general maths routine such as converting from decimal to binary (d2b) and at least 2 method to calculate Greatest Common Divisor(GCD). Through the d2b function, we learned how to decompose the "steps" to get the binary from the decimal and translate the "steps" it into code.

The direct application of the GCD I could thought of is the computation of the public key and private key pairs in the RSA algorithm ( Encryption is as simple as calling a function (java and C++ have the library), but behind the function call, these are the necessary code to calculate the key pairs.

Notice there are 2 possible way of programming the GCD, through the recursive method or the iterative method which we have discussed previously. Is it easier to understand the recursive code then the iterative code???

Below are the questions for the week.
IP address in the form of A.B.C.D, where each octet A,B,C,D range from 0 to 255 in decimal.
1. How many bits each octet hold?
2. What are the "steps" required to convert one octet to binary?
3. Write the function that would convert the IP and gives it equivalence in binary.

note: you could modify from the d2b function, or propose a simpler algorithm based on the characteristic of the IP address's octet

Monday, November 22, 2010

[DSA] Iteration and recursion

Look into the mirror and observe your self. Look into your eyes, you will notice that in your pupil (the dark/blue/green color portion of the eye if you are asian/Caucasian) you can see yourself in it. Now, look into that pupil on the mirror. You will observe yourself again, albeit a scaled version. That is what i call recursion, you will see yourself again and again in your pupil.

Assume that you can see even the smallest detail of yourself through the mirror, notice that there is no end to the vision?

This is not good for recursion in computer science/programming. The program keeps executing recursively, until the system resources run out. So, at least a condition for the recursion to stop must be defined, which what we called the base case.

Anything that is solved iteratively, can be solved recursively.

Fibonacci The first number of the sequence is 0, the second number is 1, and each subsequent number is equal to the sum of the previous two numbers of the sequence itself. Once the formula is established, it is easy to figure out the code.
Fibonacci is a natural candidate for recursion, because it need to use data that are computed before in that particular series. Hence, we need to store this temporary data somewhere. In recursion, temporary data is stored on the stack. 

Drill Questions
1. Write a iteration fuction that calculates 2^n. 2 to the power of n. n being the input from cin.
2. Write a recursive function that calculates 2^n. n being the input from cin.
3. when n is very large, what are the parameters need to take into considerations?
4. What do you observed for the 1. and 2. when n is very large?
5. Is 2^n a natural candidate for recursion??

Sunday, November 21, 2010

[FYP] mini obstacle course

video src from my student's facebook-> sara

if you wonder how to embed facebook video into blogspot. take a look at the code below. simply replace the video id "167054809983605" with your own video from ""

Monday, November 15, 2010


My favorite quote from Issac Newton "I am Standing on the shoulders of giants" greatly illustrate the idea of STL. Code have been written by other programmers, using the template feature to greatly help other programmers to overcome programming difficulties. I.e, reduce the time from concept to code.

Being a lazy programmer I am (yes I do admit I like to find the easiest and shortest possible way of writing a piece of code), I do not like to reinvent the wheel.

As in write my own custom code that serves the same purpose as those already written/tested/proven best code by the c++ community.

Why make your life suffer when there are already ready code for you to use?

Programming, in general, is the ability to synthesize code to solve real-world problem by making use of available code. Only in the very dire situation (think high security, high accuracy and the need for real time operation), custom code is needed. *read=> proprietary software*
By learning all the basic building blocks of programming such as template, variable passing etc. When one day this dire state occur, YOU have the ability to create the code library to save the day~!

The STL contains three main components:


Containers, as the name suggested is some form of storage for our data.

Iterators, instead of the programmer manually keeping track on 
ALL pointers declared and used (not an easy feat when the code is in the range of >10k lines ), this STL-Iterator helps the programmer to achieve the same objective.

Algorithms, fancy writing some code to solve the question in the math tutorial? Here is the partial solution. You need to piece this building blocks together.

Drill question

1. We have written some code to check whether a given word is a palindrome in the previous week, by using some member functions of the string class. Good work guys. 
Now, use STL containers, iterators to achieve the same objective.

2. Write a phonebook directory that let the user to store
1. first name
2. phone number

(Store some dummy data into the phone book for testing,)
and the ability to "scroll" the phone book

and the ability to "search" for a particular entry in the phone book.

hint: use ready code from

*non-OOP implementation is acceptable for now.*

Thursday, November 11, 2010

Tuesday, November 9, 2010

[DSA] string class

I hope you have enjoyed and learned some "know how" of writing a program from scratch, with our lil' palindrome example.

To make our lives easier, C++ have lots of library for us to choose from
#include < string > is one of them. Take note string and cstring. both are different!

If you check out the book pg260. There is a piece of code that is very similar of what we have done today. It is using CString instead of String.

Drill Question

Write a name generator (star wars name anybody? hehe) software.
1. The software takes in a name for input and
2. think of the "magic" algorithm to generate a "NINJA" name. Or any name modifiers you can think of. Similar to those name generators you have played on facebook. I guess pretty much of everybody have generated at least once.  Code it FREE STYLE ~maybe you want to start by storing 10 sample first name and 10 sample last name. Which gives a 10 to 10 mapping. Easily 100 names~

Append part of your original name to the sample name "randomly".
3. Check out the string member functions attached~

below are the member functions of String.

Member functions

(constructor) Construct string object (constructor member)
operator= String assignment (public member function)

begin Return iterator to beginning (public member function)
end Return iterator to end (public member function)
rbegin Return reverse iterator to reverse beginning (public member function)
rend Return reverse iterator to reverse end (public member function)

size Return length of string (public member function)
length Return length of string (public member function)
max_size Return maximum size of string (public member function)
resize Resize string (public member function)
capacity Return size of allocated storage (public member function)
reserve Request a change in capacity (public member function)
clear Clear string (public member function)
empty Test if string is empty (public member function)

Element access:
operator[] Get character in string (public member function)
at Get character in string (public member function)

operator+= Append to string (public member function)
append Append to string (public member function)
push_back Append character to string (public member function)
assign Assign content to string (public member function)
insert Insert into string (public member function)
erase Erase characters from string (public member function)
replace Replace part of string (public member function)
copy Copy sequence of characters from string (public member function)
swap Swap contents with another string (public member function)

String operations:
c_str Get C string equivalent (public member function)
data Get string data (public member function)
get_allocator Get allocator (public member function)
find Find content in string (public member function)
rfind Find last occurrence of content in string (public member function)
find_first_of Find character in string (public member function)
find_last_of Find character in string from the end (public member function)
find_first_not_of Find absence of character in string
find_last_not_of Find absence of character in string from the end (public member function)
substr Generate substring (public member function)
compare Compare strings (public member function)

Monday, November 8, 2010

[DSA] template class

Template, as the name suggested is a standard or generic way/form we could use for creating different output. For an example, you would ask for a report template from your senior so that you more or less know how what is expected from you.

One of the benefits of programming through a template, it reduces the effort to recode the same function/class but pass in a different variable type. Our good friend the STL Algorithms is the best example of programming template. Imagine the sort() function need to be rewrite again and again and again for each type of variable...............

I strongly do not advocate of getting report from other people and change it to your name. That is not template nor referencing. It is called plagiarism.

A function template or class template, beside used with primary variable, eg int, char, double. It can be used with data structures too. As usual, it is possible to pass in more then 1 parameter of the same or different variable type to the function template or class template.

reference the code below. NOTE: The Code is NOT COMPLETE you need to fix it before you could use it.

Q1. What does both of the function trying to do??? Is there a way to generalize it without repeating the "same" code?
Q2. Populate the given code with a template function that will double each number stored as elements in the data structure. Is it possible to double a char or a string stored in the data structure??

Q3. Write a template function reverselist() that could take in a list display the content of the list and store the contents of the list on to a stack and later display the content of the stack.
Q4. Is there a more efficient way to create a test for a palindrome????

Tuesday, November 2, 2010

[DSA] File Op

Data need to be saved somewhere. The reason being, if all data are stored in memory and the computer get accidentally turned off. The effect would be epidemic!
Data output using fstream are clear text by default! ENCRYPT any sensitive info before output to file!!!!!

Some text file are delimited in a certain way, for example below.
sample of comma delimited file=> aa,bb,cc
sample of semicol delimited file=>aa;bb;cc

File operations of the program, should be able to read in the lines, and "parse" the input accordingly and stored into the required variable.

This usually happens when legacy software needed an upgrade to the most-IN technology (Programmer Guru Mantra= If it ain't spoil, don't fix it). However, the data are not compatible. One common feature of software, it has the ability to "dump" data out of the system.

As as programmer, we need to write code to extract those that required to the new system. Therefore, we still get to keep our jobs, make ourself valuable.

Regarding on the issue of Out Sourcing to other country. Fret Not. Why would the company would entrust their data to a 3rd party other then their employer? The audit trail of hands dipped into the data would be clearer and easier to trace. Hence the accountability.

With Great monies, comes great responsibilities.

Talking about file IO and security, take a look at the game below.

I played the game when i was still a teenager like most of you. My friend challenged me to complete the game (eg Lvl 99) in the shortest possible time. Few of us, being kiasu (hokkien colloquial for afraid to loose), keep comparing each other's progress. Me, for being me went to my usual corner and gave my friend Lvl99 at the end of the day. Guess how I manage to get it done????

The sample of file operations are in the writescore.cpp and readscore.cpp. Compile and run it to get a feel of how File I/O is done.

Drill Questions
1. Write a program that READS IN records (eg A.txt) that are semicol delimited eg
tom 19 dcpe/2B/01 DSA B+;kelly 18 dcpe/2B/01 DSA A; .....

2. Write a program that WRITE OUT records (eg B.txt) that are semicol delimited eg
tom 19 dcpe/2B/01 DSA B+; kelly 18 dcpe/2B/01 DSA A; ....

3. write a program that reads in Q1 but modifies to comma delimited and output to a new file.

HINT: It is good to have a menu driven system to choose between the options instead of running 2 cpp projects concurrently.

Monday, November 1, 2010

[DSA] Class & Objects

In programming, class is a common topic. No matter is C++ or Java, the same concept on class still applies. Killing N birds with 1 stone.

In programming, objects are end product of a class. Objects represent data that are generalized by the class.

Think of the Class as a cookie cutter, Objects are the cookies, the dough is generic material that all cookie need to use. Each object may have some unique attribute(s), such you would sprinkle some chocolate on the dough to make a chocolate chip cookie or add some almond to it almond cookie. In the generalization point of view (the class pov), it is still cookie. All cookie uses the same dough.

Think about it, I went to eat dim sum last weekend and realize some of the items taste the same. I wonder they use the class method to make it. I.e generic minced meat to make dim sum of different shapes.

How would data be generalized and yet representable?
For an example, Cats and dogs. Both are mammals. Both have four legs. Does it means that the cat is a dog and vice versa???!!! Sure we can think of some other attribute that differentiates a dog and a cat. dog barks and cat meows.

So we can have a class named pets, we can have data attribute of pet type, pet breed etc. Below is the sample code for inventory I have for the dog class for my imaginary dog kennel.

drill question 1, create a class for a cat shelter? Think of the attribute you can put into the class to represent the data of a cat. Some attributes like owner telephone and address should be set as private, and accompany by the neccesary get and set function.

drill question 2, create bank account objects with classes as specified in DS03 Objects Q3.

Notice from the code I posted, I have to manually track the objects, manually remember what objects I have created and use it.
In programming, the ability to link one topic learned previously to another topic, "mesh" the knowledge together is very important. So to speak.
From data structures , we know that it is convenient to manipulate data in a data structure, and depends on the condition we can choose the best data structure to represent the data. Can we "link" class&objects with data structures?

Refer to the code below,

Drill question 3. Based on the class you have created, can you store the objects in a data structure of your choice???? Think of what are the possible applications for data structures "meshing" with class&objects?
HINT: try to use constructors

below is the code for the SpStudent class in the slides, with my comments

Sunday, October 31, 2010

[FYP] climbing up a ramp

well done boys and girls~! We shall not stop here. There are more to come..... 


Wednesday, October 27, 2010

[FYP] almost there

turning the segway using a pot while maintaing balance

Monday, October 25, 2010

[DSA] pointers stuff

Well done to those that have completed the drill question (well, at least you did the “EASY” one) last week. To those that did my STUN question, KUDOS!!!! By doing this exercise, you have examine the buggy code and correctly identified the syntax errors, logic erros and some went further of discovering the differences of using “cin” and “getline”. The application and synthesis skills, such as isolating the buggy portion of the code, using the debugger, and reading error message from the IDE are particularly important especially in programming. These are the skills that I hope you can exhibit or demonstrate at the future assessments to come.

For those that have yet to attempt, please give it a try. And for those have done, try out the “HERO” question. Everybody loves to be a hero and get "worshiped" (I assumed that is).

Pointer is used for example when sorting a data structure. It is “expensive” to move the data physically, hence, changing the value of the pointer that points to the data is considered “cheaper”.

Below is a chunk of code that demonstrates pointers, the differences when pointers are applied to “char array” and “int array”. YOU are MOST WELCOMED to add more examples of using a pointer in c++.

Pointers come a long history in C and C++, some hate it so much but some really love it. Take it like a durian. Pointers enable the manipulation of the memory directly. PLEASE be EXTRA meticulous when it comes to programming pointers. Commented code really helps a lot for others to look, learn, debug another programmer’s code.

Now Comes the drill question for pointer. Write a program that calculates the volume of a cube (A x A x A), which need to satisfy some "requirement" identified from the "problem analysis" (which is done by me for you)
1. Read in 2 inputs from the user
2. Code a function that takes in this 2 parameter passed by reference and the result is stored in another variable, which is also accessible by the pointer ptrArea. Print out the area for the user.
3. Code another function, which takes in the ptrArea and calculate the volume of the cube.

Now come to the drill question array. Arrays are “containers” that can be used to store data in a structural manner. There are some disadvantages when it comes to using array. First, memory need to be allocated first (static). What happends when there are many copies of the same programme are running? Since memory is allocated, and used up but there are more data to come, array do not have the flexibility to increase like the vector. What are the other cons of using array compare to any other data structure?

Consider using “arrays”. Code a simple 100 seat cinema booking system that will do the following
1. Given (x,y) coordinate set the seat to be occupied.
2. Suggest a scheme/algorithm that detects duplicate seat entry.

Wednesday, October 20, 2010

[DIY] my LED belt buckle bling

I was toying with the idea of controlling rows and rows of LED for display purposes. Why not LCD (monochrome)? some may ask. First of all, LCD doesn't display well under outdoor condition and secondly we can see from afar if compared relatively with an LCD.

So there I go finding different ways of multiplexing LEDs. If no multiplexing method is used, I am limited with N number of LEDs. Where N is the number of digital pins available from my MCU. I am not in the state of getting a MCU with 64 IO pins just to control 64LEDs. What a waste of resources.

There I stumbled on the idea of charlie-plexing on the Internet. After reading about it and getting hook on the idea, I am eager to give it a try. But to my horror, the wiring on the vero-board can be quite nightmarish. Any 1 wire connected wrongly can result in a disaster.

I am looking for a better solution, eg a PCB for my own use. I stumbled upon LOLshield V0.1 and it cost USD$99 excl shipping. It is way out of my reach.

I went around asking our staff about it and luckily, I met Mr.Chong SP which he kind enough to supply me a PCB he designed to use charlieplexing for 56LEDs. The experiment time was cut down drastically, because of the time reduce from making the connection. PHEW... programming was not straightforward but still manageable.

But somewhat 56LEDs I am still not satisfy with it..... The number of text I can scroll is limited. Couple of months later, LOLshield v1.5 is going for USD25. I know i got to get my paws on it.
126LEDs in a 9x14 grid! wow!!! Quickly, I made my order and waited patiently for it to reach SG.

I thought inserting of 126LEDs of 3mm is going to be a breeze...but i was wrong......spent about 1hr + just to insert them all....Make sure you get all the polarity of the LED correct. Any 1 mistake will make the whole board defect.JimmyRodges silk screen the LED polarity on the PCB, so you will not mess up with the + and -. How thoughtful.

 Next, Apply masking tape of the LED side to support when doing the soldering. The spacing are very small (1.5mm apart) and can be quite intimidating to beginners. I got some steady hands and couple shots of coffee to help me stay focus. I have soldered 126x2 = 252 pins in another 1hr + time.
When soldering PCB of this caliber, make sure you have a really good solder tip. Having a good condition tool is to the success of this toy. My newest soldering iron is getting really troublesome. After a few pins, the heat became uneven and it felt very sluggish..... I changed to my old solder iron which I am reluctant to throw away. Same problem..... The soldering tip is worn out badly. I went digging around my pile of junk and discover that I have a spare soldering tip, but for a smaller watt which I bought earlier but did not get to used it. 

On the left is the badly battered soldering tip, on the right is the new one.

Then soldering is really a FASSSTTTTT.... I only spent about 1-3 seconds per pin....I recommend to trim off the excess leads from the LED to as short as possible, roughly 1-2mm above the PCB then solder. I will explain in the next paragraph. My soldering skills are getting rusty, I am getting old and my eye sight is still as good. God knows how many more years I can do such delicate soldering.

Hook up the LOLshield to the Arduino. Note in the previous step. If you do not trim the leads as short as possible, when you fit the LOLshield to the Arduino there might be a gap and caused loose contact. Worst, the exposed leads will come in contact with the USB connector on the arduino. Hence, I covered the metal connector with masking tape to prevent it from shorting my LEDs.

Now, the code part, I am using the basic test from the example. Download to the chip... and....Kept my fingers crossed..........

The moment of seeing all the LEDs light up accordingly, it is really priceless.........all the hours spent did went off.........
Next, I want to scroll some text, but i realised that the library I imported is buggy and doest not support fonts. jimmrodges did release another version of the library. Comparing the modified code is really mentalling taxing. So i used the "diff" function from notepad++ to compare the changes in the 2ver of the lib files.
Life is so much simpler with this small helpers....

Load in the new changes in the lib file... mod the existing sample code to scroll a longer text. Please note that it only supports 22char and capital letters only.

have fun!!! It is going to appear as my belt buckle with customizable text. Anybody wants to shrink the footprint to make it even smaller? LOL

Sunday, October 17, 2010

[DSA] Common Mistakes in Programming

There are few categories of mistakes/error/bug in programming. Suchs as logic erros, syntax errors, core dumpz (run time error)/
I came across many many types of mistakes in programming that student commit. These mitakes fall majorly into the syntax error which is the easiest to troubleshoot. As compared to logic errors, there are formal mathematical way to prove that the logic and the premise it holds.

As the old programming guru’s mantra: “It takes more pairs of eyes to spot the bug”

Below is NAF (Need A Fix) buggy code that I have created (50lines only....easy). Your "TASK" is to "SOLVE IT", "FIX IT", PLS DO NOT EAT IT!!!

PLS POST/SHARE your answers here, add in as comments.


NO KICK???????????!!!!!!!!!!!

try the below (100lines, 5qns), covers strings, STL containers, iterators. Errors such as syntax error, runtime error and a little bit of logic error.



Thursday, October 14, 2010

[DIY] pc based oscilloscope-zelscope

sometimes we need to use oscilloscope to verify our findings, especially with data acquisition. 
But, if you working from home, having the hardware it self is a luxury.

this is pc based. you would need to connect it to the mic input of your laptop/computer.
stereo audio cable, stereo mini 2.5" jack (male and female) both can draw from the store.
if you need to look at a sample. come to my office.

Pls do not, put >5v as input. might damage your sound card.
alternatively, go SLS get those 9bux USB soundcard and use that mic input.
Anything fried, will be at the USB sound. Take it as an insurance, 9bux  10 bux only.

This is how the usb soundcard oscilloscope looks like

for the software, download here the 

there is the free ver, which is not floating from the official website. It is in my laptop

Please note the sampling frequency is only until 44kHz, which is equivalent to the CD quality for the USB sound. Hence, any hi frequency waveform is not able to observe using the software.

Sunday, October 3, 2010

[FYP] Almost there....

Weekends well spent with the students...

Happy Bdae to KKKY too~~!~!

Saturday, October 2, 2010

Congratulations Cisco NetRider Singapore 2010


You made us PROUD!!!!!
Photo Source: sjteo

Wednesday, September 22, 2010

[DIY] how to bake a light cheese cake

Was really tied up with work and processing the semester exam.Finally I found some FREE time to blog about stuffs I have done over the weeks!

The following ingredients called for 2 cakes.

250g Cream Cheese (I used Philadelphia,you can use any type of cream cheese of your choice ).
100g Butter
Leave both above at room temperature.
8eggs , yolk and white separate.
100g sugar (can be reduced to 80g if you are watching the sugar intake)
2 Tbsp (Table spoon) corn flour
2 Tbsp flour
0.5 serving of mango yogurt
150ml of whipping cream (chilled)
1tsp (tea spoon) of vanilla essence

This baking of cheese cake called for the hot water bath treatment (to be elaborated later). I did wrapped some foil on my spring foam pan (the baking tin with detachable base) to prevent water from seeping in.
Sieve the powder ingredient.
Beat butter and cream cheese with the mixer at medium speed or high speed if you are impatient like me!haha
Beat with a mixer untill light and fluffy. How to determine the mixture is fluffy? Where the mixture is beaten until it have risen AKA volume increases, that is about time to stop the mixer. If you are using a manual one, this is a good exercise to burn off the calorie... (which you going to consume later anyway...hahahaha)

Beat in the egg yolk 1 by 1.
Add in vanilla essence
Sieve in (for the 2nd time) the powder in batches and stir with a spatula. Doing for some body i Love, so I did put in extra effort. Otherwise.....
Make sure there are no granules of powder in the mixture. This will affect the texture of the cake

Turn On the mixer, add in yogurt to batter
Then add in whipping cream (chilled) to batter
 This is how the batter going to look like after all the ingredients are mixed. We are not done yet. Still have the most important step, making the meringue.

In the mean time, lets go and heat up the oven at 170deg C with a hot water bath. Prepare a pan in the oven, add in hot water until 4/5 or 3/4 filled. Do not fill to the brim, It will overflow and caused scalding. The cake tin is going to take a bath in the pan in a little while. My oven is the those that comes with a fan, the fan is good when roasting. Baking wise, conventional oven is good.
Meringue time.
Make sure your mixer, bowl and utensils are free from dirt, water and grease. Must be very very clean and dry thoroughly.
The egg white must be free from egg yolk too. TURN On the mixer at HIGH SPEED
Add in the sugar in batches

Beat the mixture until semi liquid form. This is the tricky step. In between mixing, turn off the mixer then lift up the mixer and observe the runny egg white. If it is still very liquid form, continue to beat. If it still flow down from the mixer and form a perk, that is the texture we want. If the egg white is beaten until set,  i.e. you can practically overturned the container with the white sponge in it over and it will not fall by force of gravity. This is the no no.

This takes a couple of practices to get the perfect meringue. I tried to master it, but it is really a costly experiment. Lab rats are really hard to come by to eat my experiment! hahahaha

Stir in the egg white mixture in batches to the batter.
My mum trained me (never inspired to be a ) to stir in such a way that, it forms an numerical eight. She said this will fold maximum amount of air into the cake.

Pour the batter into the cake tin, and off it goes into the oven into the hot bath.
Bake for 40minutes.

My mum's technique again.....
Insert a LONG bamboo skewer into the cake,
      If the skewer comes out clean,
               then cake is ready.
               continue with another 10 minutes.

I got carried away chatting on MSN with her and forgot to observe the time.........Then i sense a burnt smell......

Tuesday, August 31, 2010

[DSA] feedback~~!

RAWWRRRRRRRRRR is Feeding time....ooops feedback time.
feedback about me, you can use the below as a guide

1. my teaching
2. your learning
3. what you have learned from me
4. what you want me to improve on

I hope to see you guys again, prolly FYP or other modules.
It was fun and fulfilling to see you all keep upgrading your code to impress, yours truly. 

Monday, August 23, 2010

[FYP] hamster riding self balancing robot

As promised,
Sudah datang....

NO hamster is harmed in this production!!

Jack the beanstalk (hamster)
self balancing robot-> KKKY & co

SJTEO. camera boy, gives direction but that doesn't makes him a director. ZZZZzzzZZzzz
KKKY and Sara. Robot rigger
Daniel and CWei. Hamster rigger
JLiang: tools rigger
mew: pacifier (for the hamster duhzz)

Friday, August 20, 2010

[FYP] self balancing robot

This are 2 of the student's FYP i am supervising now.

the common components on the 2 bots
MCU= arduino
accelerometer and gyroscope.

what makes it so different from one and another?
The bot in the 1st video, uses IMU. A chip that have accelerometer and gyroscope bundled into a single PCB. For locomotive, it uses a tamiya twin gear with 2 DC motors on ardumotor.

The bot in the 2nd video, uses a wii nunchuck for the accelerometer and a standalone gyroscope. For locomotive, it uses 2 servo motor.

The main objective is to make a  robot that is able to balance on 2 wheels that are position laterally on both sides.
The other objective is to investigate the difference in the algorithm/software/code that need to reflect the different hardware setup.

stay tune,

akan datang.................

Tuesday, August 17, 2010

[FYP] fire & hazard SOP in lab or workshop

Today 16 aug 10, yours truly is vising the lab at 5.10pm to check out on the progress of the project.
While moving around the the robot platform ,
explaining the requirements of the robot, fiddling around with the motors and gears mounted to the robot platform.....
Yours truly's micro-fiber business pants came in contact with a hot solder iron that was left on a chair for an extended period of time. 

Why is the SOLDER left on the chair!!!??!!!???!!? GRRRZZZZZ

LUCKILY, no roast meat is served for dinner. Poor alan brooke, he did not made his business pants to be heat proof.

An old saying=> You never came lucky, TWICE.

1. DO NOT LEAVE heated elements turn ON 
for extended period of time.
2. Make sure all heated elements are inside their guard/holder.
3. Turn off any unattended heating/electrical elements.
4. Work on the workbench. 
There is a reason why it is called a "work"bench

Thursday, July 29, 2010

[DIY] android on a laptop (live CD)

my student (WS) from SPIC is exploring on how to put android on a laptop.
After some tinkering he manage to try live CD.
He had put up a very detailed step by step guide. Which you guys can check out from the link below

Since it is booting from a liveCD, no damages will be done on your computer logically.

After you take out the iso image, Your computer resumes as per normal.

Friday, July 2, 2010

Chromium OS, Cloud Computing

I had a dream.......
The computers at CSSC does not require a HDD, an optical drive (DVD/CD) nor a installed OS.
The TCO of the computers can be on the cheap.

We could juz load chromium OS on a USB drive, boot from USB and use our computer as if it is a super big web browser.

for docs processing, we could use
for multimedia, we could use youtube with the playlist feature.
for storing of images, i could use flickr , photobucket
for storing of code, i could use snipt
for IM, i could use e-buddy
for social networking, i could use facebook...

hhhmmmsss.... what i could do more on my computer?

but for software development.... it is a little bit tricky......
but.... it is still cool on my development computer.
but for scanning of  photos from a scanner... it is a little bit tricky
but for printing of from a conventional printer... it is a little bit tricky

OVERALL.... it is still cool, for using chromium in a CyberCafe type of deployment.

check out the how-to documents of running chromium OS from my young padawan yonglin.

>  </iframe>

Chromium is still breaking on computers that sports broadcomm wifi chip. Altheros is still cool. 
more info here

Tuesday, June 8, 2010

[DIY] the accidental human conductor

Usually I would take a break from intense studying by doing some non technical related activity such as cooking, baking etc. But in the office environment, en-suit kitchen is consider a luxury and way out of my reach. Instead, I make little toys (electronics) /handicraft (mastering the art of folding roses) to kill off the gloomy mood from studying non stop.

I wanted to make a Amplitude Modulated Laser Transmitter for Audio. There are many examples (successful ones) plastered all over the Internet.It originates from here ...

What you will need
1. 1x laser pointer S$1.9 from $2shop.
2. 4.5v battery
3. Audio output transformer (8ohm and 1k ohm impedance)S$1, S$3. This is the tricky one, i shall elaborate later.
4. LDR
5. Speaker, USB powered preferred over passive ones.

Connect them up accordingly. The schematics are available from the link above. From left the laser pointer, the battery pack, the audio output transformer and audio out from the laptop.

Now, hook up the receiver part. The USB powered speaker, LDR.
Now, the tricky part. The "audio output transformer" (branded by the shop with no rating) which was sold to me for $3 does not work. After measuring the impedance using a Digital Multi Meter, it only have 2ohm and 600ohm impedance, a far cry from what I need. The output from laser pointer is very very very weak. The LDR cannot pick up the light intensity. I made another trip down SLT and one of the shop owner sold me a $1  "audio output transformer" . Tough luck I may say, the impedance does not match. The output from the laser pointer still as weak. Hunt around the labs for some luck at all.

I guess there will be another round of parts hunting, AFTER I finish my exam.

During the 30minutes of playing with the above mentioned toy, i noticed something.

When I am holding the LDR+USB powered speaker's mini stereo jack on my RHS and the laser pointer + messy wires at my LHS. The speaker output some music even though I DID NOT  press the "on" button on the laser pointer. Which it should not be the case. When I DID press the "on" button, the music is cut off! For a moment, I thought it is a very strange phenomena that doesn't make sense. But...after 2 seconds... HAHA.....

The first correct answer to that "strange" phenomena and why I press on the button of the laser pointer the music is off, shall get 1x muesli bar from me. Leave your answer on my post as a comment~

Nonetheless, it is still COOL to be the human conductor by touching both the receiver end and the transceiver end to produce some sound without using a physical wire. TRY IT AT YOUR OWN RISK!!! IF you or any parts thereof Got FRIED, I shall bear no liability nor responsibility.

Below is a video of it, still can WOW some crowd if it is packaged in a magic show. E.g, asking an audience come up to the stage to touch an exposed end (eg the receiver side), while holding at the magician's hand. The magician shall strut his/her stuff with the physics behind it.

now... back to the books..........

Tuesday, June 1, 2010

[news] Top 500 super computers!!!!

link :

Thursday, May 20, 2010

[DIY] light saber ver 2

Still remember my 15bux light saber i made couple months ago?

I made an upgrade of it, with proper light saber handle...It is kinda cool to take graduation picture with it!!!!But I did not dress up as obi-wan and bring it to the ceremony, it is too eccentric somehow.

I went to the mom&pops hardware shop trying my luck to get parts to make the handle, but some how, lady luck is not smiling at me. None of the parts express their enthusiasm to be modified by me. Then I went to tom&stephanie to buy present for my friends daughter and I bump into a toy that looks like a light saber and it is CHEAP. s$8.90 only.

I did put 3x AAA battery to turn it on and record down the animation. Did not upload it, because wanted to save me from the embarrassment of the toy. BUT, it is still cheap.

Since young, I have a knack of opening up things (+ forgot how to put it back!! haha) and take a look "under the hood". Being young, I have no idea what are the "innard" looking components and the wiring that are so intriguing to look at. My parents are  language teachers and can't really help much on the electronics/physics part. It is very important to have a mentor, a guide and somebody to teach the basics and principles of the working. Alternatively, I self taught by experimenting...... but that was a long time ago......

Here is how it looks like after it is dissected.
In the lower container, from left. small DC motor with counter weight to create vibrations when turn on. speaker, small IC circuit for sound & light.

while trying to cut out the excess plastic to make room for my modification, it snapped. So much for a s$8.90 toy. Luckily, it is not affecting the overall stability of the mod.

I got some tracing paper and transparent blue flim (2m  x1m) popular book store for s$1.50, but I only use 4" of it. the materials can be save for later use. Line them up nicely, secure with double sided tape and slide in the acrylic tube from the previous light saber. 3R= Reuse, Recycle, Re .... ahem...forgot....

After I finally got the LED strips into the acrylic tube that is lined with the diffuser and colour filer, 3 hours had passed...... I am running short of time to attend the graduation ceremony.....

Went to ah yap's lab to use his power tool to do some fabrication on the handle...
this is the final look of it.

some soldering, mouting and testing... the clock showed 5 pm.... i better get my shirt and tie ready....

boys & girls, May I present to you.... my s$23.90 light saber

this is how it looks under fluorescent light.

Saturday, May 15, 2010

[DIY] arduino and temperature sensor LM35

I accidentalmy hand 2weeks ago when I left my solder iron on for a prolonged period and I grabbed the metal guard. It is really a painful mistake. Luckily, no 3rd degree burn of that sort.

So prevent this from happening again, I decided to make a colour changing bling that reacts to temperature. All I is just hook up the temperature sensor to the heat source, for this example, the metal guard. It can be also modified to be fitted into a tap to give visual warning on the temperature of the water.

I laid my paws on RGB LEDs from sim lim tower that cost $1 per piece. It is on the pricey side and i only bought 5 of them. Loaned 1 to nigel and saravanan each for their D&I. Mr.Chew told me last Wednesday he got some for 40cents each (at 100pc lar)!! I felt I was really ripped off....I also have a temperature sensor LM35z lying in some dark corner in my tool box..

To light up R,G and B individually, just connect it to a logic low. My RGB LED is the common anode type. In arduino, this can be achieve by using the digital write.

But, to achieve "blending" of another color, it is necessary to input different intensity of Red, Green and Blue for that "new" colour. Hence an analog write is used.
I have used a 0-255 value, it is the same as programming HTML colour blending.

connect as below
int redLED=11; //Pin11 = Red LED
int blueLED=10; //Pin10 = Blue LED
int greenLED=9; //Pin9 = Green LED
A0 connect to vout of LM35z.

Vout is scaled to 1024 steps for easy conversion.

the code below is for your reference. Uncomment the colour blending part to play with the RGB LED.

take a look at the video. My office is at 20degC -> BLUE, my laptop is emitting heat at 30degC +++ RED. Anything in between, green.

Monday, May 3, 2010

annotating power point slides with laser graffiti

I came across the GRL (Graffiti Research Lab) website while researching for open platform and openCV to do tracking of an image blob.

I am totally amazed by the ability to draw with a laser, albeit not the emotion they are expressing with graffiti.

So I was thinking, can I used it to annotate my powerpoint slides while teaching?? + the wireless presenter I am issued with to scroll the slides back and forth. It is going to be damn cool lar! commercial product such as "afterglow" is going for usd$1950 per copy for the same feature i mentioned.

quickly, I downloaded the code (I love open source!!) and compile it. The webcam is the input device looking at the whole vision field and the code tracks the red dot (it is called a blob)
you will need

1x code
1x webcam (any model with driver)
1x <5w laser pointer 1x projector

check out the video.

sadly, when i run it with power point slides as the background, the slides doesn't show up as the background. More code tweaking ahead and more weekends are needed....

Akan Datang............................

Friday, April 30, 2010

Arduino with servo (360deg)

arduino with servo motor (360 deg) 

There are some servo code that came with arduino.

The servo is from parallax. It is a continuous rotation type. Courtesy of Ah Yap, TSO of T822.

I don't have a servo controller handy....
So I would just make do with manually programming my arduino to control 2 servo at a later stage.

The the servo takes 6v and 12mA and we do not want to power it directly off the MCU. If the current load is too high, 
the MCU might be fried. I really take good care of my arduino, so I will try 1x servo instead of 2x.

Just to illustrate the working of it.

Ignore the sonar in the above picture. It is for decoration purposes.
Hook up servo +6v and gnd to arduino 5v and gnd, data to pin D10.

you can try try the example code "SWEEP" that comes with it and for convenience sake, it is attached below.

Check out the servo in action...

Now the questions come begging, how can we drive 2 servo using arduino (note: data pin only) for a forward and backward movement.