What is Arduino – Introduction to Arduino for Beginners

Posted by Techno On mardi 28 octobre 2014 0 commentaires
In this article, we explain the basics surrounding arduino. As the title indicates, this article is for absolute beginners in the world of electronics and for people who are beginning with arduino boards.
Arduino is an electronics prototyping platform based on a micro controller. Arduino boards are usually made using Atmel’s Atmega series micro controllers or ARM micro controllers. Arduino is an open source hardware project which means the designs of board (the hardware architecture, CAD files) are available to public with open source license. Anyone can modify the hardware designs and the associated software.

What you can do with Arduino
“If you can imagine it, you can create it” – these lines best describes arduino. You can build any kind of interesting projects and applications using your arduino board. Let’s see some examples:-
1. A 4WD Robot with Remote Control – This is an interesting robotics project built using an arduino compatible board. The remote control in this project is created using the XBEE radio. You may see the video given in the project article to see how the robot operates.
2. GPS Cat Tracker – is another interesting project created using TinyDuino (another arduino compatible board). This project helps to track any moving object or living being using GPS.
There are hundreds of different projects that you can try with arduino. I have listed just 2 of them. In the coming days, we will be publishing many different projects based on Arduino. Subscribe to our Email Newsletter to receive exciting new projects in your email.

The Arduino Platform

Arduino was originally designed for non technical people. In fact, the founders of Arduino designed it for creative people like visual artists, digital designers and the likes. It is very clear from the book written by one of the Arduino founder Massimo Banzi.
“Arduino is composed of two major parts:the Arduino board, which is the piece of hardware you work on when you build your objects; and the arduino IDE, the piece of software you run on your computer. You use the IDE to create a sketch (a little computer program) that you upload to the arduino board. The sketch tells the board what to do.”
This is one of the simplest description given to an electronics prototyping board, and is easily understood by anyone. I will be coming up with a detailed article on Arduino hardware and software next – in which I will explain the board in detail. The photograph given below is the side view of Arduino Uno board made in Italy.


READ MORE

Difference between a Microprocessor and Microcontroller

Posted by Techno On 1 commentaires
Most of time this question is come to our mind that what is the Difference between a Microprocessor and Microcontroller ? Because both are used for mostly same purpose. So clear the doubt first we should know WHAT IS A MICROCONTROLLER? Two describe the difference I should mansion that these two devices are similar, but with a little bit of difference. A Microprocessor which is the heart of these devices needs a host of external devices to make it communicate with real-world. That means for a complete system would need a system to read the inputs or data from keyboard, after processing the result should write outputs to a terminal, need to store intermediate processing data into some memory, and finally it should need a place where to keep permanent information into some safe place. To make the successful system all those additional devices which are independent circuits, work in harmony with the Microprocessor, to make one system. This makes the system more flexible that means you can add more memory, change capacity of hard drives, add or remove CD-ROMs, sound cards etc and also the cost of maintanence is reduced like for a memory storage problem you just need to change the memory unit not the total system.
A microcontroller on the other hand is made up of most of these devices built exactly within the same package. Your microcontrollerDifference between a Microprocessor and Microcontroller will therefore contain, the Microprocessor, RAM, ROM, Timers, I/O etc. all packed within one integrated circuit. This facilitates the development process, as well as reduce the requirements of external components, however this also means you cannot change, the number and type of integrated devices. The applications where a microcontroller will be used, vary. They are usually quite simple, and do not require as much processing power as a Microprocessor system needs, so the microcontrollers with varying amounts of RAM, ROM, I/O lines and timers etc have been made available. Essentially all are almost same, and they only vary in the number of resources available on them. So for a particular application you chose a microcontroller, not the one which has maximum resources, but the one which has just enough to do the job.
Thus a microcontroller is a complete, small scale computer with all the necessary devices on-board. All you need is the external hardware, which you want to drive, like sensors and motors etc.


READ MORE

Basics of Microcontrollers

Posted by Techno On 1 commentaires

