Saturday, March 29, 2014
Welcome;
We will work together, How?
In this section of my blogger New Electronic World I will put all information and tutorials about the microcontroller, but i want you interact with me How? and Why?
How?
by adding any question or comment and i will answer...
Why?
as from my experience i found that if any two or more students discuss any topic, they will aid themselves to know more...
Let's Start and try ... OK?
Read more...
Friday, March 28, 2014
Our plan:
Before any thing your must make your plan, to make the success more easy, and as we will work together
our plan must be same, so i suggest our working plan
1-Introduction.
2-Overview of the microcontroller structure:
>>> From lesson "1" to "9".
3-Full internal microcontroller structure view.
4-As the concept is same for all microcontroller types ...
we will choose one of them a go deep in it.
this micro. is "PIC16F84".
Let's Start...
Read more...
Friday, March 5, 2010
A microcontroller is an integrated chip that is often part of an embedded system. The microcontroller includes a CPU, RAM, ROM, I/O ports, and timers like a standard computer, but because they are designed to execute only a single specific task to control a single system, they are much smaller and simplified so that they can include all the functions required on a single chip.
Watch this useful video...
Read more...
Saturday, February 20, 2010
Welcome to the start of the PIC Tutorial. These pages will take you form the basic structure of the device, right through to programming methods and techniques. Also, there will be suggestions on how to modify the code so that you can adapt the PIC to suit your applications within Cybot. We will not be including any internal architecture diagrams, as this may only lead to confusion. If you want to look at the datasheet, then this can be downloaded from Microchips' web site.
Microchip PIC 16F84 Microcontroller
Microchip manufacture a series of microcontrollers called PIC. You can see the range of their microcontrollers here. There are many different flavours available, some basic low memory types, going right up through to ones that have Analogue - To- Digital converters and even PWM built in. We are going to concentrate on the 16F84 PIC. Once you have learnt how to program one type of PIC, learning the rest is easy.
There are several ways of programming the PIC - using BASIC, C, or Assembly Language. We are going to show you the Assembly Language. Don't be put off by this. There are only 35 instructions to learn, and it is the cheapest way to program the PICs, as you do not need any extra software other than the freebies.
The 16F84 Pins
Below is a diagram showing the pin-outs of the PIC 16F84. We will go through each pin, explaining what each is used for.

RA0 To RA4
RA is a bidirectional port. That is, it can be configured as an input or an output. The number following RA is the bit number (0 to 4). So, we have one 5-bit directional port where each bit can be configured as Input or Output.
RB0 To RB7
RB is a second bidirectional port. It behaves in exactly the same way as RA, except there are 8 - bits involved.
VSS And VDD
These are the power supply pins. VDD is the positive supply, and VSS is the negative supply, or 0V. The maximum supply voltage that you can use is 6V, and the minimum is 2V
OSC1/CLK IN And OSC2/CLKOUT
These pins is where we connect an external clock, so that the microcontroller has some kind of timing.
MCLR
This pin is used to erase the memory locations inside the PIC (i.e. when we want to re-program it). In normal use it is connected to the positive supply rail.
INT
This is an input pin which can be monitored. If the pin goes high, we can cause the program to restart, stop or any other single function we desire. We won't be using this one much.
T0CK1
This is another clock input, which operates an internal timer. It operates in isolation to the main clock. Again, we won't be using this one much either.
Read more...
Friday, February 19, 2010
1-On-Chip Memory:
On-chip memory is really one of two types: Internal RAM and Special Function Register (SFR) memory.

♣ Internal RAM:
it is the most flexible in terms of reading, writing, and modifying its contents. Internal RAM is volatile.
♣ Special Function Register (SFR) :
Special Function Registers (SFRs) are areas of memory that control specific functionality of the 8051 processor. For example, four SFRs permit access to the 8051s 32 input/output lines. Another SFR allows a program to read or write to the 8051s serial port. Other SFRs allow the user to set the serial baud rate, control and access timers, and configure the 8051s interrupt system.
-------------------------------------------------------------
2-External RAM:
As an obvious opposite of Internal RAM, most of microcontrollers also supports what is called External RAM. As the name suggests, External RAM is any random access memory which is found off-chip. Since the memory is off-chip it is not as flexible in terms of accessing, and is also slower. For example, to increment an Internal RAM location by 1 requires only 1 instruction and 1 instruction cycle. To increment a 1-byte value stored in External RAM requires 4 instructions and 7 instruction cycles. In this case, external memory is 7 times slower!
-------------------------------------------------------------
3-Code Memory:
Code memory is the memory that holds the actual program that is to be run. This memory has different values from one microcontrolle to another and comes in many shapes and sizes: Code memory may be found on-chip, either burned into the microcontroller as ROM or EPROM. Code may also be stored completely off-chip in an external ROM or, more commonly, an external EPROM. Flash RAM is also another popular method of storing a program. Various combinations of these memory types may also be used.
Read more...
Thursday, February 18, 2010
Central Processing Unit:
The basic tasks of the Central Processing Unit (CPU) is multiply, divide, subtract, and move its contents from one memory location onto another, the (CPU) consists of 3 more memory locations which called registers.

