Sunday 22 April 2012

Serial Port Manipulation in Java

What we have today? Serial Port Manipulation in Java. Java seems to be popular for its high level user applications and Web application. But most of us, hobbyists use C for almost all our jobs to deal with hardwares.

   What do Java have for us. To be honest, Java is not good enough for ES programming or Driver development, because it is not meant to be. We have been struggling for getting precise delay for running a Servo motor by pulsing DTS and RTS. ( have a look at Serial Port Manipulation in C) Unfortunately the PC doesn't have the capability to provide precision.

   We then tried to use Tx and Rx terminals. That was just an experiment, where we really learnt quite a few things.The code that follows will count up to three. It can be tested by connecting two leds b/w DTS & GND  and RTS & GND respectively.

Hardware Section:


Refer to Serial Port Manipulation in C for RS232 pin-out....


We used an USB-Serial(DB9) converter as the interface.













RS232 male-female






Simple GUI to control the binary counter




Output in LED diplay




Coding:

We have used RXTXcomm library to access the Serial port. We need to add 3 jar files (core.jar,   RXTXcomm.jar and serial.jar ) to the build path as shown in the image below:





// CommExp Class -> the class that implements necessary methods for accessing SerialPort



// BinaryCounterFrame => This class is a frame with 2 buttons for inreasing and decreasing the count. Here an instance of CommExp class is created and the methods of the class are accessed through it.
     


The code could be better with counting logic, but we are presenting what Java can do for Port interfacing not Counting logic. If you are looking for basics of Port Manipulation, have look at Serial Port Manipulation in C.

Here's a low quality video we made:




Thursday 12 April 2012

AVR guide for Hobbyists

INTRO



First things first,
 AVR ==> Advanced Virtual RISC 
 RISC ==> Reduced Instruction Set Architecture


As the name suggests, the instructions are simple and all are executed in single Instruction cycle. 

Why should Hobbyists choose AVR?

· Reduced complexity

Easy to use the features available. Consider the timers, there are a number of modes of operation but they are pretty simple to use. 

· Efficient architecture

Highly efficient core with a typical Instruction Cycle of 1MIPS    

· High flash memory (program memory)

With high program memory, more lines of code can be dumped in the flash which is always an advantage. 

· Variety

The AVR family has a lot of variety in it. The pin count of various micros ranges from 8 to 100. So, we are free to choose an AVR uC based on our specific needs. 


Types of 8-bit AVR micros:

1.Tiny

They are small yet powerful. Low power consumption. They are used to shrink the project size in times of space limitations. Typical flash size of 2Kb. 

2.Mega

These are general purpose 8-bit micros with a pin count of 28 to 100pins. Consist of more peripherals and features compared to tiny. 

3.Xmega

These micros are similar to Mega in terms of flash size, pin count etc. But they have better performance than Mega series. In fact X in Xmega refers to Extreme-performance. They have additional features like DMA, Event System etc, which are absent in Mega.




We are gonna work with Atmega8 uC in the fore coming posts. Lets take a look at some of the features of Atmega8 uC.

Features Available:

1.10 bit ADC

It converts analog input given externally at a pin into a digital number of 10 bit length. This number ranges from 0H to 3FFH (in Hex), 0 to 1024 (in dec).The least input voltage that can give 1bit change in the digital number is (Vstep= Vmax/1024) approximately 5mV considering the range of input voltage as 0 to 5V. 

2.PWM generation

3.Highly flexible Timers

4.Internal RC oscillator

5.External and Internal Interrupts

6.TWI(I2C) and SPI interfaces










Sunday 8 April 2012

Guides : Basics Of Programming

     I had an intention to write a book just after completing my higher secondary to help students, and make them learn thing easily. But at that time, with very little experience in writing articles, how could I write a book. Also I didn't have expertise in any field. But the idea writing a book for C-programming strike long ago in the beginning of 2010. But I came to know that there are much better books available in internet, why should I write one.

Book Cover

    After completing the fourth semester, I realized that pupil still do not have enough experience with C-programming. I started writing this guide, with a title of "Programming in C for Embedded System". I have asked my fellow students about this, but the questions they asked me narrowed my research. I started rephrasing them into Basic constructs Programming text. It took nearly two weeks to finish with my so called record works. I thought I could publish this guide before a week. Unfortunately I was unable to complete the text. And finally, here it is.

      Section 01: Variables and Arrays
      Section 02: Execution and Control Flow
      Section 03: Functions

    Say something in comments sections.

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More