Microcontrollers

This post is the continuation of the post INTRODUCTION TO PIC.
Microcontroller is a single chip micro computer made through VLSI fabrication. A microcontroller also called an embedded controller because the microcontroller and its support circuits are often built into, or embedded in, the devices they control. A microcontroller is available in different word lengths like microprocessors (4bit,8bit,16bit,32bit,64bit and 128 bit microcontrollers are available today).

Microcontroller Chip
You can find microcontrollers in all kinds of electronic devices these days. Any device that measures, stores, controls, calculates, or displays information must have a microcontroller chip inside. The largest single use for microcontrollers is in automobile industry (microcontrollers widely used for controlling engines and power controls in automobiles). You can also find microcontrollers inside keyboards, mouse, modems, printers, and other peripherals. In test equipments, microcontrollers make it easy to add features such as the ability to store measurements, to create and store user routines, and to display messages and waveforms. Consumer products that use microcontrollers include digital camcorders, optical players, LCD/LED display units, etc. And these are just a few examples.
1) A microcontroller basically contains one or more following components:
  • Central processing unit(CPU)
  • Random Access Memory)(RAM)
  • Read Only Memory(ROM)
  • Input/output ports
  • Timers and Counters
  • Interrupt Controls
  • Analog to digital converters
  • Digital  analog converters
  • Serial interfacing ports
  • Oscillatory circuits
2) A microcontroller internally consists of all features required for a computing system and functions as a computer without adding any external digital parts in it.
3) Most of the pins in the microcontroller chip can be made programmable by the user.
4) A microcontroller has many bit handling instructions that can be easily understood by the programmer.
5) A microcontroller is capable of handling Boolean functions.
6) Higher speed and performance.
7) On-chip ROM structure in a microcontroller provides better firmware security.
8 ) Easy to design with low cost and small size.

Microcontroller structure

The basic structure and block diagram of a microcontroller is shown in the fig(1).
Microcontroller Structure
  • CPU
CPU is the brain of a microcontroller .CPU is responsible for fetching the instruction, decodes it, then finally executed. CPU connects every part of a microcontroller into a single system. The primary function of CPU is fetching and decoding instructions. Instruction fetched from program memory must be decoded by the CPU.
  • Memory
The function of memory in a microcontroller is same as microprocessor. It is used to store data and program. A microcontroller usually has a certain amount of RAM and ROM (EEPROM, EPROM, etc) or flash memories for storing program source codes.
  • Parallel input/output ports
Parallel input/output ports are mainly used to drive/interface various devices such as LCD’S, LED’S, printers, memories, etc to a microcontroller.
  • Serial ports
Serial ports provide various serial interfaces between microcontroller and other peripherals like parallel ports.
  • Timers/counters
This is the one of the useful function of a microcontroller. A microcontroller may have more than one timer and counters. The timers and counters provide all timing and counting functions inside the microcontroller. The major operations of this section are perform clock functions, modulations, pulse generations, frequency measuring, making oscillations, etc. This also can be used for counting external pulses.
  • Analog to Digital Converter (ADC)
ADC converters are used for converting the analog signal to digital form. The input signal in this converter should be in analog form (e.g. sensor output) and the output from this unit is in digital form. The digital output can be use for various digital applications (e.g. measurement devices).
  • Digital to Analog Converter (DAC)
DAC perform reversal operation of ADC conversion.DAC convert the digital signal into analog format. It usually used for controlling analog devices like DC motors, various drives, etc.
  • Interrupt control
The interrupt control used for providing interrupt (delay) for a working program .The interrupt may be external (activated by using interrupt pin) or internal (by using interrupt instruction during programming).
  • Special functioning block
Some microcontrollers used only for some special applications (e.g. space systems and robotics) these controllers containing additional ports to perform such special operations. This considered as special functioning block.

Comparison between Microprocessor and Microcontroller

The main comparison between microprocessor and microcontroller shown in fig (2).
Comparison of Micrprocessor and Microcontroller

