Shop OBEX P1 Docs P2 Docs Learn Events
ping))) sensor works only few seconds !? — Parallax Forums

ping))) sensor works only few seconds !?

fukakaifukakai Posts: 9
edited 2013-06-10 15:16 in Accessories
Hi,

I have a Ping))) sensor plugged on an arduino card, you can see documentation here : http://www.parallax.com/Portals/0/Downloads/docs/prod/robo/570-28015-PingBracket-v2.0.pdf

When i'm trying some really simply codes with (https://code.google.com/p/arduino-new-ping/wiki/Simple_NewPing_Example) or without (https://gist.github.com/flakas/3294829) NewPing library my issue it the same :

I first, upload my program on the arduino card.
I start the program by the position 2 of the start button, all is working fine, i have distance with pings and i can use them.
Few seconds after the program starting (30 seconds approximately), all continue to working fine except the ping sensor who return 0 instead of the inch or centimeters distance.
Moreover, the ping green light is also stopping !
If now, i move the start button du 0 position to stop it and move again on position 2 it always don't work !
But : if i move the button to 0, push reset button and start again the arduino card now it works again !!!! and i can have new values for distance with ping censor !!!

I want to use the ping))) sensor during few minutes, not only for seconds ...

So, how can i solve this problem ?
Someone ever had this problem ?

I have always test the watchdog solution to do a "software" reset but it's don't working ...

Thank you in advance,

