Abstract: This article introduced a simple class lantern floated down river’s software and hardware design process, has given its software programming thinking method with emphasis, inspires by the time for the monolithic integrated circuit learner.
Key words: Monolithic integrated circuit; Flows the lantern floated down river; Programming
1. introduction
The present era is the time which a new technology emerges one after another incessantly, in the electronic domain particularly automation intelligent control domain, the control system which the traditional discrete component or the digital logic electric circuit constitutes, before has not seen the speed is substituted for by the monolithic integrated circuit intelligent control system. The monolithic integrated circuit has the volume to be small, the function is strong, the cost is low, application surface broad and so on merits, may say, the intelligent control and automatic control’s core is a monolithic integrated circuit. At present, a study with using monolithic integrated circuit’s high tide factory, the school and the Enterprises and institutions emerges massively. Studies monolithic integrated circuit’s most efficacious device is the theory and the practice pays equal attention to, this article author with a AT89C51 monolithic integrated circuit self-restraint section of simple class lantern floated down river, introduced with emphasis its software programming method, inspires by the time for the monolithic integrated circuit beginner, becomes the monolithic integrated circuit domain quickly outstanding talent.
2. hardware composition
According to the monolithic integrated circuit system expansion and the system disposition condition, the monolithic integrated circuit application system may divide into the smallest system, the smallest power loss systematic and the canonical system and so on. At89C51 monolithic integrated circuit is the low voltage which, the high performance CMOS 8 monolithic integrated circuits American ATMEL Corporation produces, has the rich internal resources: 4kB dodges saves, 128BRAM, 32 I/O mouth line, 2 16 fixed time/counters, 5 vector two level of interrupt structures, 2 full-duplex’s serial port, has the 4.25~5.50V voltage operating region and the 0~24MHz operating frequency, uses when at89C51 monolithic integrated circuit outside does not need to expand the memory. Therefore, the mother current lantern floated down river in fact is one has eight light emitter diode’s monolithic integrated circuit smallest application system, namely for the single monolithic integrated circuit which by electric circuits and the essential software and so on light emitter diode, crystal oscillator, replacement, power source is composed. Its concrete hardware composition as shown in Figure 1.
Figure 1 class lantern floated down river hardware schematic diagram
May see from the schematic diagram, if must let meet shines in P1.0 mouth LED1, so long as then became the P1.0 mouth’s level the low level to be possible; On the contrary, if must meet in P1.0 the mouth LED1 extinguishment, must become the P1.0 mouth level the high level; Likewise, meets in P1.1~P1.7 mouth other 7 LED lightening with the extinguishment method with LED1. Therefore, must realize the class lantern floated down river function, so long as we light emitter diode LED1~LED8 will lighten, the extinguishment in turn, 8 LED lamps then met one brightly one dark make the class lantern floated down river. In this we should also pay attention to a spot, because the human eye persistence of vision effect as well as the monolithic integrated circuit carry out each instruction time to be very short, we in control the time which the diode extinguishes brightly should time delay period of time, otherwise we did not look at “the running water” the effect.
3. software programming
Monolithic integrated circuit’s application system is composed of the hardware and the software, after the above hardware schematic diagram build completes on the electricity, we have not been able to see the class lantern floated down river circulation lightens the phenomenon, how we also do need to tell the monolithic integrated circuit to carry on the work, as soon as namely the write program control monolithic integrated circuit base pin level’s height change, realizes the light emitter diode one brightly to extinguish. The software programming is in a monolithic integrated circuit application system’s important constituent, is the monolithic integrated circuit study key point and the difficulty. Below we the class lantern floated down river control function namely realize 8 LED lamp’s circulation by the simple to lighten, introduced that realizes several software programming method which the class lantern floated down river controls.
3.1 control the law
This is one kind quite stupid, but is also easiest the method which understood, uses the sequential program structure, with position command control P1 mouth each units place output height level, thus controls the corresponding LED lamp to extinguish brightly. The procedure is as follows:
ORG 0000H ; On after monolithic integrated circuit electricity, from 0000H address execution
AJMP START ; Skips to the master routine depositing address place
ORG 0030H ; The establishment master routine starts the address
START:MOV SP,#60H ; The establishment storehouse start address is 60H
CLR P1.0 ; P1.0 outputs the low level, causes LED1 to lighten
ACALL DELAY ; Transfer time delay subroutine
SETB P1.0 ; P1.0 outputs the high level, causes LED1 to extinguish
CLR P1.1 ; P1.1 outputs the low level, causes LED2 to lighten
ACALL DELAY ; Transfer time delay subroutine
SETB P1.1 ; P1.1 outputs the high level, causes LED2 to extinguish
CLR P1.2 ; P1.2 outputs the low level, causes LED3 to lighten
ACALL DELAY ; Transfer time delay subroutine
SETB P1.2 ; P1.2 outputs the high level, causes LED3 to extinguish
CLR P1.3 ; P1.3 outputs the low level, causes LED4 to lighten
ACALL DELAY ; Transfer time delay subroutine
SETB P1.3 ; P1.3 outputs the high level, causes LED4 to extinguish
CLR P1.4 ; P1.4 outputs the low level, causes LED5 to lighten
ACALL DELAY ; Transfer time delay subroutine
SETB P1.4 ; P1.4 outputs the high level, causes LED5 to extinguish
CLR P1.5 ; P1.5 outputs the low level, causes LED6 to lighten
ACALL DELAY ; Transfer time delay subroutine
SETB P1.5 ; P1.5 outputs the high level, causes LED6 to extinguish
CLR P1.6 ; P1.6 outputs the low level, causes LED7 to lighten
ACALL DELAY ; Transfer time delay subroutine
SETB P1.6 ; P1.6 outputs the high level, causes LED7 to extinguish
CLR P1.7 ; P1.7 outputs the low level, causes LED8 to lighten
ACALL DELAY ; Transfer time delay subroutine
SETB P1.7 ; P1.7 outputs the high level, causes LED8 to extinguish
ACALL DELAY ; Transfer time delay subroutine
AJMP START ; after 8 LED has flowed, returns circulates again to marking START place
DELAY: ; Time delay subroutine
MOV R0,#255; Time delay period of time
D1: MOV R1,#255
DJNZ R1,$
DJNZ R0, D1
RET ; Subroutine returns
END ; Procedure conclusion
3.2 end around shift law
We are control P1 port’s each units place in the previous procedure to realize one by one, therefore the procedure appears a little complex, below we use the end around shift instruction, uses the cyclic program structure to carry on the programming. We give the P1 mouth in the procedure to deliver a number from the very beginning, this counts itself to let P1.0 be first low, other positions for high, then time delay period of time, then let this data to the top digit migration, then outputs again to the P1 mouth, like this realizes “the running water” the effect. Because in 8051 series monolithic integrated circuit’s instructions only then to accumulator ACC in data left shift or right lateral instruction, therefore actual programs us should the data which must move to put first to ACC, lets its migration, after then passes along again the ACC migration’s data the P1 mouth, may realize “the running water” like this similarly the effect. The concrete programming as follows shows, the program structure has been truly simple many.
ORG 0000H ; On after monolithic integrated circuit electricity, from 0000H address execution
AJMP START ; Skips to the master routine depositing address place
ORG 0030H ; The establishment master routine starts the address
START:MOV SP,#60H ; The establishment storehouse start address is 60H
MOV A,#0FEH ; In ACC loads the LED1 bright data first (binary system 11111110)
MOV P1, A ; Delivers the P1 mouth the ACC data
MOV R0,#7 ; Moves again the data 7 times completes a 8 fluvial process
LOOP: RL A ; Shifts to the left one ACC in data
MOV P1, A ; Moves the data ACC to deliver the p1 mouth demonstration
ACALL DELAY ; Transfer time delay subroutine
DJNZ R0, LOOP ; Does not have the migration to suffice 7 times to continue to move
AJMP START ; Moves 7 jumps from now on to starts to come again, achieves the circulatory flow effect
DELAY: ; Time delay subroutine
MOV R0,#255; Time delay period of time
D1: MOV R1,#255
DJNZ R1,$
DJNZ R0, D1
RET ; Subroutine returns
END ; Procedure conclusion
3.3 table look-up law
The above two procedures are the quite simple class lantern floated down river procedures, “the running water” the pattern can only realize solely “from left to right” the class way. Class lantern floated down river procedure which compiles using the table look-up law, can realize the random way running water, moreover running water pattern infinite, so long as the change running water pattern data sheet’s running water data may increase or the change running water pattern at will, realizes the class lantern floated down river effect which truly has one’s wish. We must first demonstrate that the running water pattern the data constructs in one take TAB as in the marking data sheet, then “MOVC A,@A DPTR” takes through the look-up instruction the data in accumulator A, then delivers the P1 mouth to carry on the demonstration again. The concrete source program is as follows, the TAB marking’s place data sheet may act according to realizes the effect request to revise willfully.
ORG 0000H ; On after monolithic integrated circuit electricity, from 0000H address execution
AJMP START ; Skips to the master routine depositing address place
ORG 0030H ; The establishment master routine starts the address
START:MOV SP,#60H ; The establishment storehouse start address is 60H
MOV DPTR,# TAB ; The running water pattern table first address delivers DPTR
LOOP: CLR A ; Accumulator reset
MOVC A,@A DPTR ; Takes in data sheet’s value
CJNE A,#0FFH, SHOW; Inspection running water end mark
AJMP START ; All patterns flow, then from the beginning starts the redundant class
SHOW: MOV P1, A ; Delivers the P1 mouth the data
ACALL DELAY ; Transfer time delay subroutine
INC DPTR ; Takes the data sheet indicator direction next data
AJMP LOOP ; Continues the table look-up to take the data
DELAY: ; Time delay subroutine
MOV R0,#255 ; Time delay period of time
D1: MOV R1,#255
DJNZ R1,$
DJNZ R0, D1
RET ; Subroutine returns
TAB: ; Below is the running water pattern data sheet, the user may compile willfully according to the request
DB 11111110B ; Binary expression running water pattern data, from low to the high left shift
DB 11111101B
DB 11111011B
DB 11110111B
DB 11101111B
DB 11011111B
DB 10111111B
DB 01111111B
DB 01111111B ; Binary expression running water pattern data, from high to low right lateral
DB 10111111B
DB 11011111B
DB 11101111B
DB 11110111B
DB 11111011B
DB 11111101B
DB 11111110B
DB 0FEH,0FDH,0FBH,0F7H ; Hexadecimal system expression running water pattern data
DB 0EFH,0DFH,0BFH,7FH
DB 7FH,0BFH,0DFH,0EFH
DB 0F7H,0FBH,0FDH,0FEH
……
DB 0FFH ; Running water pattern end mark 0FFH
END ; Procedure conclusion
4. conclusion
When one of after above procedures compiles, we need to use the translation software to its translation, obtains binary code which the monolithic integrated circuit can distinguish, then uses the programmer to write again the binary code fever in at89C51 monolithic integrated circuit, finally connects the good electric circuit circular telegram, we saw LED1~LED8 “the running water” the effect. This article the function which realizes to the procedure is quite simple, is for the purpose of offering a few ordinary introductory remarks so that others may offer their valuable ideas, the user may based on this expand the more complex class lantern floated down river controls, for instance keyboard control running water pattern, control class lantern floated down river demonstration digit or design and so on.
Reference:
[1] Xu Yuming, Han Yan. Monolithic integrated circuit principle and connection technology [M]. Beijing: Electronics industry publishing house, 2005.1
[2] Wan Guang resolute, strict righteousness, Xing Chunxiang. Monolithic integrated circuit experiment and practice course [M]. Beijing: Beijing University of Aeronautics and Astronautics Publishing house, 2006.4