Assignment Microproccessors Luis
Assignment Microproccessors Luis
1. Assignment Aims:-
Write a program which will read an analogue voltage from the potentiometer,
convert it into an 8-bit binary number and produce a display on the LED’s such that the
higher the number, the more LED’s will be ON. In other words, the LED’s will take the
form of a Bargraph. The number of LED’s that are ON should take the form of the
following table.
The system has to receive an analog signal of entry, this sign is from 0 to 5 volts.
The volts (0 to 5) are inside a range of decimal values from 0 to 255. These decimal
values must turn into a binary code of 8 bits with it between 0000 0000 and 1111 1111.
With this range of values, it depends on the values that interfere., turn on from the 1 to 8
of the LED's that we have.
To do this, we have to see the previous table and observe what happens with the
three bits with MSB, if we see these it is possible to observe that in the range of values
for every line of the picture, the three bits MSB (5, 6, 7) are the same in the range, for
example, in the second line of the range is 0000 0001-0001 1111 and in the third line is
0010 0000-0011 1111. When the process has been observed we could continue. We can
see that one bit is incremented from 0001 to 0010 and from 0001 to 0011.
The second step consists of multiplying every range of values with a mask with the
value 1110 - 0000, with this mask only there will be the three bits with the MSB, later
we will have to do a swap between the bits LSB and MSB and will be able to obtain
0000 - xxx0 where x are the bits that it had before the MSB. The following step is to
turn to the right the bits a bit to have the three bits of major weight in the first three
positions (0,1,2).
It is say the bits of major weight they have passed to be those of minor weight, and
inversely.
S07001907 1
Microproccessors System Luis de Leon Sastre
Now, to end, the value in binary, they must be checked and depending on it, the LED's
turn into modals to described into the table..
3. The Flow Chart:-
START
INITIALISATION
PORT A/D
START A/D
CONVERSION
READ
RESULT
IS THE
RESULT
ZERO=?
NO
HASK OUT 5 LSB’s OF
THE A/D VALUE
TURN RIGHT BY
1 BIT
TAKE DISPLAY
PATTEN FROM
LOOK-UP TABLE
DISPLAY ON LED’S
ALLOW A/D
ADQUISITION TIME
START A/D
CONVERSION
S07001907 2
Microproccessors System Luis de Leon Sastre
TABLE addwf PCL,1 ;ADD PCL+1 FOR RETURN THE NUMBERS OF LED
retlw b’00000000’ ;ALL LEDs OFF
retlw b’00000001’ ;LED 0 ARE ON
retlw b’00000011’ ;LED 0,1 ARE ON
retlw b’00000111’ ;LED 0,1,2 ARE ON
retlw b’00001111’ ;LED 0,1,2,3 ARE ON
retlw b’00011111’ ;LED 0,1,2,3,4 ARE ON
retlw b’00111111’ ;LED 0,1,2,3,4,5 ARE ON
retlw b’01111111’ ;LED 0,1,2,3,4,5,6 ARE ON
retlw b’11111111’ ;LED 0,1,2,3,4,5,6,7 ARE ON
S07001907 3
Microproccessors System Luis de Leon Sastre
Picture 1.
This screen show that the program hasn’t any errors because the line of build is
green. Build Successful.
S07001907 4
Microproccessors System Luis de Leon Sastre
Picture 2
This screen show the window with all registers when these still have 0 values.
S07001907 5
Microproccessors System Luis de Leon Sastre
Picture 3
This screen shows that the program does the conversion, and finishes when the
bit 2 of registerADCON0 changes to 0. If the program is not in the trainer PIC, this bit
must be changed by a manual form and it put to 0. When the conversion has ended, the
process continues verifying if the number is 0 or not. And so on.
S07001907 6
Microproccessors System Luis de Leon Sastre
Picture 4
This screen shows when the record WREG has '11100000' in the binary one, to do
the AND with the result of the conversion, to have only 3 MSB (bit7, bit6, bit5). Then
the change has to be done to have this bit in the positions bit3, bit2 and bit1 of the
record of RESULT, to finish, the record of RESULT has to turn a bit to the right.
S07001907 7
Microproccessors System Luis de Leon Sastre
Picture 5
This is the final screen, this shows that in the PORTB there is a number in
binary with the exact number of the led's that must be connected, in this case in which
the number, the first three bits were 5, the number of the led's that must be connected is
six (the led's 0 to 5).
S07001907 8
Microproccessors System Luis de Leon Sastre
When the simulation has ended and the works of the program have executed
and realized correctly the following step it is the load the program in the PIC and to
check that the system works according to the specific asked information.
In the following pictures we can observe that the system works well.
Picture 6
The uses that can be designated to the created system, can be used by certain
fields inside which they can be the mechanical, car industry and even in domestic
domiciles.
S07001907 9
Microproccessors System Luis de Leon Sastre
The best use that can give him is to realize alarms and visual alerts indicating
that a certain limit has excelled itself of some system, for example we it can use in
industries when there is exceeded a limit of load, which is illuminated determined leds,
depending on the overcharge. Or also could to use in braking systems in car, depending
on the intensity of brake, more or less leds ignitions.
Another possible purpose is for the systems that use certain conditions or states of limit,
every led, It could be a different colour, and to determine the limit.
In the great industries this system can be applied for the level of noise, for
example using a sensor, this sensor gives a variable analogical signal according to the
noise level.
8. Conclusion:
At first it is a bit complicated because you have to be familiar with the program
assembler, as are the main programming commands, the following is to see and study
the characteristics of the PIC to be programmed, and get an idea of what actually takes
to do. Studying the functionality of the program and the possible methods that would
enable its proper functioning. I had to consult parts of code and design to understand the
codes and consult websites and questions in forums. It is a code that the first time it is
difficult to understand because it is quite problematic, but after making small practices
and see the functioning of the code can understand the role of the instructions.
We start with simple and basic instructions, which are easy to understand, and little
by little more complicated structure of the programme. Using small pieces of code, it is
possible to assimilate the knowledge needed for programming in assembler.
The study and implementation of programming has proved most beneficial to develop
my level as a programmer within the functions of assembly. It is a program to reach an
expert level requires many hours of studying and understanding the instructions of the
code, but that gradually we can go to learn.
http://www.microchip.com
S07001907 10
Microproccessors System Luis de Leon Sastre
http://micropic.galeon.com/index.html
http://www-pagines.fib.upc.es/~sdmi/pdfs/ManualPicLab.pdf
http://platea.pntic.mec.es/~lmarti2/PRAC4.pdf
http://www.iesleonardo.info/ele/tra/VARIOS/t-manual_PIC/
http://www.uah.es
S07001907 11