Registers are therefore memory locations whose role is to help with performing various mathematical operations or any other operations with data wherever data can be found. Look at the current situation. We have two independent entities (memory and CPU) which are interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for example, we wish to add the contents of two memory locations and return the result again back to memory, we would need a connection between (memory and CPU). Simply stated, we must have some "way" through data goes from one block to another.
Read more...
Wednesday, February 17, 2010
Bus:
We must have some "way" through data goes from one block to another,
That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires.

There are two types of buses:
1-Address bus:
it consists of as many lines as the amount of memory we wish to address, and serves to transmit address from CPU memory.
2-Data bus:
it is as wide as data, in our case 8 bits or the connection line. First one , and connect all blocks inside the microcontroller.
Read more...
Tuesday, February 16, 2010
Input - output unit:
Those locations we've just added are called "ports".
There are several types of ports : input, output or bidirectional ports.
When working with ports, first of all it is necessary to choose which port we need to work with, and then to send data to, or take it from the port.

When working with it the port acts like a memory location. Something is simply being written into or read from it, and it could be noticed on the pins of the microcontroller.
Read more...
Monday, February 15, 2010
Serial communication:
Beside stated above we've added to the already existing unit the possibility of communication with an outside world. However, this way of communicating has its drawbacks. One of the basic drawbacks is the number of lines which need to be used in order to transfer data. What if it is being transferred to a distance of several kilometers?
The number of lines times number of kilometers doesn't promise the economy of the project. It leaves us having to reduce the number of lines in such a way that we don't lessen its functionality. Suppose we are working with three lines only, and that one line is used for sending data, other for receiving, and the third one is used as a reference line for both the input and the output side.
In order for this to work, we need to set the rules of exchange of data. These rules are called "protocol".
Protocol:
it is therefore defined in advance so there wouldn't be any misunderstanding between the sides that are communicating with each other.
For example, if one man is speaking in French, and the other in English, it is highly unlikely that they will quickly and effectively understand each other. Let's suppose we have the following protocol.
As we have separate lines for receiving and sending, it is possible to receive and send data (info.) at the same time. So called full-duplex mode block which enables this way of communication is called a serial communication block. Unlike the parallel transmission, data moves here bit by bit, or in a series of bits what defines the term serial communication comes from. After the reception of data we need to read it from the receiving location and store it in memory as opposed to sending where the process is reversed. Data goes from memory through the bus to the sending location, and then to the receiving unit according to the protocol.
Read more...
Sunday, February 14, 2010
Timer unit:
Since we have the serial communication explained, we can receive, send and process data.

However, in order to utilize it in industry we need a few additionally blocks. One of those is the timer block which is significant to us because it can give us information about time, duration, protocol etc. The basic unit of the timer is a free-run counter which is in fact a register whose numeric value increments by one in even intervals, so that by taking its value during periods T1 and T2 and on the basis of their difference we can determine how much time has elapsed. This is a very important part of the microcontroller whose understanding requires most of our time.
Read more...
Saturday, February 13, 2010
Watchdog:One more thing is requiring our attention is a flawless functioning of the microcontroller during its run-time. Suppose that as a result of some interference (which often does occur in industry) our microcontroller stops executing the program, or worse, it starts working incorrectly.
Of course, when this happens with a computer, we simply reset it and it will keep working. However, there is no reset button we can push on the microcontroller and thus solve our problem. To overcome this obstacle, we need to introduce one more block called watchdog. This block is in fact another free-run counter where our program needs to write a zero in every time it executes correctly. In case that program gets "stuck", zero will not be written in, and counter alone will reset the microcontroller upon achieving its maximum value. This will result in executing the program again, and correctly this time around. That is an important element of every program to be reliable without man's supervision.
Read more...
Friday, February 12, 2010
Analog to Digital Converter:
As the peripheral signals usually are substantially different from the ones that microcontroller can understand (zero and one), they have to be converted into a pattern which can be comprehended by a microcontroller. This task is performed by a block for analog to digital conversion or by an (ADC). This block is responsible for converting an information about some analog value to a binary number and for follow it through to a (CPU) block so that (CPU) block can further process it.

Read more...
Thursday, February 11, 2010

