Tuesday, July 14, 2009

The 1,2,3 in interfacing LCD with PIC (Software: Part 1)

This article is written assuming user has knowledge on hardware part.

There are few basic things which we have to bear in mind.

  1. 3 control lines:
    1. Register Select (RS)
    2. Read/Write (R/W)
    3. Enable (E)
  2. Simple instruction set you might need:
    1. Initializing – determine cursor’s position and characteristic.


Table 1: The command control codes

For more information, please refer to http://www.cytron.com.my/viewProduct.php?pid=FjswICgDMQkFLhMRHy0XHVI/kU2m3Az9XsdY/Nuz3hY=&store=

Next, we move on to the next part where we initialize the LCD and start displaying some characters. Hence, to simplify, the objectives of the following step are:

1. Initialize LCD

2. Display few characters

3. Determine location to display the characters

The first step to do is to initialize the LCD. As mentioned earlier, the 3 controls line must be set prior to the initialization. RS is set to ‘0’ so that the LCD is in command mode. Then, set the initialization bits (D7-D0) according to Table 1. The next step is to toggle the E pin. When E bit is being toggled, it enables the chip to accept data. The R/W pin is being connected to ground in this case as we do not require data to be read from the LCD module.


To perform the mentioned steps in details:

// clear screen

rs = 0;

PORTD = 0b00000001;

E = 1;

delay (300);

E = 0;

delay (300);


If you’re on the right track, you should see nothing on your LCD. If there are boxes on the first line, adjust the contrast so that it is semi-visible. This is the step to clear screen (refer to Table 1). Next, we set the cursor’s position and characteristic.


// initialize cursor

PORTD = 0b00001111;

E = 1;
delay (300);

E = 0;

delay (300);


After performing this code, you should be able to see your cursor at the first position of the LCD. The cursor is also blinking and underlined.


(NOTE: Remember to initialize your PORTD as output port and a while loop at the end of the code so that the program does not repeats itself when loaded.)


Now, you are ready to complete the second task, which is to display some characters. The steps to input characters are similar to initializing the LCD, however, they differ by the configuration of RS bit. When displaying characters, the RS must be set to ‘1’ to enable data transfer. As for the characters, they are identified using ASCII code. You can always get the code online. Just google it! In this tutorial, we will use only few characters, they are: ‘A’, ‘B’ and ‘C’.


// function set (refer table 1)

rs = 0;

PORTD = 0b00110100;

E = 1;

delay (300);

E = 0;

delay (300);

// write in characters

rs = 1;

PORTD = 0x41; //’A’

E = 1;

delay (300);

E = 0;

delay (300);

PORTD = 0x42; //’B’

E = 1;

delay (300);

E = 0;

delay (300);

PORTD = 0x43; // ‘C’

E = 1;

delay (300);

E = 0;

delay (300);


Now that you’re equipped with skills to key in characters and initializing the LCD, we can move on to determine the location of the cursor.


To test with the cursor location, we set our LCD into two lines mode, to have a wider range for manipulation.


Next, we will have to set the location we want our cursor to be at. For instance, we want to set the cursor to address 00001000. We set the display address command, 0b10001000.


// set the function (2 lines)

rs = 0;

PORTD = 0x38;

E = 1;

delay (300);

E = 0;

delay (300);

PORTD = 0x88; // move cursor to ninth location

E = 1;

delay (300);

E = 0;

delay (300);


Well, I guess that’s all for the basic of LCD which you need to know before advancing into more sophisticated program.

Monday, July 13, 2009

Bali Trip - Day 2 -- 17 Juni 2009

The continum of Bali Day 2... As mentioned earlier, ,me, Mei shan, gui yan, jia feng, sam and kk went to Kuta beach for a walk after shopping at Khrisna.. This is the time where we (mostly me) took a lot of pictures of well-built man~~







Well, after the mouth drooling session.. we went to cool ourselves down... we went to MoonTeaSpa for Balinese Spa...~~ no pics though coz we're in a hurry~~ so, that's all for the 2nd day at Bali..

Are adults being realistic or kids are simply surreal?

Very often, we are exposed to the different kinds of robots, regardless from the media or in reality. This traces back to various movies like Star Wars, Terminator, iRobot, and Transformer. For most adults, these movies are just like the ‘any-other’ movie they watched – ‘money-driven’ movie. On the contrary, kids will get mesmerized by the marvels. This addiction is the goal where movies producer have been longing to achieve. But then again, this raises another question, should all these addictions remain addiction or should it be evolved into hopes and dreams?


Let us take a glimpse back into our childhood. During then, we are exposed to cartoons like Doraemon, where a robotic cat named Doraemon, travels back in time from the 22nd century to aid a schoolboy, Nobita Nobi. Besides that, we are also being introduced to superheroes, like Batman, Superman, Spiderman and X-Men. Then, in the 20th century, our kids have numerous accesses to the internet to know more about robots than us. So, where does this evolution lead us to? Does all these fiction serve to drive us to disappointment or it is only for a moment of euphoria?


As I get back to the topic, the future of the robots lies in both adults and kids. What these science-fiction movies gave us is an idea of the immense and boundless potential of the robotic field. What we, as audience are supposed to do is to play a part in the development of this field. Adults should not dampen their kids’ imagination by telling them that those robots are only fictions and will only appear on the big screen. Instead, they should let their kids’ imagination run wild so that in future, what is shown on the big screen will come true in reality. Adults should stop being realistic, allowing their kids a chance to explore into the impossible. After all, Honda started with ‘The Power of Dreams’ and they came up with Asimo.


Once the parents are able to sort these out, how can they aid in supporting their kids in this area?


To be continued…

Tuesday, July 7, 2009

Intermission

Oopss... Sorry for the intermission.. I'm aware that I'm supposed to talk about Bali Trip, but then again, i've started working, hence, allow me to interrupt.. Today's my 5th day in Cytron, suppose to be working, but i'm blogging instead. Neway, that's me, blogging whenever and wherever i feel like it.

So, how's working life? how is feels like to be not studying and start working? It feels almost the same for me. Most probably I'm working at a company who provides solutions for students in their projects. Now, I feel like I'm at the level where i aid students who needed help terribly for their projects. at least, i'm here, Cytron's here, there's nothing to worry about. haha~~ i wonder if i can provide solutions for students who do research and experimental based FYP...

Lastly, do visit Cytron's website, www.cytron.com.my for more info.. Who knows, you might find your solution here~~!!