Romain

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-06-05 08:58
    You said it stops working after 30 seconds each time. If this is the case regardless of how long the sensor has been powered on then I would be inclined to suspect a code error, such as stack overflow/underflow. I'm not fluent with the Arduino code, so I wouldn't be able to diagnose the issue there, but it's a logical suspect, based on the fixed run time of the issue.
  • dgatelydgately Posts: 1,630
    edited 2013-06-05 09:16
    Romain,


    1. Are you using a Parallax Ping))) or an HC-SR04 Sensor?

    Your examples are for the HC-SR04 which uses two pins for trigger and echo, whereas the actual Ping))) uses a single pin and requires a slightly different timing between trigger and echo instances.

    2. What are you using to supply power to the Arduino and sensor? Battery power?

    Although it does not sound like you have a reset problem, it could be that you are not supplying enough amperage for both the Ping))) and the Arduino. And, since you quote the Ping))) Bracket product, are you running a servo as well? You may want to check your power supply...


    dgately
  • fukakaifukakai Posts: 9
    edited 2013-06-05 10:22
    Thanks for quick answers,

    Chris Savage :

    You confirm what I suspected also, it can be a stack overflow / underflow issue (when i discovered the reset button tips ^^) but i don't reach to do it in arduino or to find tutorials / example to do that.
    I'm currently trying to find others informations about.



    dgately :
    1 : I am using Parallax Ping))). In code, when I am using NewPing library i set trigger and echo pins with the same value and it works ... during few seconds ^^ (as the other way)
    I saw here the NewPin 1.5 library support also the Parallax Ping))) :
    http://forum.arduino.cc/index.php?topic=106043.0

    2: to support Arduino and sensor, I have five AA batteries. But the issue occurs also with only one cable connected to the computer (and no batteries)

    Here is another sample (http://arduino.cc/en/Tutorial/Ping). Again the same issue with it.
    [COLOR=#7E7E7E][FONT=monospace][I]/* Ping))) Sensor
      
       This sketch reads a PING))) ultrasonic rangefinder and returns the
       distance to the closest object in range. To do this, it sends a pulse
       to the sensor to initiate a reading, then listens for a pulse 
       to return.  The length of the returning pulse is proportional to 
       the distance of the object from the sensor.
         
       The circuit:
        * +V connection of the PING))) attached to +5V
        * GND connection of the PING))) attached to ground
        * SIG connection of the PING))) attached to digital pin 7
    
       http://www.arduino.cc/en/Tutorial/Ping
       
       created 3 Nov 2008
       by David A. Mellis
       modified 30 Aug 2011
       by Tom Igoe
     
       This example code is in the public domain.
    
     */[/I][/FONT][/COLOR]
    
    [COLOR=#7E7E7E][FONT=monospace][I]// this constant won't change.  It's the pin number[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// of the sensor's output:[/I][/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]const [/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]int[/FONT][/COLOR][COLOR=#000000][FONT=monospace] pingPin [/FONT][/COLOR][COLOR=#000000][FONT=monospace]=[/FONT][/COLOR][COLOR=#000000][FONT=monospace] 10[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    
    [COLOR=#CC6600][FONT=monospace]void[/FONT][/COLOR][COLOR=#CC6600][FONT=monospace][B]setup[/B][/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace]{[/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// initialize serial communication:[/I][/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]Serial[/FONT][/COLOR][COLOR=#000000][FONT=monospace].[/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]begin[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]9600[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]}[/FONT][/COLOR]
    
    [COLOR=#CC6600][FONT=monospace]void[/FONT][/COLOR][COLOR=#CC6600][FONT=monospace][B]loop[/B][/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]{[/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// establish variables for duration of the ping, [/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// and the distance result in inches and centimeters:[/I][/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]long[/FONT][/COLOR][COLOR=#000000][FONT=monospace] duration[/FONT][/COLOR][COLOR=#000000][FONT=monospace],[/FONT][/COLOR][COLOR=#000000][FONT=monospace] inches[/FONT][/COLOR][COLOR=#000000][FONT=monospace],[/FONT][/COLOR][COLOR=#000000][FONT=monospace] cm[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    
    [COLOR=#7E7E7E][FONT=monospace][I]// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:[/I][/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]pinMode[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]pingPin[/FONT][/COLOR][COLOR=#000000][FONT=monospace],[/FONT][/COLOR][COLOR=#006699][FONT=monospace]OUTPUT[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]digitalWrite[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]pingPin[/FONT][/COLOR][COLOR=#000000][FONT=monospace],[/FONT][/COLOR][COLOR=#006699][FONT=monospace]LOW[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]delayMicroseconds[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]2[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]digitalWrite[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]pingPin[/FONT][/COLOR][COLOR=#000000][FONT=monospace],[/FONT][/COLOR][COLOR=#006699][FONT=monospace]HIGH[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]delayMicroseconds[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]5[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]digitalWrite[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]pingPin[/FONT][/COLOR][COLOR=#000000][FONT=monospace],[/FONT][/COLOR][COLOR=#006699][FONT=monospace]LOW[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    
    [COLOR=#7E7E7E][FONT=monospace][I]// The same pin is used to read the signal from the PING))): a HIGH[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// pulse whose duration is the time (in microseconds) from the sending[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// of the ping to the reception of its echo off of an object.[/I][/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]pinMode[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]pingPin[/FONT][/COLOR][COLOR=#000000][FONT=monospace],[/FONT][/COLOR][COLOR=#006699][FONT=monospace]INPUT[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]  duration [/FONT][/COLOR][COLOR=#000000][FONT=monospace]=[/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]pulseIn[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]pingPin[/FONT][/COLOR][COLOR=#000000][FONT=monospace],[/FONT][/COLOR][COLOR=#006699][FONT=monospace]HIGH[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    
    [COLOR=#7E7E7E][FONT=monospace][I]// convert the time into a distance[/I][/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]  inches [/FONT][/COLOR][COLOR=#000000][FONT=monospace]=[/FONT][/COLOR][COLOR=#000000][FONT=monospace] microsecondsToInches[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]duration[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]  cm [/FONT][/COLOR][COLOR=#000000][FONT=monospace]=[/FONT][/COLOR][COLOR=#000000][FONT=monospace] microsecondsToCentimeters[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]duration[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    
    [COLOR=#CC6600][FONT=monospace]Serial[/FONT][/COLOR][COLOR=#000000][FONT=monospace].[/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]print[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]inches[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]Serial[/FONT][/COLOR][COLOR=#000000][FONT=monospace].[/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]print[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#0066CC][FONT=monospace]"in, "[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]Serial[/FONT][/COLOR][COLOR=#000000][FONT=monospace].[/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]print[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]cm[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]Serial[/FONT][/COLOR][COLOR=#000000][FONT=monospace].[/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]print[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#0066CC][FONT=monospace]"cm"[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]Serial[/FONT][/COLOR][COLOR=#000000][FONT=monospace].[/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]println[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    
    [COLOR=#CC6600][FONT=monospace]delay[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#000000][FONT=monospace]100[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]}[/FONT][/COLOR]
    
    [COLOR=#CC6600][FONT=monospace]long[/FONT][/COLOR][COLOR=#000000][FONT=monospace] microsecondsToInches[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]long[/FONT][/COLOR][COLOR=#000000][FONT=monospace] microseconds[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]{[/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// According to Parallax's datasheet for the PING))), there are[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// second).  This gives the distance travelled by the ping, outbound[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// and return, so we divide by 2 to get the distance of the obstacle.[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf[/I][/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]return[/FONT][/COLOR][COLOR=#000000][FONT=monospace] microseconds [/FONT][/COLOR][COLOR=#000000][FONT=monospace]/[/FONT][/COLOR][COLOR=#000000][FONT=monospace]74[/FONT][/COLOR][COLOR=#000000][FONT=monospace]/[/FONT][/COLOR][COLOR=#000000][FONT=monospace]2[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]}[/FONT][/COLOR]
    
    [COLOR=#CC6600][FONT=monospace]long[/FONT][/COLOR][COLOR=#000000][FONT=monospace] microsecondsToCentimeters[/FONT][/COLOR][COLOR=#000000][FONT=monospace]([/FONT][/COLOR][COLOR=#CC6600][FONT=monospace]long[/FONT][/COLOR][COLOR=#000000][FONT=monospace] microseconds[/FONT][/COLOR][COLOR=#000000][FONT=monospace])[/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]{[/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// The speed of sound is 340 m/s or 29 microseconds per centimeter.[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// The ping travels out and back, so to find the distance of the[/I][/FONT][/COLOR]
    [COLOR=#7E7E7E][FONT=monospace][I]// object we take half of the distance travelled.[/I][/FONT][/COLOR]
    [COLOR=#CC6600][FONT=monospace]return[/FONT][/COLOR][COLOR=#000000][FONT=monospace] microseconds [/FONT][/COLOR][COLOR=#000000][FONT=monospace]/[/FONT][/COLOR][COLOR=#000000][FONT=monospace]29[/FONT][/COLOR][COLOR=#000000][FONT=monospace]/[/FONT][/COLOR][COLOR=#000000][FONT=monospace]2[/FONT][/COLOR][COLOR=#000000][FONT=monospace];[/FONT][/COLOR]
    [COLOR=#000000][FONT=monospace]}[/FONT][/COLOR]
    
  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-05 11:29
    There's really no place in the code you've posted for a stack overflow or underflow to occur. Although I haven't run these examples myself, I've run across people who have done so successfully. What you describe doesn't make sense in terms of a problem with the PING itself. The only thing that does make sense to me is some kind of power problem. What else do you have connected to the Arduino adapter? What kind of Arduino board are you using?

    Does the 5V regulator get hot after 30 seconds with the power switch in position 2?
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2013-06-05 13:29
    Also, you might look at this tutorial. Scroll down - it has a circuit and Arduino code written specifically for the Parallax Ping))) sensor:

    http://learn.parallax.com/KickStart/28015
  • fukakaifukakai Posts: 9
    edited 2013-06-05 14:53
    Thanks for fast answers !

    Chris Savage :
    i suspected also the stack overflow since i'll discover the reset button result. You confirm my second thoughts. But i don't reach to find any tutorials / examples about the stack clearing with arduino commands. I actually doing some test.

    Dgately :
    1 : i'm using Parallax Ping)))
    When i'm using the NewPing 1.5 library, i set trigger and echo pins with the same value for only one pin because i saw here http://forum.arduino.cc/index.php?PHPSESSID=srvcptqvesmu7jomidkc4lkn35&topic=106043.0 the NewPing 1.5 library support the Parallax Ping))).

    2 : To supply power to the Arduino and sensor, i'm using five AA batteries. But the issue occurs with batteries or without (connected by USB cable to my computer)
    i have other servos connected. i've tried without them and with only the ping sensor : same issue.

    Mike Green : i've upload 2 pictures to show you what i am using. After few seconds of work in the position 2 there is no hot component (servos, ping))), or other if they are connected)

    Steph Lindsay : i did all the last part for Arduino Uno : connections and code. Same issue again :s
    Here is the logs i can see with the code find on your link
    16
    16
    16
    16
    16
    16
    [...] //voluntary cut here ^^
    58
    145
    44
    48
    44
    47
    48
    44
    70
    44
    52
    59
    145
    145
    45
    46
    56
    58
    46
    44
    45
    46
    48
    46
    44
    44
    45
    50
    58
    145
    48
    45
    45
    46
    46
    47
    145
    145
    78
    44
    81
    72
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    ....

    and here two pictures :

    I have an arduino uno, 3 servos (right and left wheel and ping))) servo), a color detector in front of the robot but it's not actually connected

    20130605_232748.jpg


    20130605_232719.jpg



    Thanks a lot, i want to find a solution and you give me really good directions :D
    1024 x 768 - 104K
    1024 x 768 - 72K
  • fukakaifukakai Posts: 9
    edited 2013-06-05 14:56
    i forgot to say : when result value is 0,0,0,0.... the green light on the front panel of the ping))) is always off ! normally i can see a flash for each ping ...
  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-05 17:03
    The green LED on the front of the PING lights up when the PING transmits an ultrasonic pulse (when it's triggered). If the green LED doesn't go on, either the PING is not receiving a trigger pulse or it's not getting any power.

    Try making the trigger pulse longer. Change the first delayMicroseconds from 2 to 5 and the second delayMicroseconds from 5 to 10 and see what happens. Try adding a delayMicroseconds(5); between the digitalWrite(...,LOW); and the pinMode
  • fukakaifukakai Posts: 9
    edited 2013-06-06 01:10
    Mike Green,

    ok, i understand better now the green light on the front of the PING.
    I have always the same issue with delayMicroseconds(); corrections.

    i just timed with my phone, the PING sensor : it auto stopping exactly at 1 minute (01:00) after start !

    i tried to magnify delayMicroseconds() wtih 10 / 100 / 50 ,I have not noticed any variation.

    but i think, here we have a good clue :
    i added a delay(1000) inside the loop() method and it happens a curious thing : the ping is flashing all seconds but stopped also to exactly one minute !
    consequently : it take less measurements !
    so, can we deduce the issue is not related to the number of pings or their frequency ? but ... ? arf ... i think we reach the goal ^^
  • fukakaifukakai Posts: 9
    edited 2013-06-06 13:24
    hi,

    i have somes news ! good .. i'm not sure ^^.
    With a lot of "Serial.println()" commands in the NewPing library, i isolated the issue in the library code. it's :
    boolean NewPing::ping_trigger() {
         [..] 
           while (!(*_echoInput & _echoBit))                          // Wait for ping to start.
    		if (micros() > _max_time) return false;                // Something went wrong, abort.
         [..] 
    }
    

    this code fragment is on the line 99-99 into the NewPing.cpp file.
    I understand each time this code return false, the ping trigger return NO_ECHO and 0 value !!!!
    unsigned int NewPing::ping() {
    	if (!ping_trigger()) return NO_ECHO;                // Trigger a ping, if it returns false, return NO_ECHO to the calling function.
    	while (*_echoInput & _echoBit)                      // Wait for the ping echo.
    		if (micros() > _max_time) return NO_ECHO;       // Stop the loop and return NO_ECHO (false) if we're beyond the set maximum distance.
    	return (micros() - (_max_time - _maxEchoTime) - 5); // Calculate ping time, 5uS of overhead.
    }
    
    
    

    Obviously, i tried to comment this part of the code, and in place of return 0, it return always the last ping value !

    Actually, i don't know anymore, but i continue ...

    Help me if you are knowing wich var in this code fragment can cause this problem.

    Thank you in advance,

    Romain
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2013-06-07 09:26
    I am not sure what is causing the measurements to stop after 1 minute. But I see some other possible issues:

    What are your I/O pins in use for your entire board? I cannot quite tell from the photos. I just want to make sure you are not using P11 next to the breadboard and also the P11 Servo Header pins at the same time.

    The Ping))) sensor should get regulated 5V. If you connect the Ping))) sensor to the Servo Header pins, and the Servo Header jumper is set to VIN, it might be getting too much power. If you want to connect the Ping))) sensor to the Servo Header pins, set the jumper to 5V.

    In your list of measurements, I see I see "145" in there at random. They look like they might be false readings. I have seen random "144" when the Ping))) sensor is receiving a 40 kHz signal from the fluorescent light fixture in my office. If you think the "145" should not be there, try again with the lights off.
  • fukakaifukakai Posts: 9
    edited 2013-06-07 12:11
    hi Steph Lindsay, thanks for answer.

    I used differents I/O pins tu connect the PING))) sensor, 11 sure but, only one by one obviously (the one for cerveau or the other one on the left. I also connect the PING))) to the 9, 3, and 5 pins.

    According with the official tutorial, i've connect it on 5V Servo Headers pins and set the jumper to 5V (blocks with black, red, white) and i tried on the other 5V and GND pins.

    For measurements, i don't know 145 was false reading but it can be there the "bug" is starting. But i dont understand, with wich lights off you want i try ?

    Thanks in advance,

    Romain
  • fukakaifukakai Posts: 9
    edited 2013-06-09 00:50
    hi all,

    I was this week-end to the SUPINFO robotic competition in France : http://grenoble.labo-robotique.com/8-et-9-juin-2013-competition-robotique-a-supinfo-grenoble/.

    The robotic "full professor" of Grenoble campus lent me another PING))) sensor and it works perfectly !!!! With the exactly same codes i had, and all others i've tried -.-".

    So good news, it was an hardware issue !

    Thanks a lot for help and quick answers.

    Romain
  • fukakaifukakai Posts: 9
    edited 2013-06-10 15:16
    fukakai wrote: »
    hi all,

    I was this week-end to the SUPINFO robotic competition in France : http://grenoble.labo-robotique.com/8-et-9-juin-2013-competition-robotique-a-supinfo-grenoble/.

    The robotic "full professor" of Grenoble campus lent me another PING))) sensor and it works perfectly !!!! With the exactly same codes i had, and all others i've tried -.-".

    So good news, it was an hardware issue !

    Thanks a lot for help and quick answers.

    Romain

    Edit : Some photos for fun ;)http://troyes.labo-robotique.com/2013/06/09/competition-robotique-grenoble/
Sign In or Register to comment.