Back to PCAM+ page.
Back to Chapter 6 L293D DC Motor Driver Interface with 89S52The L293D is mounted on the PCAM+ board and is ready to use with very few interface connections.You can follow these steps to play with a DC Motor using your own microcontroller code. Note that while the motor driver IC is mounted on PCAM+, a DC Motor is not included with the kit. You will have to supply your own. Start by making these connections: - Connect P2.0 to E1 pin of L293D section (Section 8) on PCAM+ Kit.
- Connect P2.1 to I1 pin of L293D section on PCAM+ Kit.
- Connect P2.2 to I2 pin of L293D section on PCAM+ Kit.
- Connect VS pin from L293D section of PCAM+ Kit to a suitable voltage line e.g. 5V or 9V. For example, you can connect VS to the +5V pin located near the 7805 voltage regulator IC. See the mark of +5V near the two-pin male header on the extreme right-bottom corner of the PCAM+ board.
- Connect GND pin from L293D section of the PCAM+ Kit to GND of the external supply (to which VS is connected above). If using the on-board 5V supply as suggested above, this can be skipped as there is no need for a common Ground connection.
- Connect your hobby DC Motor pins to pins O1 & O2 of the L293D section on PCAM+.
Write the following code using 8051IDE, assemble it and download it to 89S52 on PCAM+ kit using HandyProgUSB programmer. Main: SETB P2.0 ; ENABLE L293D DRIVER
ROTATE_LOOP: CLR P2.1 SETB P2.2 ;01 COMBINATION WILL ROTATE MOTOR IN ONE DIRECTION LCALL DELAY ;LET THE MOTOR ROTATE IN ONE DIRECTION SETB P2.1 CLR P2.2 ;10 COMBINATION WILL ROTATE MOTOR IN OTHER DIRECTION LCALL DELAY ;LET THE MOTOR ROTATE IN OTHER DIRECTION SJMP ROTATE_LOOP
DELAY: MOV R5,#200D LOOP1: MOV R6,#45D LOOP2: MOV R7,#100D DELAY_LOOP: DJNZ R7,$ DJNZ R6,LOOP2 DJNZ R5,LOOP1 RET
Proceed to Chapter 8
Back to PCAM+ page. |