-->
Showing posts with label Electronics. Show all posts
Showing posts with label Electronics. Show all posts

Electronic Circuits - AMIE

By
Electronic Circuits 
                                                            AMIE Syllabus Tutorials 



 Transistors Bipolar Junction Transistor
Transistors are three terminal active devices made from different semiconductor materials that can act as either an insulator or a conductor by the application of a small signal voltage. The transistor's ability to change between these two states enables it to have two basic functions: "switching" (digital electronics) or "amplification" (analogue electronics). Then bipolar transistors have the ability to operate within three different regions:

Bipolar Transistor basic construction consists of two PN-junctions producing three connecting terminals with each terminal being given a name to identify it from the other two. These three terminals are known and labelled as the Emitter ( E ), the Base ( B ) and the Collector ( C ) respectively.



 Biasing technique 
Applying suitable DC voltage across the terminal of the transistor is called Biasing 







                                                                                                                Emitter Base       Collector Base

Operation Mode of BJT  are follows  
 1. Active Region   -   the transistor operates as an amplifier                       Forward               Reverse
 2. Saturation   -   the transistor is "fully-ON" operating as a switch             Forward               Forward
 3. Cut-off   -   the transistor is "fully-OFF" operating as a switch .              Reverse                Reverse

According to the  circuit arrangement the transistor can be mainly connected  in three configuration 
1. Common Base Configuration   -   has Voltage Gain but no Current Gain
2. Common Emitter Configuration   -   has both Current and Voltage Gain.  
3. Common Collector Configuration   -   has Current Gain but no Voltage Gain.

 1).Common Base Configuration
In this arrangement the Emitter Base junction is Froward biased ,and the base collector junction is reverse biased  
The emitter current IE flows as input current and the Collector current IC flows as output current .any change in the IE current makes a similar current changes in IC 
The ratio of collecter current to the emitter current  is called current amplification factor .(Alpha, α).
          IC                          Output 
α =  ---------  =            ------------------         
          IE                           Input
The Ic cosist of two current IC and IB ,comparatively  IB is too small current.

          






Timers & 8051 Timer Programming

By

8051 microcontroller has two Timers designated as Timer0 and Timer1. 
Each of these timers is assigned a 16-bit register. 
The value of a Timer register increases by one every time a timer counts. 
Timer takes a time period of one machine cycle to count one. 
(Machine cycle is a unit that refers to the time required by the microcontroller to execute instructions.) 
This means that the maximum number of times a timer can count without repeating is 216, i.e., 65536. 
So the maximum allowed counts in value of Timer registers can be from 0000H to FFFFH. 
Since 8051 is an 8 bit controller, 
the registers of 8051 Timers are accessed as two different registers; 
one for lower byte and other for higher byte. 
For example, register of Timer0 is accessed as TL0 for lower byte and TH0 for higher byte. 
Similarly TL1 and TH1 are registers assigned to Timer 1.

Keil IDE Tutorials

By

Micro vision Keil -IDE
Keil is a cross compiler. So first we have to understand the concept of compilers and cross compilers. After then we shall learn how to work with keil.
Concept of compiler: -
Compilers are programs used to convert a High Level Language to object code. Desktop compilers produce an output object code for the underlying microprocessor, but not for other microprocessors. I.E the programs written in one of the HLL like ‘C’ will compile the code to run on the system for a particular processor like x86 (underlying microprocessor in the computer). For example compilers for Dos platform is different from the Compilers for Unix platform

So if one wants to define a compiler then compiler is a program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instruction. See there is a bit little difference between compiler and an interpreter. Interpreter just interprets whole program at a time while compiler analyzes and execute each line of source code in succession, without looking at the entire program.

The advantage of interpreters is that they can execute a program immediately. Secondly programs produced by compilers run much faster than the same programs executed by an interpreter. However compilers require some time before an executable program emerges. Now as compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language.