Advantages of Microcontrollers

The main advantages of microcontrollers are given.
a)      Microcontrollers act as a microcomputer without any digital parts.
b)     As the higher integration inside microcontroller reduce cost and size of the system.
c)      Usage of microcontroller is simple, easy for troubleshoot and system maintaining.
d)     Most of the pins are programmable by the user for performing different functions.
e)      Easily interface additional RAM, ROM,I/O ports.
f)       Low time required for performing operations.

Disadvantages of Microcontrollers

a)      Microcontrollers have got more complex architecture than that of microprocessors.
b)     Only perform limited number of executions simultaneously.
c)      Mostly used in micro-equipments.
d)     Cannot interface high power devices directly.

Applications

Microcontrollers are widely used in modern electronics equipments. Some basic applications of microcontroller is given below.
a)      Used in biomedical instruments.
b)     Widely used in communication systems.
c)      Used as peripheral controller in PC.
d)     Used in robotics.
e)      Used in automobile fields.
READ MORE

What is C++ ? An Introduction to programming with C++

Posted by Techno On 0 commentaires
I am beginning a series of articles about C++ programming language. So lets begin with a simple C++ program as shown below.
#include
int main()
{
cout<<"My first C++ code"<<"\t"; // This is a C++ comment
return 0;
}
This piece of code when executed, outputs a line of text " My first C++ code" on your computer screen. Lets analyse this piece of code in detail.
  • iostream.h - is called a header file
  • main() - is called a function
  • cout - is called an identifier 
  • << - is  an output operator called as "insertion" or "put to" operator
  • #include - is called a preprocessor directive
  • int - is called a data type that represents an integer data
  • return - is a keyword in C++ , used to return values to a particular function

Lets begin with main() function:-

Every C++ program must contain a main() function. We all know that a program is read by the compiler -line by line, as part of compilation. The function named as main() is the point of entry to a C++ program. The compiler enters the program through main() function and then it reads each line of code. The program terminates at the return 0 statement written at the last line of main function code block. 
The code block of main function is:-
int main()
{
function code blocks;
return 0;
}
In C++ the main function by default is of the type integer (denoted by keyword int). This means that at the end of the code block that forms the main() function, there should be a line of code that returns an integer value to main() function. This is achieved with the return 0 statement. This statement sends the value '0' to the main function and hence denotes the "end of program
Note:- The function code blocks and statements of main() function are placed inside 2 parentheses { }
Note:- Each line of statement inside a C++ program must end with a semicolon. This is to notify the compiler about "end of statement" or "end of line".

Analyzing the statement beginning with cout<<

cout<<"My first C++ code"<<"\t"; // This is a C++ comment

cout is an identifier (pronounced as C out) that represents the standard output stream. cout is a predefined object in C++, which represents the standard output stream and it's declaration is given inside the header file iostream.h. Usually the output stream will be your computer monitor.
<< is known as the insertion operator (or put to operator). It inserts contents in its right side to the object in its left side.
\t - is an escape sequence which prints a tab space on the output monitor. Similalry \n is another escape sequence which prints a new line on the output monitor.You can read more about escape seuqnces here:-Escape seuqnces in C.
\\ (double slash) is a symbol for representing comments in a C++ program. \\ is usually used to represent a single line of comment. For representing multiple line of comments we may use the comment symbol of C programming language /* */
# is a preprocessor and include is a preprocessor directive. iostream.h is the header file that contains declarations of identifiers like cout, cin and operators like << and >>
After reading the above article, try running this code:- 

#include
#include // Header file to use library function getch() in the program
int main()
{
cout<<"My first C++ code"<<"\t"; // This is a C++ comment
getch(); /* Function to hold the ouput screen "PAUSED" until we press a key*/
return 0;
}
Okay! That's enough for an introduction to C++ programming, I guess.  Now lets talk a little bit about C++ in general. It is an object oriented programming (OOP) language developed by a scientist named Bjarne Stroustrup (AT&T Bell Laboratories). He made the language by combining the features of classic C (developed by Dennies Ritchie) with the some other features (mainly object oriented programming featureclasses) of another language Simula67. So C++ is basically an extension of C programming language with the addition of class construct of Simula67. Stroustrup called the new language as 'C with classes'. Later in 1983, its name was changed to C++
READ MORE

