Real Time Clock with DS1307 - Introduction

by Conrad Gomes on

You’re developing a product and you need it to track time even when the power is switched off, what do you use? A real-time clock.

A real-time clock(RTC) for your system can be made available using chips like the DS1307. This has the ability to be programmed and keep track of the time in seconds, minutes, hours and date in binary coded decimal(BCD) format with compensation for leap years till 2100.

The DS1307 on inspection has 8 pins. The following describes the kind of circuit connections required for this chip.

Circuit Diagram DS1307
Figure 1. Circuit diagram of DS1307

Starting at the top left we see pins X1 and X2 connected to a crystal. The crystal provides the clock to the chip and is critical in accurately maintaining the time once programmed. Connections for X1 and X2 is a standard 32.768kHz quartz crystal.

The VCC and GND provide the power supply to the chip which is a 5V power supply.

SQW/OUT has dual functionality. It can be used to generate a square wave of 1Hz, 4kHz, 8kHz and 32kHz or it can simply output either a high or low signal.

VBAT is the connection for an external battery. The chip has an automatic power fail detect and switch circuitry which will switch to the battery in the event of the main power supply failing.

SDA and SCL are the I2C lines which is used by the CPU/Micro-controller to read and write the time and date registers.

In the next part we look at the register map of the DS1307.


Atmega Development Boards and Arduino

by Conrad Gomes on

I’ve been going through various sources trying to figure out what the Electronic DIY community uses to develop LED cubes, RC controlled cars, etc. I’ve been going through various sources trying to figure out what the Electronic DIY community uses to develop LED cubes, RC controlled cars, etc.

One of the popular micro-controllers in use today is the ATmega AVR from Atmel. This micro-controller is also used in the popular Arduino platfrom.

The popularity of the ATmega AVR is due to the availability of free and inexpensive development tools accelerated by the high number of development boards available.

The ATmega AVR was the first micro-controller to have an on board flash for program storage. Compared to the other micro-controllers at the time which offered one time programmable ROM, EPROM and EEPROM options. The flash offers reduced cost of development as the frequency with which applications can be deployed and tested easily increases.

The Arduino platform is an open source hardware and software project meant for hobbyists, designers and artists. The hardware uses a ATmega AVR and the software consists of an easy to use JAVA like programming IDE based on Wiring.

I’ve got my hands on an AVR development board called the Device Driver Kit. The kit can be used to learn about Linux device drivers or can be used as a ATmega AVR development board for your electronics project.

lddk connected
Figure 1. LDDK board

The board has a USB interface through which you can program the ATmega and develop your own applications. This makes it easy to do rapid prototyping with just a PC and the board. I’ll be posting some of my side projects which will use the board.

It shouldn’t be too difficult to whip up a ATmega AVR development board or a Arduino board with the resources available online. However as a starting point it would be good to familiarize yourself with the AVR before you jump into building your own board.

Details of the DDK board are available at:
http://esrijan.com/index.php?pagefile=lddk


An Introduction To I2C

by Conrad Gomes on

I2C is a serial data bus used to interface low speed peripherals developed by Phillips. Data sheets of other semi-conductor companies refer to their I2C like interface as the Two Wire Interface.

I2C has two lines SDA and SCL. SDA is used for data input or output on the I2C interface. SCL is the clock interface and is used to synchronize the data communication on the SDA line.The device initiating and terminating the transmission is called the master. The master controls the SCL clock signal.

There is only one master active during data communication on the bus however it does not mean the bus has to have only one master. The I2C protocol can support multiple masters and multiple slaves. In fact multiple masters can co-exist if they support an arbitration mechanism.

Typically when a master initiates a transfer it will also sense the line in order to detect if another master is transmitting at the same time. The arbitration mechanism will force one master to hold back on the transmission. The master can wait and try again once the line is free or immediately switch to slave mode if the application requires the device to act in both master and slave modes

More information at :

I2C
Figure 1. Diagram showing an I2C configuration

Kernel Module Makefiles

by Conrad Gomes on

You’ve got your kernel module code ready and you want to build it. The following is a simple kernel module makefile which will help you do this:

1
2
3
4
5
6
7
obj-m += hello-1.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules (1)

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean (2)
1 modules is the target to build the kernel module
2 clean is the target to clean the kernel module
The above makefile will fail if used directly please replace the spaces at lines 4 and 7 with TABS or please download the following from here makefile1.

In this explanation there are two makefiles which I will be referring to. The first is the one shown above and the second is the main kernel makefile which is located in the kernel source directory.

When you compile the kernel the make process assembles a list of kernel drirvers and modules that are to be compiled as loadable kernel modules defined by obj-m.

In our example above we indicate that we want to create a kernel module out of the hello-1.o object file which is eventually built from our hello-1.c source code.

There are two targets for the makefile i.e. all and clean. They invoke the 'modules' and 'clean' targets of the main kernel makefile.

Let’s understand the option switches.

The -C option switches the make command to the kernel source directory. Basically this is the directory of the source code used to build the kernel image with the main kernel makefile. Here $(shell uname -r) is a convenient way of specifying the name of the live kernel being run when the make command is executed.

The M option tells the main kernel makefile to go to the present working directory and read the makefile present there. This is a way of telling the main kernel makefile to read the the makefile shown above. This enables the main kernel makefile to add the hello-1.o object to its list of modules to be built.

Here $(PWD) is a convenient way of specifying the present working directory.

More information is available at:
http://www.tldp.org/LDP/lkmpg/2.6/html/x181.html


Linux Kernel Modules

by Conrad Gomes on

A unique feature of the Linux Kernel is its ability to allow injection of code while it is running. This piece of code is called a kernel module.

The traditional approach employed by operating system designers was to add the code to the source code of the OS and build the OS as a single binary that can be booted by the boot-loader.

The kernel module can be inserted and removed at any time during the execution of the kernel giving Linux Kernel developers the flexibility to test their modules before making them a part of the mainline Kernel source code.

The process of building a stand-alone kernel module or integrating the kernel module with the source code of the Linux Kernel is simplified through the makefile of the kernel module. The source code of the kernel module remains the same irrespective of how it is built.

Information on kernel module programming can be obtained from:
http://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html


An Operating System Called Linux

by Conrad Gomes on

This post highlights the comparison of the required functionalities of an OS with that of Linux.An operating system is a software program which provides 5 management functions:

  1. CPU

  2. Memory

  3. Networking

  4. Storage

  5. Device Input/Output

Linux if one were to draw a block diagram can be represented as:

linux kernel architecture diagram
Figure 1. Linux kernel architecture diagram

In this diagram the core operating system is the Linux Kernel. The management functions which map to the generic definition of an operating system are:

  1. Process management

  2. Memory management

  3. Network

  4. File Systems

  5. Device Drivers

Applications viz. Firefox, vim, LibreOffice, Bash, etc run in the User memory space and are not part of the Linux Kernel memory space. An application interfaces with the Linux Kernel through the system call interface.


iFanaticism

by Conrad Gomes on

It’s amazing, I’m going through the news paper and I read about people in Tokyo who’ve queued outside an Apple store to buy the iPhone 4s in memory of the late Steve Jobs.

What was it about Steve Jobs that moves people not in his own country but in countries other than his own? What was it about him that caused millions to pour out their hearts on twitter and facebook when they heard of his death. Steve Jobs has been catapulted to the status of a rock-star. No other entrepreneur has ever had the admiration and adoration of millions of people. It’s pure fanaticism!

His products have been sought after by many fans. People literally stand in queues to pick up Apple’s products. They want the real deal. People don’t buy cheaper imitations from China. They find value for money in those gadgets. Enough to convert them into evangelists for Apple.

Steve Jobs now shares his place with those that inspired and evoked euphoria in the millions. People like Curt Cobain, Elvis Presley and Michael Jackson. He redefined product conceptualization. But there’s a question that comes to my mind. Steve’s best was at the end of his life. Was it his awareness of his condition that pushed him to create the best products of Apple?

Whatever it was one thing’s for sure, he’s made a dent in the universe.


Facebook Fatigue

by Conrad Gomes on