Finally, the microcontroller is now completed, and all we need to do now is to assemble it into an electronic component where it will access inner blocks through the outside pins. The picture below shows what a microcontroller looks like inside.
Thin lines which lead from the center towards the sides of the microcontroller represent wires connecting inner blocks with the pins on the housing of the microcontroller so called bonding lines. Chart on the following image represents the center section of a microcontroller.
For a real application, a microcontroller alone is not enough. Beside a microcontroller, we need a program that would be executed, and a few more elements which make up a interface logic towards the elements of regulation (which will be discussed in later lessons).
Read more...
Wednesday, February 10, 2010
PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. Its general structure is shown on the following map representing basic blocks.
Program memory (FLASH) for storing a written program. Since memory made in FLASH technology can be programmed and cleared more than once, it makes this microcontroller suitable for device development.
EEPROM data memory that needs to be saved when there is no supply.It is usually used for storing important data that must not be lost if power supply suddenly stops. For instance, one such data is an assigned temperature in temperature regulators. If during a loss of power supply this data was lost, we would have to make the adjustment once again upon return of supply. Thus our device looses on self-reliance.
RAM data memory used by a program during its execution.In RAM are stored all inter-results or temporary data during run-time.
PORTA and PORTB are physical connections between the microcontroller and the outside world. Port A has five, and port B eight pins.
FREE-RUN TIMER is an 8-bit register inside a microcontroller that works independently of the program. On every fourth clock of the oscillator it increments its value until it reaches the maximum (255), and then it starts counting over again from zero. As we know the exact timing between each two increments of the timer contents, timer can be used for measuring time which is very useful with some devices.
CENTRAL PROCESSING UNIT has a role of connective element between other blocks in the microcontroller. It coordinates the work of other blocks and executes the user program.
Read more...
Tuesday, February 9, 2010
PIC16F84 has a total of 18 pins.

Pins on PIC16F84 microcontroller have the following meaning:
Pin no.1 RA2 Second pin on port A. Has no additional function.
Pin no.2 RA3 Third pin on port A. Has no additional function.
Pin no.3 RA4 Fourth pin on port A. TOCK1 which functions as a timer is also found on this pin.
Pin no.4 MCLR Reset input and Vpp programming voltage of a microcontroller.
Pin no.5 Vss Ground of power supply.
Pin no.6 RB0 Zero pin on port B. Interrupt input is an additional function.
Pin no.7 RB1 First pin on port B. No additional function.
Pin no.8 RB2 Second pin on port B. No additional function.
Pin no.9 RB3 Third pin on port B. No additional function.
Pin no.10 RB4 Fourth pin on port B. No additional function.
Pin no.11 RB5 Fifth pin on port B. No additional function.
Pin no.12 RB6 Sixth pin on port B. 'Clock' line in program mode.
Pin no.13 RB7 Seventh pin on port B. 'Data' line in program mode.
Pin no.14 Vdd Positive power supply pole.
Pin no.15 OSC2 Pin assigned for connecting with an oscillator.
Pin no.16 OSC1 Pin assigned for connecting with an oscillator.
Pin no.17 RA2 Second pin on port A. No additional function.
Pin no.18 RA1 First pin on port A. No additional function.
Read more...
Monday, February 8, 2010
First you must know that Oscillator circuit is used for providing a microcontroller with a clock. Clock is needed so that microcontroller could execute a program or program instructions.
Types of oscillators:
PIC16F84 can work with four different configurations of an oscillator. Since configurations with crystal oscillator and resistor-capacitor (RC) are the ones that are used most frequently, these are the only ones we will mention here. Microcontroller type with a crystal oscillator has in its designation XT, and a microcontroller with resistor-capacitor pair has a designation RC. This is important because you need to mention the type of oscillator when buying a microcontroller.
XT Oscillator:

Crystal oscillator is kept in metal housing with two pins where you have written down the frequency at which crystal oscillates. One ceramic capacitor of 30pF whose other end is connected to the ground needs to be connected with each pin.
Oscillator and capacitors can be packed in joint case with three pins. Such element is called ceramic resonator and is represented in charts like the one below. Center pins of the element is the ground, while end pins are connected with OSC1 and OSC2 pins on the microcontroller. When designing a device, the rule is to place an oscillator nearer a microcontroller, so as to avoid any interference on lines on which microcontroller is receiving a clock.
RC
RC Oscillator:
In applications where great time precision is not necessary, RC oscillator offers additional savings during purchase. Resonant frequency of RC oscillator depends on supply voltage rate, resistance R, capacity C and working temperature. It should be mentioned here that resonant frequency is also influenced by normal variations in process parameters, by tolerance of external R and C components, etc.

Above diagram shows how RC oscillator is connected with PIC16F84. With value of resistor R being below 2.2k, oscillator can become unstable, or it can even stop the oscillation. With very high value of R (ex.1M) oscillator becomes very sensitive to noise and humidity. It is recommended that value of resistor R should be between 3 and 100k. Even though oscillator will work without an external capacitor(C=0pF), capacitor above 20pF should still be used for noise and stability. No matter which oscillator is being used, in order to get a clock that microcontroller works upon, a clock of the oscillator must be divided by 4. Oscillator clock divided by 4 can also be obtained on OSC2/CLKOUT pin, and can be used for testing or synchronizing other logical circuits.

Read more...