Digital frequency meter by PIC microcontroller using timer 1

Posted by Techno On samedi 25 octobre 2014 1 commentaires

As we know frequency = Number of full circle per second. So for making frequency meter we have to count number of positive pulses for external signal which we have to measure. As I mention earlier we have to configure T1CON (Timer1 Control Register) properly as per our requirement.  For reading external clock (or pulse) we normally set the prescaler 1:1 ratio. It means we do not delay the sampling of the external pulse, but treat the external clock as it is to count number of pulses for specified time duration.

So if we run Timer 1 as a counter mode, there are two pins we can use to apply the external clock pulse RC0/T1OSO and RC1/T1OSI. Selection of one of them is controlled by the T1OSCEN bit.
Setting the bit selects RC1/T1OSO and clearing it does for RC0/T1OSI. In our project as we use counter mode is synchronous, we clear the T1SYNC bit. For TMR1CS bit, we set it for external clock counting. Finally, we set the TMR1ON bit to start the Timer1 module. Counting of the rising edge of the external clock pulse would increase the TMR1 registers by one for every external clock. And TMR1 register made with two 8 bit register TMR1L and TMR1H.When the content of TMR1 crosses from FFFFh to 0000h, the Timer1 interrupt bit TMR1IF would be set, if interrupt is enabled. Usually, when we count number of pulses within a period, we disable the interrupt, and after the lapse of the time, we stop the timer and read the content of TMR1 register.
To make our project “Digital frequency meter by PIC microcontroller using timer 1” Then what will be our bit pattern of TICON register? For counting external clock pulses entered to the pin 15 RC0/T1OSO, bit pattern of T1CON register would be 00000010. When we start the counting, we set the TMR1ON, bit0 of the T1CON and that time bit pattern of T1CON register will be 00000011.

In bellow you see the circuit diagram for simulation in Proteus for our project “Digital frequency meter by PIC microcontroller using timer 1 “.



this is a video to explain you more about this project:






In bellow you will find the complete c code written in mikro c pro for pic. 


// LCD module connections

sbit LCD_RS at RB4_bit;

sbit LCD_EN at RB5_bit;

sbit LCD_D7 at RB0_bit;

sbit LCD_D6 at RB1_bit;

sbit LCD_D5 at RB2_bit;
sbit LCD_D4 at RB3_bit;sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB0_bit;
sbit LCD_D6_Direction at TRISB1_bit;
sbit LCD_D5_Direction at TRISB2_bit;
sbit LCD_D4_Direction at TRISB3_bit;
// End LCD module connections
void main() {
int c=0,i=0,z=0;
char txt[5],txt1[5],*res;;
lcd_init();
lcd_cmd(_LCD_CLEAR);
lcd_cmd(_LCD_CURSOR_OFF);
TRISC=1;
TRISB=0;
TRISD=0;
PORTD= 0;
TMR1L=0;
TMR1H=0;
lcd_out(1,1," WORKING..");
delay_ms(100);
lcd_out(1,1," WORKING….");
delay_ms(100);
lcd_out(1,1," WORKING……");
T1CON= 0B00000011;delay_ms(1000);
T1CON= 0B00000010;
c= TMR1L;
i= TMR1H * 256;
z= c+i;
IntToStr(z,txt);
lcd_cmd(_LCD_CLEAR);
delay_ms(100);
lcd_out(1,1," FREQUENCY IS");
delay_ms(100);lcd_out(2,0,txt);
lcd_out(2,7," Hz");
}


READ MORE

Advantages of PIC 18 Series over PIC 16 series

