• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

AT89C51 does not work in Motor reverse circuit ?

Status
Not open for further replies.

winstar

New Member
I want to build on a remote control on motor direction, I have found a page on

http://www.geocities.com/naveen_pn/circuitspage.html
in the topic: DC motor direction controller




but I used 2N2222 instend of BC148, 2N4403 instead of SK100, and 2N3053 instead of SL100... will it affect the result?

It works:
when I put control input A into +9V and left B alone(clockwise)
when I put control input B into +9V and left A alone(anticlockwise)

However, it does not work while putting control input A and B into pin21 and pin22 of a AT89C51....whatever I put A HIGH and B LOW or A is LOW and B is HIGH

what should be added to input A and input B in AT89C51?

Pls help me.... really really urgent... for me in doing a project

Thanks alot....
 

Chippie

Member
If I understand correctly, what you say is:

A high B lo motor drives one direction,

A lo B hi motor drives opposite direction...... But when A and B are connected to an Atmel it doesnt work......

All I can say is, what are you expecting the Atmel to do ?
Is it programmed with some code to control the motor direction?

If so, is the code written/compiled/programmed correctly ?
 

winstar

New Member
actually, the program i written by another one, while testing, A can receive signal "1" and B can receive signal "0"; then it is expected to get a result--motor move clockwise...

the program is as follows:

;************************************************************
org 00h
jmp Initial
org 0bh
ajmp SystemClockInt

Initial:
Receiver equ p1 ; first 3 bits are device number, p1.3 is for ON-OFF
DeepSwitch equ p1 ; only last 4 bits (p1.4-p1.7) are used
TempMem equ 20h ; temp variable
DeepMem equ 21h
Signal equ 22h

;
; ::::::: Turn Off the Motor :::::::
;
clr p2.0
clr p2.1
;
; :::::: Initialize memory ::::::
;
mov Signal, #00h

;
; :::::: Initialize timer ::::::
;
mov ie, #10000010b ; Enable tf0
mov ip, #01h ; High Priority
mov tmod, #01h ; Timer 0
;
; ::::::: Get Switch Number :::::::
;
mov a, DeepSwitch
anl a, #01110000b
swap a
mov DeepMem, a
;
; ::::::: Get Receiver signal :::::::
;
Start:
mov a, Receiver
mov TempMem, a
anl a, #00000111b
cjne a, DeepMem, Start

mov a, TempMem
anl a, #00001000b
cjne a, Signal, IsNewSig
jmp Start

IsNewSig:
mov Signal, a ; Update info.
mov r7, #00h
mov r6, #00h

acall StartSystemClock

cjne a, #00h, IsLeft
IsRight:
mov p2, #00000010b
mov Receiver, #0ffh
TurningRight:
mov a, r6
cjne a, #20, TurningRight
acall StopSystemClock
mov p2, #00000000b
jmp Start

IsLeft:
cjne a, #00001000b, start
mov p2, #00000001b
TurningLeft:
mov a, r6
cjne a, #20, TurningLeft
acall StopSystemClock
mov p2, #00000000b
jmp Start

;******************************************************************************
;*
;* Timer Interrupt
;*
;******************************************************************************
SystemClockInt:
inc r7
acall StartSystemClock
reti
;-------------------------------------------------------------------------
StartSystemClock:
mov th0, #03ch ; 50000 machine cycle = 3CAF
mov tl0, #0afh
setb tr0 ; start timer
mov a, r7
cjne a, #0ff, QuitStartSystemClock
inc r6
mov r7, #00h
QuitStartSystemClock:
ret
;-------------------------------------------------------------------------
StopSystemClock:
clr tr0 ; stop timer
ret
end


;************************************************************

but I dun know why it cannot run while both input A and input B connected.
Without connected to At89C51, It really works when I just apply +9V to either input A or B...

I am a new learner for this ee field...so I could not slove this,but the deadline comes soon...
Thus, help me pls....^-^

Thanks alot...
 

Chippie

Member
Thanks for posting your code..I'm not a coder, but it looks ok to me unless someone else can spot something.....

but.....disconnect the Atmel form your motor circuit, and check what happens at the out pins from the chip........do they change state as they are supposed to ?

This would prove the code is ok.....
 

kinjalgp

Active Member
Have you checked the circuit by manually applying logic signals to points A and B? If not do it first and go step by step. Write your code in small blocks and test each of the separately. This helps a lot in debugging.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top