ASM Programming problem

Discussion in 'Embedded Systems and Microcontrollers' started by Jakob90, Jan 13, 2009.

  1. Jakob90

    Thread Starter New Member

    Jan 13, 2009
    1
    0
    Hello,

    I am in the course of programming a PIC 16F819 for school. All the hardware has been set up correctly and it can be seen here, drawn in Multisim: http://img212.imageshack.us/img212/3207/drawingeq1.png

    I will add the finished schematic tomorrow. This one might contain some mistakes, but it should give you the general idea for now. The "Sonalert" are representing a ultrasound transmitter and a reciever.

    The hardware has been tested and it is set up probably. So after spending 6 hours today trying to fix the software and I haven't been able to do so. Before I post the code I want to say I am no expert, which is why I am asking for help here.

    What I am trying to do: I want the microcontroller to calclulate the distance between the ultrasound sender (and receiver for that matter) and a flat surface. The idea was to calculate how much the Timer0 would count to for what corrosponds to 1 cm and then add it all up.

    D = 0,5 * C * (T - T0) and this means that I could do the following:
    1 = 0,5 * 344 * (Count / Frequency / 64) * 100 --> ~3

    With the frequency being 4MHz and the prescaler at 1:64.

    I hope this is enough introduction to the project and if not please tell me what you need to know to help me, it is a project within a certain timeline so any help would be great :)

    The .asm file can be found at: http://www.wikiupload.com/download_page.php?id=89014

    I am not sure if it is better that I post all of it here or linked to it.
     
  2. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    How can you be sure that your receiver is not picking up the strong initial ultrasound output instead of the much weaker echo/reflection?
     
  3. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    To expand on what eblc said, make the distance between the reflector and the Sonalert much greater -- 100cm for instance. I would also consider using a number of distances (10 cm, 50 cm, 100 cm, 500 cm) to see what effect distance has. Also, I believe atmospheric conditions will affect the timing, as well as the reflecting material.

    Another reason for using a larger distance is rounding errors. The timer is digital -- it counts in whole numbers. What happens if the signal returns at 2.7 timer ticks? The timer will indicate it occurred after three ticks, and that will introduce errors at only 10 cm -- the timer will stop at 27 ticks for what should have been 30 ticks, indicating the reflector is closer than it really is.

    --Rich
     
Loading...