Concept of cross compiler: -
A cross compiler is similar to the compilers but we write a program for the target processor (like 8051 and its derivatives) on the host processors (like computer of x86)
It means being in one environment you are writing a code for another environment is called cross development. And the compiler used for cross development is called cross compiler

So the definition of cross compiler is a compiler that runs on one computer but produces object code for a different type of computer. Cross compilers are used to generate software that can run on computers with a new architecture or on special-purpose devices that cannot host their own compilers. Cross compilers are very popular for embedded development, where the target probably couldn't run a compiler. Typically an embedded platform has restricted RAM, no hard disk, and limited I/O capability. Code can be edited and compiled on a fast host machine (such as a PC or Unix workstation) and the resulting executable code can then be downloaded to the target to be tested. Cross compilers are beneficial whenever the host machine has more resources (memory, disk, I/O etc) than the target.  Keil C Compiler is one such compiler that supports a huge number of host and target combinations. It supports as a target to 8 bit microcontrollers like Atmel and Motorola etc.

Why do we need cross compiler?
There are several advantages of using cross compiler. Some of them are described as follows
•         By using this compilers not only can development of complex embedded systems be completed in a fraction of the time, but reliability is improved, and maintenance is easy.
•         Knowledge of the processor instruction set is not required.
•         A rudimentary knowledge of the 8051’s memory architecture is desirable but not necessary.
•         Register allocation and addressing mode details are managed by the compiler.
•         The ability to combine variable selection with specific operations improves program readability.
•         Keywords and operational functions that more nearly resemble the human thought process can be used.
•         Program development and debugging times are dramatically reduced when compared to assembly language programming.
•         The library files that are supplied provide many standard routines (such as formatted output, data conversions, and floating-point arithmetic) that may be incorporated into your application.
•         Existing routine can be reused in new programs by utilizing the modular programming techniques available with C.
•         The C language is very portable and very popular. C compilers are available for almost all target systems. Existing software investments can be quickly and easily converted from or adapted to other processors or environments.

Now after going through the concept of compiler and cross compilers lets we start with Keil C cross compiler.

Keil C cross compiler: -
Keil is a German based Software development company. It provides several development tools like
•         IDE (Integrated Development environment)
•         Project Manager
•         Simulator
•         Debugger
•         C Cross Compiler , Cross Assembler, Locator/Linker
Keil Software provides you with software development tools for the 8051 family of microcontrollers. With these tools, you can generate embedded applications for the multitude of 8051 derivatives. Keil provides following tools for 8051 development
1.     C51 Optimizing C Cross Compiler,
2.     A51 Macro Assembler,
3.     8051 Utilities (linker, object file converter, library manager),
4.     Source-Level Debugger/Simulator,
5.     µVision for Windows Integrated Development Environment.
The keil 8051 tool kit includes three main tools, assembler, compiler and linker.
An assembler is used to assemble your 8051 assembly program
A compiler is used to compile your C source code into an object file
A linker is used to create an absolute object module suitable for your in-circuit emulator.


8051 project development cycle: - these are the steps to develop 8051 project using keil
  1. Create source files in C or assembly.
  2. Compile or assemble source files.
  3. Correct errors in source files.
  4. Link object files from compiler and assembler.
  5. Test linked application.
Now let us start how to work with keil.

to open keil software click on start menu then program and then select keil2 (or any other version keil3 etc. here the discussion is on keil2 only). Following window will appear on your screen






you can see three different windows in this screen. 1) project work space window 2) editing window 3) output window.

Project workspace window is for showing all the related files connected with your project.

Editing window is the place where you will edit the code

Output window will show the output when you compile or build or run your project.

