shondolala
Newbie level 1
technique for dc motor bidirectional control
My final diploma project is about the above written subject. i have done some research on it but the most difficult part comes in through the programming part because i wanted to use PIC16F84A and L293D in controlling the motor. i would like to do this application on a car using 6V PMDC.The power supply is a 9v of batteries. i have also found out that this could be done using h-bridge technique.i got a sample program from the internet but i dont understand assembly language. Can someone pls help me and even if there is a much simpler program i could use, pls upload it. pls explain the program to me.
here is the sample program;
include "P16F84a.inc"
list p=16F84a,r=dec
errorlevel -302
__Config _XT_OSC & _WDT_OFF & _PWRTE_ON
#define sw1 PORTB,4
#define sw2 PORTB,5
#define sw3 PORTB,6
#define sw4 PORTB,7
#define motor1a PORTB,0
#define motor1b PORTB,1
#define motor2a PORTB,2
#define motor2b PORTB,3
cblock 0x0C
r0
r1
r2
input
endc
org 0x00
goto start
start
bsf STATUS,RP0
movlw B'00000000'
movwf TRISA
movlw B'11110000'
movwf TRISB
bcf STATUS,RP0
clrf PORTA
clrf PORTB
goto main
main
movf PORTB,W
movwf input
movlw B'11110000'
andwf input,W
movwf input
movlw B'00010000'
xorwf input,W
btfsc STATUS,Z
call foward
movlw B'00100000'
xorwf input,W
btfsc STATUS,Z
call backward
movlw B'01000000'
xorwf input,W
btfsc STATUS,Z
call left
movlw B'10000000'
xorwf input,W
btfsc STATUS,Z
call right
movlw B'01010000'
xorwf input,W
btfsc STATUS,Z
call foward_left
movlw B'10010000'
xorwf input,W
btfsc STATUS,Z
call foward_left
movlw B'01100000'
xorwf input,W
btfsc STATUS,Z
call backward_left
movlw B'10100000'
xorwf input,W
btfsc STATUS,Z
call backward_right
goto main
foward
bsf motor1a
bcf motor1b
bcf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
backward
bcf motor1a
bsf motor1b
bcf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
left
bcf motor1a
bcf motor1b
bsf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
right
bcf motor1a
bcf motor1b
bcf motor2a
bsf motor2b
movlw D'2'
call delay
clrf PORTB
return
foward_left
bsf motor1a
bcf motor1b
bsf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
foward_right
bsf motor1a
bcf motor1b
bcf motor2a
bsf motor2b
movlw D'2'
call delay
clrf PORTB
return
backward_left
bcf motor1a
bsf motor1b
bsf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
backward_right
bcf motor1a
bsf motor1b
bcf motor2a
bsf motor2b
movlw D'2'
call delay
clrf PORTB
return
delay
movwf r0
delay1
movlw D'133'
movwf r1
delay2
movlw D'250'
movwf r2
delay3
decfsz r2,F
goto delay3
decfsz r1,F
goto delay2
decfsz r0,F
goto delay1
return
end
my other question is how many motor do i need to control 4 wheels? for projects i have seen BJTs and MOSFETs are used, but which one between the two is most suitable for my application? i would really appreciate your hepl.thanx
My final diploma project is about the above written subject. i have done some research on it but the most difficult part comes in through the programming part because i wanted to use PIC16F84A and L293D in controlling the motor. i would like to do this application on a car using 6V PMDC.The power supply is a 9v of batteries. i have also found out that this could be done using h-bridge technique.i got a sample program from the internet but i dont understand assembly language. Can someone pls help me and even if there is a much simpler program i could use, pls upload it. pls explain the program to me.
here is the sample program;
include "P16F84a.inc"
list p=16F84a,r=dec
errorlevel -302
__Config _XT_OSC & _WDT_OFF & _PWRTE_ON
#define sw1 PORTB,4
#define sw2 PORTB,5
#define sw3 PORTB,6
#define sw4 PORTB,7
#define motor1a PORTB,0
#define motor1b PORTB,1
#define motor2a PORTB,2
#define motor2b PORTB,3
cblock 0x0C
r0
r1
r2
input
endc
org 0x00
goto start
start
bsf STATUS,RP0
movlw B'00000000'
movwf TRISA
movlw B'11110000'
movwf TRISB
bcf STATUS,RP0
clrf PORTA
clrf PORTB
goto main
main
movf PORTB,W
movwf input
movlw B'11110000'
andwf input,W
movwf input
movlw B'00010000'
xorwf input,W
btfsc STATUS,Z
call foward
movlw B'00100000'
xorwf input,W
btfsc STATUS,Z
call backward
movlw B'01000000'
xorwf input,W
btfsc STATUS,Z
call left
movlw B'10000000'
xorwf input,W
btfsc STATUS,Z
call right
movlw B'01010000'
xorwf input,W
btfsc STATUS,Z
call foward_left
movlw B'10010000'
xorwf input,W
btfsc STATUS,Z
call foward_left
movlw B'01100000'
xorwf input,W
btfsc STATUS,Z
call backward_left
movlw B'10100000'
xorwf input,W
btfsc STATUS,Z
call backward_right
goto main
foward
bsf motor1a
bcf motor1b
bcf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
backward
bcf motor1a
bsf motor1b
bcf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
left
bcf motor1a
bcf motor1b
bsf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
right
bcf motor1a
bcf motor1b
bcf motor2a
bsf motor2b
movlw D'2'
call delay
clrf PORTB
return
foward_left
bsf motor1a
bcf motor1b
bsf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
foward_right
bsf motor1a
bcf motor1b
bcf motor2a
bsf motor2b
movlw D'2'
call delay
clrf PORTB
return
backward_left
bcf motor1a
bsf motor1b
bsf motor2a
bcf motor2b
movlw D'2'
call delay
clrf PORTB
return
backward_right
bcf motor1a
bsf motor1b
bcf motor2a
bsf motor2b
movlw D'2'
call delay
clrf PORTB
return
delay
movwf r0
delay1
movlw D'133'
movwf r1
delay2
movlw D'250'
movwf r2
delay3
decfsz r2,F
goto delay3
decfsz r1,F
goto delay2
decfsz r0,F
goto delay1
return
end
my other question is how many motor do i need to control 4 wheels? for projects i have seen BJTs and MOSFETs are used, but which one between the two is most suitable for my application? i would really appreciate your hepl.thanx