View Full Version : 89c51 micromouse help needed

05-25-2008, 11:54 PM
hello friends, this is my first post to this site. the reason is simple, i am stuck in between a project. earlier also this site has given me answers to many of my questions so i am hoping the best here also.....

first i am going to tell what i have done uptil now.

PROJECT: micromouse (maze escaper)

89c51 micocontroller, led-ldr sensor, stepper motors, simple wall following algorithm.

this is my first uc based robot, earlier i have completed some projects but they were either brainless or done by parallel port interfacing. i have completed the sensor circuit ( i don't know why but none of the circuits i got on the net worked, finally i had to invent my own circuit using 4n35, uln2803, variable resistor, leds and 2 ldr in series..........i know too much for an obstracle sensor but the final result is soooo good. it can detect upto 6 cm using leds only and the variable resistor allow for ambient light cancellation). :idea:

now the motor driver circuit. i have done work with steppers before also. so making a cuircuit for it was easy. i used the same 4n35 + uln2803 circuit with 12 v supply from 7812.(actually i got the idea of using 4n35 and uln in my sensor circuit from here only) . its working fine.(tested using pc parallel port). :)

now comes the part i have not experienced before. and its giving me a lot of pain already. :x
i have got a 89c51.
to get some idea about it , and to test my circuitry together, i wrote a simple program.

port 1- input
port 2-output (same given on port 1)

the program is as follows:

mov p2,#0;
mov p1,#255;
mov a,p1;
mov p2,a;
ljmp st;

i checked it using simulator and its working fine. i transferred it on 89c51. now when i connected the circuit and started the testing i found that something is wrong. uc is not behaving like the program. its giving random signals. output signal is flickeringand very dim (led on output). every time i reset and start again i get different response, something like noise.

i am using following circuitry
# 4 MHz crystal with 22pf capacitors
# self start reset circuit
# input at port 1
# output at port 2
#the circuit is similar to one given here: http://www.freewebs.com/maheshwankhede/ports.html
the only difference is i am using 4MHz crystal.

MY DEBUGGING EXPERIENCE: i am trying to solve this problem for 2 weeks. i have tried almost everything i could think os find on net. i tried using pullup pulldown resistors, amplifying the output signal using transistor, using uln, i even tried to use 4n35 as a switch. but the output is still flickering,dim and random. i checked the program tens of times, checked that its written well in the uc, using uc as a source, using uc as sink, i even translated the code into hex type manually to check whether the software is converting it correctly or not (it was also fine). i can't still find the problem. some points i would like u to cross check are:

1) i am using 4mhz crystal. althouh the datasheet says anything between to 33 mhz is acceptible but i have never seen any circuit on net except 12mhz(or 11.059mhz). is it causing a problem? i am going to buy a 12mhz crystal tomorrow. hope it could solve the problem!!!!!!!

2) when i touch the crystal with my hands, the output suddenly becomes very clear and loud ( but still random and flickering). same happens when i touch it using any wire or conducting thing ( of cource, not carrying current at that time). does the body voltage alters its functioning?????

3) i am just writing the assembly code in keil and burning it using 89 series burner. i have selected the correct device, kept all device setting to default except the crystal frequency, marked the BUIKD HEX FILE option, written the code in assemble. do i need to do anything else???? (something like adding header files or defining the starting address????)

can anyone tell me what i am doing wrong??????
also if u have a simple working circuit which consists of 89c51 interfaced with very simple ics which i could test, send me that also. (help me to believe that microcontrollers works)


05-26-2008, 10:21 PM
hello friends,
so i got the solution. it was crystal. i tried the 12mhz crystal and its working fine with the input output program. but now another problem has arisen. i wrote a flashing led program with delay of 1 sec (according to kiel software simulation). but when i tested it , its not working .

the program is for port 2. initiall first 4 bits are low and other four are high. after 1 sec first 4 becomes high and others low. program is simulating correctly.

could u plese help me . also tell me whether 89c51 modify the crystal frequency. (i read somewhere there is a frequency divide in it). how it affect the code execution speed. for example a delay designed to give 1sec on 12mhz frequency will actually complete in how much time?????


05-27-2008, 10:48 PM
at last i solved the problem......
this session is becoming more like my project experience and my troubleshooting experience rather than getting any suggestions.

that's fine.... i love getting surrounded by such tiny problems which u could find using ur microscopic vision only, and when u get the solution it seems that u are GOD(at least for some time until a new problem arises......)

OK enough philosophy........now getting back to work....
the problem was POWER SUPPLY...yes u heard it right.......i between all those giant circuits the problem creating particle was 7805....i have read in many forums that something called MAX is better than 7805....but as u know half knowledge is worse than zero knowledge....same happened here.... i have used 7805 voltage regulator many times ... and it worked fine..... but not in this case... i found out that it emits very small ac ripples at output. most components are immune to it but not microcontroller.... so i added a 2200uf capacitor (earlier it was 1uf) and.... eureka my microcontroller is working......

but good news comes with bad news...this small and innocent looking ac ripple (which even cannot be detected by multimeter) has killed 2 of my microcontrollers.... but now i know how to defend my soldier from enimies.......

let the next problem come.......I AM READY LIKE A SPARTAN ........