DC Motor Control using IR data communication


Current generation moves into wireless technology. Every one wishes to use remote controls. In this way, the speed of the DC motor is controlled by IR rays. IR rays get modulated with combination of data signal and carrier wave of 38 kHz. At the received end, the modulated signal is demodulated which is given to another controller, connected to the Dc motor driving circuit.


Algorithms:

Transmission
STEP1: Start
STEP2: Initialize the LCD
STEP3: Display speed on LCD
STEP4: Check for interrupt
STEP5: If INT0, increment counter and transmit.
STEP6: If INT1, decrement counter and transmit.
STEP7: Repeat STEP3.
STEP8: End

Reception

STEP1: Start
STEP2: Initialize the LCD
STEP3: Check for serial interrupt
STEP4: Display the received value
STEP5: If Caught compare R0 for 31,32,33,34.
STEP6: If R0 = 31 run motor in 25% speed
STEP7: If R0 = 32 run motor in 50% speed
STEP8: If R0 = 33 run motor in 75% speed
STEP9: If R0 = 34 switch OFF motor
STEP10:Go to STEP3.

 

Flowchart for Transmission:


 


 

Flowchart for Interrupt(INT0):




Flowchart for Interrupt(INT1):


Flowchart for Reception:

Flowchart for Reception

Flowchart for Reception

 

Flowchart for Interrupt:

Flowchart for Interrupt

Flowchart for Interrupt

 

Source code:

Transmission program:
ORG 0000H
JMP MAIN
ORG 0003H
JMP INCR
ORG 0013H
JMP DECR
ORG 0023H
JNB TI,REC
CLR TI
MOV P0,A
ACALL DAT
ACALL DELAY
RETI
REC: CLR RI
RETI

ORG 0040H
MAIN: MOV A,#38H
ACALL COMM
ACALL DELAY
MOV A,#0EH
ACALL COMM
ACALL DELAY
MOV A,#01H
ACALL COMM
ACALL DELAY
MOV A,#06H
ACALL COMM
ACALL DELAY
MOV A,#80H
ACALL COMM
ACALL DELAY
MOV IE,#97H
MOV SCON,#50H
MOV TMOD,#2DH
MOV TH1,#0E8H
MOV R0,#30H
SETB TR1
SETB TCON.0         ; EDGE TRIGGERING
SETB TCON.2
SETB TR0

SPEED: MOV R6,TL0
CALL SEC
CALL SEC
CALL SEC
MOV A,TL0
SUBB A,R6
ACALL CONV
MOV A,#0C0H
ACALL COMM
ACALL DELAY
MOV A,R2
ACALL DAT
ACALL DELAY
MOV A,R1
ACALL DAT
ACALL DELAY
MOV A,R7
ACALL DAT
ACALL DELAY
JMP SPEED

COMM: MOV P0,A
CLR P2.7
SETB P2.5
CLR P2.5
RET

DAT: MOV P0,A
SETB P2.7
SETB P2.5
CLR P2.5
RET

DELAY: MOV R3,#50
HERE2: MOV R4,#255
HERE: DJNZ R4,HERE
DJNZ R3,HERE2
RET

;************************** INCREASE SPEED

INCR: INC R0
CJNE R0,#35H ,NEXT           ; TO CHECK IF MAX SPEED CROSSED
DEC R0
RETI

NEXT: MOV A,#80H
ACALL COMM
ACALL DELAY
ACALL SEND
RETI

;*************************   DECREASE SPEED

DECR: CJNE R0,#31H, NEXT2         ; TO CHECK IF MIN SPEED CROSSED
RETI

NEXT2: DEC R0
MOV A,#80H
ACALL COMM
ACALL DELAY
ACALL SEND
RETI

SEND: MOV A,R0
MOV SBUF,A
RET

SEC: MOV R3,#25
H3: MOV R4,#200
H2: MOV R5,#200
H1: DJNZ R5,H1
DJNZ R4,H2
DJNZ R3,H3
RET

CONV: MOV B,#10
DIV AB
MOV R7,B
MOV B,#10
DIV AB
ORL A,#30H
MOV R2,A
MOV A,B
ORL A,#30H
MOV R1,A
MOV A,R7
ORL A,#30H
MOV R7,A
RET
END





RECEPTION PROGRAM:

ORG 0000H
JMP MAIN
ORG 0023H
JNB TI,REC
CLR TI
RETI

REC: MOV A,SBUF
CLR RI
MOV P0,A
MOV R0,A
ACALL DAT
ACALL DELAY
RETI

ORG 0040H
MAIN: MOV A,#38H
ACALL COMM
ACALL DELAY
MOV A,#0EH
ACALL COMM
ACALL DELAY
MOV A,#01H
ACALL COMM
ACALL DELAY
MOV A,#06H
ACALL COMM
ACALL DELAY
MOV A,#80H
ACALL COMM
ACALL DELAY
MOV IE,#92H
MOV SCON,#50H
MOV TMOD,#2DH
MOV TH1,#0E8H
MOV R0,#30H
SETB TR1
DEF: SETB P1.1
ACALL DELAY
CLR P1.1
ACALL DELAY
JMP TWO
JMP DEF

ORG 0090H
UP: CJNE R0,#31H, NEXT2  ; CHECKING 4 REC VALUES
JMP ONE
NEXT2: CJNE R0,#32H, NEXT3
JMP TWO
NEXT3: CJNE R0,#33H, NEXT4
JMP THREE
NEXT4: CJNE R0,#34H ,DEF
JMP FOUR
FOUR: CLR P1.1
CJNE R0,#34H ,UP     ; OFF
CLR P1.1
JMP FOUR
THREE: CJNE R0,#33H ,UP     ; 75% SPEED
SETB P1.1
ACALL DELAY
ACALL DELAY
ACALL DELAY
CLR P1.1
ACALL DELAY
JMP THREE
TWO: CJNE R0,#32H ,UP     ; 50% SPEED
SETB P1.1
ACALL DELAY
CLR P1.1
ACALL DELAY
JMP TWO
ONE:  CJNE R0,#31H,UP     ; 25% SPEED
SETB P1.1
ACALL DELAY
CLR P1.1
ACALL DELAY
ACALL DELAY
ACALL DELAY
JMP ONE
COMM:  MOV P0,A
CLR P2.7
SETB P2.5
CLR P2.5
RET
DAT: MOV P0,A
SETB P2.7
SETB P2.5
CLR P2.5
RET
DELAY: MOV R6,#50
HERE2: MOV R7,#255
HERE: DJNZ R7,HERE
DJNZ R6,HERE2
RET
END

Applications:

  1. Remote Monitoring.
  2. Robotics .
  3. Remote controlled Toys

Future enhancements:

  1. Transmission Using RF Channel
  2. Feed Back Error Control
  3. Performance Testing

Conclusion:

In this project, we performed the serial transmission between two  89c51 microcontrollers in IR medium. The speed of DC motor was controlled in different speed and feedback was taken through proximity sensors.



Make a Free Website with Yola.