Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Thursday, June 2, 2016

How to calculate the value of a ceramic capacitor

You might have come across situations were you needed to calculate the value of a ceramic capacitor. Today a large variety of such capacitors are available in the market but the value calculation of all remains the same. All these capacitors are marked with a three digit number code, say, 104. There are two key points to remember in the value calculation. First point is that in the marked number code the first two digits are the significant digits and the third digit is the multiplier. The second point is that the final value is in the 'pico Farad' unit (without conversion).

For example, a value 104 on the capacitor indicates that the value of the capacitor is 10 x 104 pF or 100 nano Farads (μF) or 0.1 micro Farads (μF). Some other codes and their corresponding values are given below:

Capacitor
Code
Value in pF
Value in μF
101
100
0.0001
102
1000
0.001
103
10000
0.01
104
100000
0.1
105
1000000
1


For some capacitors there will be an additional alphabet code at the end of the number marking say 104J. This alphabet code indicates the capacitor tolerance. The tolerance values are calculated as given in the table below

Code Tolerance
C ±0.25pF
J ±5%
K ±10%
M ±20%
D ±0.5pF
Z +80% / -20%

For example, 104J coded capacitor has the value 0.1 ± 5% μF. 
For a 104C coded capacitor, the value is 0.1 μF ± 0.25pF

Monday, July 23, 2012

How a software interacts with hardware? - Basics of Computer Electronics

In modern computer programming, every software is written using a software programming language. This text program (called high level language) is then converted into runnable (executable - low level language) format by special softwares called compilers(or interpreters). The specialty of this low level language is that it could be understood by a hardware (precisely a microprocessor - a type of electronic component which can perform electronic operation based on software codes). The microprocessor reads the program (low level) and perform the corresponding action.

Now the microprocessor understands a particular code by reading (actually, its sensing electronically) the bits in the particular code. For example if a microprocessor is made in such a way that it will make its 5th pin to +5 voltage level when it reads a bit sequence 0010011, then the processor perform the action whenever it reads a 0010011 in the code. In this way the actions to be performed by a particular microprocessor and the corresponding bit sequence is defined at the time the microprocessor is manufactured. As you know, in a computer system, the microprocessor is the brain, so all the operations are carried out by it.

The computer peripherals (like mouse, keyboard etc) are identified by using configuration files called drivers. These files contain the information that is to be used for interacting with the hardware. The Operating System (windows, linux etc) controls and monitors the peripheral (hardware) control and management.

Monday, March 19, 2012

Things you should know before working with Microcontroller Programming

There are a lot of things you need to know before working with your microcontroller project code. I would like to explain some of the important ones. They are:


1.  PROGRAMMING LANGUAGE: A microcontroller program can be written in 3 languages – assembly, c and hex (with the help of a computer). The first two are the practical and most widely used languages. The third method is correct but impractical for large programs.
Each language has its own advantages and disadvantages. In assembly language the program is written using the microcontroller instruction set only. This makes programming in assembly, somewhat complex. The main advantage of using assembly is its fast execution. Because of this reason assembly language is highly preferred in real time systems, for which the time constraint is a serious matter. The ‘c’ language (actually it is micro-c), as its name indicates, is written in the same syntax of the original computer ‘c’ language. The advantage of writing in ‘c’ is the availability of a large number of functions that comes in handy while programming. But the ‘c’ programs are comparatively slower than the assembly programs. In either case you need the simulator software with assembler/compiler. I recommend using the latest version of ‘Keil uVision’ if you are working on 8051 microcontroller, ‘PIC Simulator IDE’ for PIC microcontroller and ‘AVR Studio’ for the AVR microcontroller.


2.  HEX FILE: Though you are initially writing the program code in assembly or ‘c’ language you will have to convert it to hex file before you can put it (program/burn) into a microcontroller flash memory. Usually, the conversion is done by the assembler program associated with the programming (simulator) software. Then the hex file can be loaded into the microcontroller using a suitable microcontroller programmer (hardware).


3.  MICROCONTROLLER PCB CIRCUIT: I recommend that you create a basic microcontroller circuit on a General PCB with the ‘Lock/Eject type’ IC base for the microcontroller. This will help a lot during the microcontroller programming by avoiding the uneasiness and various connection problems while using the breadboard circuit and it also eliminates the need for those costly and bulky development boards.


4.  CHECK YOUR MICROCONTROLLER: Before you test your program code on a microcontroller, you should check whether the microcontroller is functional or not. This can be done by burning a simple program in the microcontroller and checking the result (output). For example, the following test code is written for the said purpose. It is written for 8051 microcontroller in the assembly language:


ORG 00H          ; initialize microcontroller

LOP:

SETB P1.0        ; make p1.0 pin high

MOV R5, #0FH     ; approx. 1s delay

LOP2:

MOV R6, #0FFH

CALL DELAY

DJNZ R5, LOP2

CLR P1.0         ; make p1.0 pin low

MOV R5, #0FH     ; approx. 1s delay

LOP3:

MOV R6, #0FFH

CALL DELAY

DJNZ R5, LOP3

JMP LOP          ; go to ‘lop’ label


;****************************************

;           1s DELAY ROUTINE

;****************************************

DELAY:

DELAYL1: MOV R7, #0FFH

DELAYL2: DJNZ R7, DELAYL2

DJNZ R6, DELAYL1

RET

END


The above code will toggle the 8051 P1.0 pin between high (+5V) and low (0V) with a delay of approximately 1 second. You can see this state switching by means of an LED (with driver-recommended) circuit connected to the P1.0 pin.