Shop OBEX P1 Docs P2 Docs Learn Events
Ping))) general questions — Parallax Forums

Ping))) general questions

Justin_HJustin_H Posts: 4
edited 2006-04-14 00:08 in General Discussion
I have a few questions about the PING))) sonar and am wondering if someone could take a few seconds to answer them. I purchased several of these components (28015 rev a) for a college project and am having trouble getting meaningful results from them. First question, in the PDF documentation the echo hold off is listed as 750 us but on your site it is listed as 350, which is correct?

Second question, I am trying to use the sonars with innovation first’s mini controller and am writing the code in c. the code sends a positive TTL pulse 3us one time. The LED on the sonar turns on and stays on forever, is this correct?

Third question, I am judging distance by having the controller run a timer from the time the signal pin goes high until it drops again (after the signal pulse), is that the correct idea?

Finally I also have the controller writing a line to my computer screen every time the sonar toggles its input which seems to happen several times a second until I turn the robot off, once you signal the sonar one time does it start continually pinging? Is that why the LED stays on all the time? I’d really appreciate any help or direction you can give me. I have read all the docs I could find and the answer to these questions was not immediately obvious to me.

Thank you very much for your time.
Justin_H

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-03 23:48
    It is indeed 750 -- this was changed from 350 to ensure that the BS1 had plenty of time to get its PULSIN instruction loaded and ready for the echo pulse (we'll get the web site corrected).

    The LED should "blip" with each trigger/return -- if it looks like it's on all the time then you have a target that is very close.· Have you connected a scope to see what·you're getting?

    The return will be a high-going pulse that corresponds to the distance to the target.· Measure this pulse and do the calculation from there.· The BASIC Stamp program can be used as a guide; just keep in mind that the BS2 PULSIN instruction returns the pulse width in 2 uS units.

    The Ping))) only pings when you tell it to.· If you're using the trigger pin to do other things you could be triggering the Ping when you don't mean to.

    As always, we suggest that you post your current code (even in C) so that others can have a look at what you're doing and uncover anything you might have missed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Justin_HJustin_H Posts: 4
    edited 2006-04-04 07:14
    This code is for the innovation first minicontroller <www.ifirobotics.com> (Microchip PICmicro® PIC18F8520)

    void StartScan(char isCalledFast)
    {
            /* send a sonar pulse and wait */
            if(!hasScanned && !isCalledFast)
            {
                //this block of code only executes once
                //called from main loop to start the scan
                //opens the timer for use and starts it
                OpenTimer0(TIMER_INT_OFF & T0_16BIT & T0_SOURCE_INT & T0_PS_1_256 );
                timeFReturn=timeLReturn=timeRReturn=0;
                
                //set the signal pin on the sonar to be used for output
                IO2=OUTPUT;
                //start the ttl pulse set voltage low
                rc_dig_out02 =0;
                Delay10TCYx(3);    //wait 3us
                rc_dig_out02 =1;//set voltage high and wait 3 us
                Delay10TCYx(3);
                //set the voltage low again
                rc_dig_out02 =0;
                //wait the 750 us holdoff
                Delay100TCYx(75);
                //then start the timer
                WriteTimer0(0);
                IO2=INPUT;//set the signal pin to input 
                lastFrontSonarValue=frontSonar;//front sonar is an alias for the signal pin the sonar is connected to
                hasScanned=1;            
            }
            if(hasScanned && isCalledFast && frontSonar != lastFrontSonarValue)
            {
                #if DEBUG
                    printf("front sonar changed input to %d timer = %d\n",frontSonar, (unsigned int)ReadTimer0());
                #endif
            /*    WriteTimer0(0);*/
                lastFrontSonarValue=frontSonar;
            }
        
    }
    



    the pin is only used for the sonar, and as I mentioned before after the sonar has been signalled it continually seems to oscialate its value from high to low and back. Any help is appreciated, just ask if you need more info. I can post all the code as a download if necessary.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-04 12:54
    Not being much of a C programmer for the PIC, I may be missing something -- but you seem to be doing more than you need.· Let me break down the steps:

    Trigger:
    · -- make I/O line output high
    · -- wait 5 uS (I use 5 to make sure line quality to sensor has no effect -- and sensor is triggered on falling edge)
    · -- make I/O pin low
    · -- wait 100 uS (this is the approximate instruction load time for the BASIC Stamp)

    Echo:
    · -- make I/O line an input
    · -- wait for I/O line to go high
    · -- start timer
    · -- wait for I/O line to go low
    · -- stop timer

    The value in the timer·can be used to calculate the distance to the target.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Justin_HJustin_H Posts: 4
    edited 2006-04-04 13:27
    Thanks Jon,
    Another quick question "wait 100 uS (this is the approximate instruction load time for the BASIC Stamp)" can you explain what this means so i can find the equivelent time on my controller. I am unser what happens during the "instruction load time" and I am not very familiar with the basic stamp. my controller runs at 10mhz if that influences the load time.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-04 13:30
    This could probably be a lot shorter -- the point is that the actual trigger is the falling edge of the first pulse, so this gives the Ping time to actually register that falling edge and start its internal processes before you make the I/O pin an input.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Justin_HJustin_H Posts: 4
    edited 2006-04-05 07:31
    Thank you for your help Jon, I got it working [noparse]:D[/noparse]

    ~Justin_H
  • BatmanBatman Posts: 93
    edited 2006-04-07 16:07
    I have one question, Do the Ping))) come with a servo?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Happy new year
  • pjvpjv Posts: 1,903
    edited 2006-04-07 16:16
    Hi Batman;

    They do when you ship them in the same box.

    Hope that clarifies things.

    Cheers,

    Peter (pjv)
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-07 16:44
    Batman,

    Please stop hijacking threads -- when you have question that veers off the original topic (in this case it was Ping interfacing, not any accessories that may or may not come with it), start a new thread.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • matthelmmatthelm Posts: 19
    edited 2006-04-13 23:10
    I have a few question about using the PING sensor for a project I plan on building soon. First, the project is to add lighting around my front sidwalk and porch. Fisrt, let me say I've tried IR sensors, and none of them seem to work very well, so I'd like to try the PING sensor hung from the overhang facing down.

    I'm just going to get a 5 pack and spread them along the walk, and maybe 1 in the porch area.

    OK now the questions.

    1. I'd like to use a single BS2 to control all of them, but that means the signals might run up to 20 feet. Is the signal from the BS2 and then back from the PING going to be strong enough to get a good measurment? Or should I use some kind of buffer? If so, suggestions? (I MIGHT have enough BS1s to control each sensor if this can't be done)

    2. I was told by tech support to keep the temp above 32 degrees, so will a small insulated case with heating in the cold weather work? I thought I'd just put a temp sensor at the BS2, and turn the heat on for all if needed. (12volts thru a resistor, maybe)


    Thanks in advance.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-14 00:08
    Matt,

    Welcome, and please see my post to Batman above -- please start a new thread if your questions and not directly related to the original thread topic.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.