Now to start with new project follow the steps
  • click on project menu and select new project
  • you will be asked to create new project in specific directory
  • just move to your desired directory and there create a new folder for your project named "first". Here I am creating new project in d:\keil2\myprojects\first as shown in figure













  •  give the name of project as "test". By default it will be saved as *.v2 extension.
  • now you will be asked to chose your target device for which you want to write the program.
  • scroll down the cursor and select generic from list. expand the list and select 8051 (all variants)















    when you click OK, you will be asked to add startup code and file to your project folder. click yes. Now on your screen expand target1 list fully. You will see following window.
















  • now click on file menu and select new file. editor window will open. Now you can start writing your code.
  • as you start writing program in C, same way here also you have to first include the header file. Because our target is 8051 our header file will be "reg51.h"


  • after including this file. just right click on the file and select open document <reg51.h>. The following window will appear

















  • if you scroll down cursor you will see that all the SFRs like P0-P3, TCON, TMOD, ACC, bit registers and byte registers are already defined in this header file. so one can directly use these register names in coding
  • now you can write your program same as c language starting with void main()
  • after completing the code save the file in project folder with ".c" extension.
  • now right click on "source group 1" in project workspace window. select "add files to source gorup 1"
  • select the C file you have created and click add button














  • you will see that the c file has been added in source group
  • now to compile the program from project menu select "build target". In the output window you will see the progress
  • if there is any compilation error then target will not be created. Remove all the errors and again build the target till you find "0 Error(s)"
  • now you are ready to run your program. from debug menu select "start/stop debug session"
  • you will see your project workspace window now shows most of the SFRs as well as GPRs r0-r7. also one more window is now opened named "watches". in this window you can see different variable values. 


















  • to add variable in watch window goto "watch#1" tab. then type F2 to edit and type the name of your variable
  • if you want to see the output on ports go to peripheral menu and select I/O ports. select the desire port. you can give input to port pins by checking or unchecking any check box. here the check mark means digit 1 and no check mark means 0. the output on the pin will be shown in same manner
  • to run the program you can use any of the option provided "go", "step by step", "step forward", "step ove" etc.
  • now after testing your program you need to down load this program on your target board that is 8051. for this you have to create hax file
  • to create hex file first stop debug session. Again you will be diverted to project workspace window.
  • right click on "target 1" and select "option for target 1". Following window will appear.





    • select output tag and check "create hex file" box
    • now when you again build your program you will see the message in output window "hex file is created".
    • in your project folder you can see the hex file with same name of your project as "test.hex".
    • this file you can directly load in 8051 target board and run the application on actual environment.

    So here I have described the procedure to create a project in keil for 8051 micro controller. To see some sample programs for 8051 in keil just go through  the link "sample programs in keil" so that you can get the idea how to write a program for 8051 in keil C.   












LED Blinking Using 8051

By


LED Blinking Using 8051 -Proteus Simulation Tutorials

AT89C51 is an 8-bit micro-controller and belongs to Atmel's 8051 family. AT89C51 has 4KB of Flash programmable and erasable read only memory (P-EROM) and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times.

In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports. Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins, they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit addressable and so their bits can also be accessed individually.

Port P0 and P2 are also used to provide low byte and high byte addresses, respectively, when connected to an external memory. Port 3 has multiplexed pins for special functions like serial communication, hardware interrupts, timer inputs and read/write operation from external memory. AT89C51 has an inbuilt UART for serial communication. It can be programmed to operate at different baud rates. Including two timers & hardware interrupts, it has a total of six interrupts.

One can read datasheets for detailed knowledge.


Lets start with our first program to blink the LED's at the PORT-0 of the Micro-Controller.
Note that these programs are made in Keil u Vision
 
#include <REGX51.H>          // Header file
void Delay(unsigned char i); // Function calling

void main()

{

P0 = 0x00;                 //PORT 1 as Output Port
 

while (1) 
{
P0 = 0xAA;                           // 10101010

Delay(1000);

P0 = 0x55;                           // 010101010

Delay(1000);

}

}

void Delay(unsigned char itime)

{

unsigned char i;

for (i = 0; i < itime; i++);
 

}

  1. Now put the generated *.hex files in the micro-controller's memory and view the result, the output is shown below.
Any doubt Please mail me i will help you thannara123(at)gmail.com

More Posts

gElectron. Powered by Blogger.