Parallel Port Interfacing Unit 3 Parallel Port Interfacing
Interfacing of 8051 with DAC 0808
Interfacing
Program To Generate Triangular Wave ORG 0000H MOV A, #00H RISE: MOV P1, A INC A CJNE A, #0FFH, RISE FALL: MOV P1, A DEC A CJNE A, #00H, FALL SJMP RISE END
Sine Wave Generation Angle in Degrees (Ɵ) Sin(Ɵ) Count= 2.5+(2.5×sinƟ) 2.5 128 30 0.500 3.75 192 60 0.866 4.66 239 90 0.999 4.99 256 120 0.865 150 0.499 3.74 180 0.001 2.49 210 0.501 1.24 64 240 0.33 17 270 0.002 300 -0.864 0.337 330 0.497 1.255 360 0.0025 2.506
Program To Generate Sine wave ORG 0000H MOV R0, #30H ;Starting Address ; Store the Calculated Values on address from 30H MOV @R0, #128 INC R0 MOV @R0, #192 MOV @R0, #239 MOV @R0, #256
MOV @R0, #239 INC R0 MOV @R0, #192 MOV @R0, #128 MOV @R0, #64
MOV R0, #30H HERE: MOV P1,@R0 INC RO CJNE R0, #3CH, HERE MOV R0,#30H SJMP HERE END
Interfacing of Stepper Motor with 8051
Stepper Motor Structure
Full-Step Stepper Motor Coil1 Coil2 Coil3 Coil4 1 I 0CH 2 06H 3 03H 4 09H
Half-Step Stepper Motor
Half-Step Stepper Motor Coil1 Coil2 Coil3 Coil4 Hex 1 I 08H 2 0CH 3 04H 4 06H 5 02H 6 03H 7 01H 8 09H
Interfacing
ULN 2003 Driver IC
Write a Program to rotate a motor 117o in clockwise direction Write a Program to rotate a motor 117o in clockwise direction. The motor has step angle of 1.80 1 step = 1.80 Steps= 1170 X= 𝟏𝟏𝟕 𝟏.𝟖 =65 65 steps are to be given to stepper motor.
ORG 0000H MOV R0, #30H ;Starting Address ; Store the Calculated Values on address from 30H MOV @R0, #0CH INC R0 MOV @R0, #06H MOV @R0, #03H MOV @R0, #09H
MOV R0, #30H MOV R1,#65 HERE: MOV P1,@R0 INC RO DJNZ R1, NXT SJMP LAST NXT: CJNE R0, #33H, HERE MOV R0,#30H SJMP HERE LAST: END
Interfacing of Motion Detectors with 8051 Motion Detector Sensors: Passive Infrared (PIR) MircoWave (MW) Area Reflective Type(IR) Ultrasonic Vibration
Passive InfraRed Sensor(PIR)
Working Principle
InfraRed Sensor
Ultrasonic Sensor
Working Principle
Interfacing of PIR sensor with 8051
PIR EQU P2.4 LED EQU P2.3 ORG 0000H L1: JNB PIR, L1 SETB LED L2: JB PIR, L2 CLR LED SJMP L1 END
Interfacing of LM35 with 8051
Interfacing of LCD and LM35 with 8051 via ADC 0808
SEL_A EQU P3. 1 _ SEL_B EQU P3. 2 \ SEL_C EQU P3. 3 | ALE EQU P3 SEL_A EQU P3.1 _ SEL_B EQU P3.2 \ SEL_C EQU P3.3 | ALE EQU P3.4 > ADC START EQU P3.5 | EOC EQU P3.6 | OE EQU P3.7 / ADC_DATA EQU P1 _ RS EQU P2.0 | RW EQU P2.1 > LCD EN EQU P2.2 _|
ORG 0000H MOV A, #02H ACALL CMD MOV A, #38H MOV A,#0EH
MOV ADC_DATA, #0FFH ;DATA PORT TO INPUT SETB EOC ;EOC AS INPUT CLR ALE CLR OE CLR START ;REST OF OUTPUT SIGNALS MAIN: MOV A,#80H ACALL CMD SETB SEL_A CLR SEL_B CLR SEL_C ;SELECT ANALOG CHANNEL 1 SETB ALE ;LATCH CHANNEL SELECT SETB START ;START CONVERSION
CLR ALE CLR START HERE: JB EOC, HERE ;WAIT FOR END OF CONVERSION HERE1:JNB EOC, HERE1 SETB OE ;ASSERT READ SIGNAL MOV A, ADC_DATA ; READ DATA ;ADC DATA IS NOW IN ACCUMULATOR CLR OE ;START OVER FOR NEXT CONVERSION
MOV B,#256 DIV A,B MOV B,#50 MUL AB MOV B,#10
MOV R1,A ANL A,#11110000 SWAP A MOV B,#30H ADD A,B ACALL DISP MOV A,R1 ANL A,#00001111
MOV A,#83H ACALL CMD MOV A,#"C" ACALL DISP SJMP MAIN
CMD: ACALL INIT MOV P0,A CLR RS CLR RW SETB EN CALL DELAY CLR EN RET DISP: ACALL INIT MOV P0,A SETB RS CLR RW SETB EN ACALL DELAY CLR EN RET
;POLLING FUNCTION INIT: CLR EN CLR RS MOV P1, #0FFH SETB RW L1: SETB EN JB P1.7, L1 DELAY: MOV R3, #10 L1: MOV R4, #250 L2: DJNZ R4, L2 DJNZ R3, L1 RET END
Frequency Counter using 8051
Frequency Counter using 8051
Data Acquisition System
Sensors Sensor Phenomenon Thermocouple, RTD, Thermistor Temperature Photo Sensor Light Microphone Sound Strain Gage, Piezoelectric Transducer Force and Pressure Potentiometer, LVDT, Optical Encoder Position and Displacement Accelerometer Acceleration pH Electrode pH
Signal Conditioning Amplification Excitation Linearization Cold-Junction Compensation Filtering Isolation High Impedance RMS Signal Conditioning
Example of DAS
Optocoupler