Posted by Techno On 0 commentaires
This is the common question that what are the Advantages of PIC 18 Series over PIC 16 series ? why should we use PIC 18 rather PIC 16 ?The PIC 18 Series  microcontrollers dramatically enhance the PIC core, making it suitable for advanced embedded projects. Despite many features which are new, it has been designed to make upwards migration from a 16 Series device easy, so that the designer making this move will find many things which are familiar. So to know the main Advantages of PIC 18 Series over PIC 16 series , in bellow i give some point which is similar and new advantages in pic 18 over pic 16.
The principal characteristics we shall see are:
Similar to 16 Series
• RISC (Reduced Instruction Set Computer), pipelined, 8-bit CPU, with single Working (W) and Status registers
• Many peripherals identical or very similar
• Similar packages and pinouts
• Many Special Function Register (SFR) and bit names unchanged
• All but one of the 16 Series instructions are part of the 18 Series instruction set
• Instruction cycle made up of four oscillator cycles.
New for 18 Series
• The number of instructions more than doubled, with 16-bit instruction word
• Enhanced Status register
• Hardware 8 × 8 multiply
• More external interrupts
• Two prioritised interrupt vectors
• Radically different approach to memory structures, with increased memory size
• Enhanced address generation for program and data memory
• Bigger Stack, with some user access and control
• Phase-locked loop (PLL) clock generator.

READ MORE

Introduction to PIC 16F877

Posted by Techno On vendredi 24 octobre 2014 0 commentaires
The basics of Peripheral Interface Controller have already been explained in recent posts. To know more about them, click on the links below.

Overview of PIC 16F877

PIC 16F877 is one of the most advanced microcontroller from Microchip. This controller is widely used for experimental and modern applications because of its low price, wide range of applications, high quality, and ease of availability. It is ideal for applications such as machine control applications, measurement devices, study purpose, and so on.  The PIC 16F877 features all the components which modern microcontrollers normally have. The figure of a PIC16F877 chip is shown below.
PIC 16F877

Features of PIC16F877

The PIC16FXX series has more advanced and developed features when compared to its previous series. The important features of PIC16F877 series is given below.

General Features

o   High performance RISC CPU.
o   ONLY 35 simple word instructions.
o   All single cycle instructions except for program branches which are two cycles.
o   Operating speed: clock input (200MHz), instruction cycle (200nS).
o   Up to 368×8bit of RAM (data memory), 256×8 of EEPROM (data memory), 8k×14 of flash memory.
o   Pin out compatible to PIC 16C74B, PIC 16C76, PIC 16C77.
o   Eight level deep hardware stack.
o   Interrupt capability (up to 14 sources).
o   Different types of addressing modes (direct, Indirect, relative addressing modes).
o   Power on Reset (POR).
o   Power-Up Timer (PWRT) and oscillator start-up timer.
o   Low power- high speed CMOS flash/EEPROM.
o   Fully static design.
o   Wide operating voltage range (2.0 – 5.56)volts.
o   High sink/source current (25mA).
o   Commercial, industrial and extended temperature ranges.
o   Low power consumption (<0.6mA typical @3v-4MHz, 20µA typical @3v-32MHz and <1 A typical standby).

Peripheral Features

o   Timer 0: 8 bit timer/counter with pre-scalar.
o   Timer 1:16 bit timer/counter with pre-scalar.
o   Timer 2: 8 bit timer/counter with 8 bit period registers with pre-scalar and post-scalar.
o   Two Capture (16bit/12.5nS), Compare (16 bit/200nS), Pulse Width Modules (10bit).
o   10bit multi-channel A/D converter
o   Synchronous Serial Port (SSP) with SPI (master code) and I2C (master/slave).
o   Universal Synchronous Asynchronous Receiver Transmitter (USART) with 9 bit address detection.
o   Parallel Slave Port (PSP) 8 bit wide with external RD, WR and CS controls (40/46pin).
o   Brown Out circuitry for Brown-Out Reset (BOR).