So here’s the deal Facebook’s this awesome site where over 500 million users can interact with their friends and associates. Its popularity has been unchallenged leaving companies like Google and Microsoft sitting up and paying attention.

But I’ve got a theory that Facebook’s banking too much on the social connection. Facebook’s a shiny new red toy engine. It’s what everyone wants and needs to have. But over time the red paints going to wear out and we’re going to go after shinier toys.

Facebook is cool because it’s purely web based. Awesome, but to a user Facebook offers a platform for information sharing. This information is not random, it’s personal information. It can be a video you like, a picture you love or just a status that makes you laugh.

But here’s where I draw the line. Facebook’s not doing enough to keep me dazzled. It’s chat doesn’t work as well as the Gmail Gtalk plugin. It’s difficult to marshal content so as to control who views it. It’s getting old and becoming advertising real estate which I’m not interested in. Maybe it is useful to advertisers but from personal speak I’m not looking at the ads. I just connect see if there’s anything interesting happening in my social network and log off.

Facebook launched a new e-mail service with some yap yap difference. Well guess what I don’t want to use the e-mail service. Now Google’s done well in attracting the masses away from leaders such as MSN Hotmail and Yahoo mail by offering unlimited e-mail storage. So you’ve got you’re personal e-mail with all your contacts located int one place and you’ve got your social connections located in another. Interesting. You’d like to keep the two apart because if you’re using Facebook for business you wouldn’t want associates et al dropping in on your social life. It’s the tendency to separate business and pleasure for fear of not being taken seriously.

People live different lives. Not many people can safely say they’re the same person to everyone. You’re most likely a serious person at work and a loose fun loving beer drinking friend at parties. There’s a reason why you’re not the same person. It’s because you live in different social circles. Within each circle you’re a different person.

Facebook’s got along way to go before it can match up to my take on what the next big thing is going to be. In this Google’s trying to claw its way up the social curve. But Google’s got more and continuously strives to put a fresh coat of paint on the red toy train. Google’s got millions of Gmail users who use Android phones and growing. This is where lies the value. You don’t talk to strangers. That contact list of yours is your social network at least the important one.

For now Facebook’s got to prove it’s improving and drawing more users to consider it seriously. I truly hope Mark’s got an ace up his sleeve until then I’m going to view his company as the Joker in the pack.


Beautiful Products

by Conrad Gomes on

There’s something about a beautiful product. From the moment you play with it you’re hooked.You want it, you need it and you won’t rest until its yours.

Every product available today is an idea. The idea starts off as a thought process with potential. While there are many ideas that can be turned into products only a few actually create excitement.

Beautiful products must enhance the value of life. If a product does not amplify its purpose and evoke euphoria it’s just an unnecessary object occupying space and time.

Simplicity, aesthetics & functionality maybe some of the qualities that get associated with a beautiful product however these can be achieved only through proper design and execution.

Design is the manifestation of an idea. It takes good design to push the idea from conception to existence. For an idea to be accepted well it has to be communicated well.

To the user a new feature adds value to the product.A well designed feature adds weight to the acceptance of the idea and can even revolutionize the perception of a class of products. Apple revolutionized the touch experience and introduced its users to an experience that set the benchmark for all smartphones.

The concept of touch was a feature that several phone manufacturers introduced. It was only through good design that the idea moved from a blueprint idea to a differentiating idea.

Consumers buy products and the one aspect all consumers seek is value for money. Products don’t build themselves they are developed by teams of managers and engineers. It takes proper execution to conduct an orchestra and produce a beautiful symphony. Likewise it also takes impeccable execution to produce a beautiful product.

Core to execution lies effective processes and communication. While quality is not a differentiation lack of quality will definitely downplay the expected results. So product manufacturers should constantly look back and ask themselves, "Is it enough?"

If a product is delivered is it enough? If a product fails to generate awe and interest is it enough? Could better execution set the product apart from others in its class. Execution encompasses everything from conception to realization of the product. Beautiful products do not happen by accident they grow out of beautiful execution.

In the end products will come and go but the beautiful ones will live on forever at least in our memories, in case studies and museums.