Shop OBEX P1 Docs P2 Docs Learn Events
Problem with Ping with AT89C52 — Parallax Forums

Problem with Ping with AT89C52

tahasamadtahasamad Posts: 3
edited 2011-05-12 22:07 in Accessories
Hello,

I am using ping sensor in my Final Year Project.The project is basically a robotic call which will follow the left wall and eventually the outline of the room/enclosed space will be plotted on the computer. I am using following components:

AT89C52
2 Ping Sensor
BC4 Bluetooth Module
Plus 2 motors
2 H-Bridge
12V 2AH battery
Opto-interrupter


Ping is connected to P2.0 and P2.1
Data is sent to the computer where remaining calculations are made

Supply Circuit:
12v battery is connected to 7805 voltage regulator, There are 2 capacitors

i)100uF across 12v and ground of 7805
ii)10uF across 5v and ground of 7805

Now my problem is that my ping sensor used to work properly but now it keeps on giving the same output i.e. 3.052m this means that it is receiving 0xFFFF every time.

i want to know what can be the possible issue.as i have 2 more spare sensors but i cannot afford to lose them as deadline of my project is end of april.It takes about 2 weeks to get pings shipped to Pakistan.

I am attaching my assembly and c++:

CODE1.ASM
Comp Code III.cpp

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-07 08:12
    We cannot help you with the AT89C52 code. If the PING worked properly before and now does not, you have to think about what has changed in both your hardware and your code since it worked. Does the LED on the PING flash? That indicates that an ultrasound pulse was transmitted.

    Make sure you understand how the PING operates. Read the documentation for it. There is only one bidirectional data line. The AT89C52 has to put a brief (roughly 5us) pulse (0->1->0) on the data line to start. Approximately 750us later, the PING will produce a pulse (0->1->0) on the data line whose width gives the time until the first received echo. This pulse is a minimum of 115us and a maximum of 18.5ms in width.

    If you have access to an oscilloscope or logic analyzer, you might look at the signals on the data line to see if they behave as described. It sounds like your software is not seeing the end of the pulse for some reason or not seeing the pulse from the PING at all. Check your connections.
  • tahasamadtahasamad Posts: 3
    edited 2011-04-07 08:29
    yes the activity LED on the ping blinks periodically after equal intervals(this is how it should blink,cause there is a delay in the code). There is practically no change in code or hardware. The only thing is that initially i was testing ping as a sole device with micro-controller,now it is connected to micro-controller along with other devices like BC4 blue tooth module and dc motors etc. Yes i have gone through data sheet carefully many times.

    Can you please answer following questions:

    1) If the activity light on ping blinks does this mean that ping is working properly or is it possible that some part of ping is faulty due to which i am getting the constant value?

    2) I know ping works on 5v but practically on what range of voltage will it work properly? because my 7805 was giving 5.11V so is it okay?

    3) how sensitive ping is to transient responses? i mean as there is a switch which is used to turn on all the circuit on the robotic car it is possible that momentarily there is a voltage surge which cannot be seen using ordinary voltmeters and oscilloscopes.So is it possible that a voltage surge, produced when I turn on the switch, could have caused a part of ping to get burned/faulty.

    regards
    Taha Samad
  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-07 09:00
    1) If the activity LED blinks, it means that most of the PING is working. It is still possible, but unlikely, that various parts of the PING could be faulty. The LED simply indicates that the PING received the start pulse and is turning on the transmitter.

    2) The PING, like most logic components, is designed to work over a +/- 10% supply voltage. That's approximately a 4.5V-5.5V range. Anything over 7V can damage or destroy the device. 5.11V is fine.

    3) Like I said, any voltage applied to the PING greater than 7V can damage it. Usually when turning on power to a system, there might be a brief voltage drop, but a surge doesn't make sense unless the power supply is faulty. The 7805 should prevent that. If you were powering some motors from the 5V power supply, you could get voltage spikes on the power supply lines.

    It's most likely that the PING is ok, but there's something about your program, now that it's controlling other things, that's causing the PING timing in the program to not work.

    It would be useful to try a separate power supply for the microcontroller, Bluetooth, and PING. If you have another 12V battery or AC supply (9-12V), connect that to the 7805 and leave your 12V 2AH battery connected just to the motors and H-bridges. Make sure the grounds are all connected together. If nothing changes, then you've eliminated that as the source of your PING problems.
  • tahasamadtahasamad Posts: 3
    edited 2011-05-12 21:19
    Thanks Mike.Just had my project evaluation last week.Everything worked fine.Thanks for the advice.Separating power supplies worked for us.

    Here is a video of our project in case you want to have a look thanks again.

    http://www.youtube.com/watch?v=IHY9sowJ7Qs
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-12 22:07
    Congratulations on a successful project evaluation!
Sign In or Register to comment.