Key Features

o   Maximum operating frequency is 20MHz.
o   Flash program memory (14 bit words), 8KB.
o   Data memory (bytes) is 368.
o   EEPROM data memory (bytes) is 256.
o   5 input/output ports.
o   3 timers.
o   2 CCP modules.
o   2 serial communication ports (MSSP, USART).
o   PSP parallel communication port
o   10bit A/D module (8 channels)

Analog Features

o   10bit, up to 8 channel A/D converter.
o   Brown Out Reset function.
o   Analog comparator module.

Special Features

o   100000 times erase/write cycle enhanced memory.
o   1000000 times erase/write cycle data EEPROM memory.
o   Self programmable under software control.
o   In-circuit serial programming and in-circuit debugging capability.
o   Single 5V,DC supply for circuit serial programming
o   WDT with its own RC oscillator for reliable operation.
o   Programmable code protection.
o   Power saving sleep modes.
o   Selectable oscillator options.

Pin Diagrams

PIC16F877 chip is available in different types of  packages. According to the type of applications and usage, these packages are differentiated. The pin diagrams of a PIC16F877 chip in different packages is shown in the figure below.

Pin Diagrams of PIC 16F877 Chip

Input/output ports

PIC16F877 has 5 basic input/output ports. They are usually denoted by PORT A (R A), PORT B (RB), PORT C (RC), PORT D (RD), and PORT E (RE). These ports are used for input/ output interfacing. In this controller, “PORT A” is only 6 bits wide (RA-0 to RA-7), ”PORT B” , “PORT C”,”PORT D” are only 8 bits wide (RB-0 to RB-7,RC-0 to RC-7,RD-0 to RD-7), ”PORT E” has only 3 bit wide (RE-0 to RE-7).
All these ports are bi-directional. The direction of the port is controlled by using TRIS(X) registers (TRIS A used to set the direction of PORT-A, TRIS B used to set the direction for PORT-B, etc.). Setting a TRIS(X) bit ‘1’ will set the corresponding PORT(X) bit as input. Clearing a TRIS(X) bit ‘0’ will set the corresponding PORT(X) bit as output.
(If we want to set PORT A as an input, just set TRIS(A) bit to logical ‘1’ and want to set PORT B as an output, just set the PORT B bits to logical ‘0’.)
o   Analog input port (AN0 TO AN7) : these ports are used for interfacing analog inputs.
o   TX and RX: These are the USART transmission and reception ports.
o   SCK: these pins are used for giving synchronous serial clock input.
o   SCL: these pins act as an output for both SPI and I2C modes.
o   DT: these are synchronous data terminals.
o   CK: synchronous clock input.
o   SD0: SPI data output (SPI Mode).
o   SD1: SPI Data input (SPI mode).
o   SDA: data input/output in I2C Mode.
o   CCP1 and CCP2: these are capture/compare/PWM modules.
o   OSC1: oscillator input/external clock.
o   OSC2: oscillator output/clock out.
o   MCLR: master clear pin (Active low reset).
o   Vpp: programming voltage input.
o   THV: High voltage test mode controlling.
o   Vref (+/-): reference voltage.
o   SS: Slave select for the synchronous serial port.
o   T0CK1: clock input to TIMER 0.
o   T1OSO: Timer 1 oscillator output.
o   T1OS1: Timer 1 oscillator input.
o   T1CK1: clock input to Timer 1.
o   PGD: Serial programming data.
o   PGC: serial programming clock.
o   PGM: Low Voltage Programming input.
o   INT: external interrupt.
o   RD: Read control for parallel slave port.
o   CS: Select control for parallel slave.
o   PSP0 to PSP7: Parallel slave port.
o   VDD: positive supply for logic and input pins.
o   VSS: Ground reference for logic and input/output pins.
Take a look at the specifications of the PIC 16F87X Series
PIC 16F87X Specifications
To know more about the Architecture and Memory Organization of PIC 16F877, click on the link below.
READ MORE