Very strange problem with PING))) sensor, is it broken? Please help!
Hello, I am spanish, sorry for my English. I really like the PING))) sensor but I am having some problems with it in my Sumo-Bot. As you probably know this are the basic commands for using the PING sensor:
So in the "time" variable you get stored the time in pairs of microseconds·(BS2)·the sound waves take to come back. This time can be up to 19 ms if the object is very far. On the other hand, the "Pulsin" command counts up to 655 ms if it does not detect any 1 comming throw PINGpin. And apparently that happens sometimes in my case.
When I run a simple program to show the "time" value in my computer screen, it works perfectly. But if I shut down the robot and then put it on again, the first 5-10 readings spend 655 ms and return a 0 (that's what·happens when "Pulsin" time-outs). In a more complex program of Sumo, it seems to happen the same, but not only in the first readings, it happens for a lot of time. That gets solved (I don't know why) pressing the Reset button, but then randomly happens another time. It sometimes happens when I put the On-Off switch in position 2 (which also starts the motors).
To sum up, I don't know wtf is happening. Is it normal for the PING sensor not to work well in the first readings? Is it broken? Could it be because I have been reading the sensor two often without a pause? I have been reading the sensor every 20 ms. In fact, the ACT led blinks so quickly that it seems to be on all the time... What does it happen if you send a Pulsout to the PING sensor when it has not finished reading the last sound waves?
In my case I only need to know if the object is at less than 50 cm (20 inches) so I use this code:
This can be understood if you go to the PING sensor datasheet and see the square wave diagram. If the PING sensor is still sending a 1 throw PINGpin after 3 ms, it means that the object is more than 50cm / 20in far. But in this case if the object is not close, the next Pulsout command will execute before the PING sensor has finished sending the pulse throw PINGpin, could·this be a reason for damaging the PING·sensor?·Anyway, this works perfectly sometimes, like in the more simple code, but tend to give me false positives the first time, then it gets solved when I press the reset button, but sometimes fails when putting on the motors, sometimes during normal program execution...
I am terribly sorry for all the words, it was really difficult to write in English for me. PLEASE HELP !!!
Do Pulsout PINGpin, 2 Pulsin PINGpin, 1, time Loop
So in the "time" variable you get stored the time in pairs of microseconds·(BS2)·the sound waves take to come back. This time can be up to 19 ms if the object is very far. On the other hand, the "Pulsin" command counts up to 655 ms if it does not detect any 1 comming throw PINGpin. And apparently that happens sometimes in my case.
When I run a simple program to show the "time" value in my computer screen, it works perfectly. But if I shut down the robot and then put it on again, the first 5-10 readings spend 655 ms and return a 0 (that's what·happens when "Pulsin" time-outs). In a more complex program of Sumo, it seems to happen the same, but not only in the first readings, it happens for a lot of time. That gets solved (I don't know why) pressing the Reset button, but then randomly happens another time. It sometimes happens when I put the On-Off switch in position 2 (which also starts the motors).
To sum up, I don't know wtf is happening. Is it normal for the PING sensor not to work well in the first readings? Is it broken? Could it be because I have been reading the sensor two often without a pause? I have been reading the sensor every 20 ms. In fact, the ACT led blinks so quickly that it seems to be on all the time... What does it happen if you send a Pulsout to the PING sensor when it has not finished reading the last sound waves?
In my case I only need to know if the object is at less than 50 cm (20 inches) so I use this code:
Do Pulsout PINGpin, 2 Pause 3 'the time for the sounds waves to move 50 cm Input PINGpin Target = ~PINGpin Loop
This can be understood if you go to the PING sensor datasheet and see the square wave diagram. If the PING sensor is still sending a 1 throw PINGpin after 3 ms, it means that the object is more than 50cm / 20in far. But in this case if the object is not close, the next Pulsout command will execute before the PING sensor has finished sending the pulse throw PINGpin, could·this be a reason for damaging the PING·sensor?·Anyway, this works perfectly sometimes, like in the more simple code, but tend to give me false positives the first time, then it gets solved when I press the reset button, but sometimes fails when putting on the motors, sometimes during normal program execution...
I am terribly sorry for all the words, it was really difficult to write in English for me. PLEASE HELP !!!
Comments
From my working with the Ping))) it sounds like you're not giving it quite enough time to complete a cycle.
I assume that you've looked at the timing requirements from the documentation at: http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/28015-PING-v1.5.pdf. According to this, it can take 18.5ms max to get a value, plus the 200us delay until the next command. See if adding a 5ms delay solves the problem, and then lower it from there to see how much delay you really need in your case.
Tom
Thank you for your answer
My propeller setup comes back with a good reading on the first powerup cycle and every cycle afterward with my 300ms delay, but we're talking different hardware here. I'd check your 5v at the Ping, and especially check your data line to the Ping to make sure it's not picking up some noise from something nearby.
I think this text will help you with your ping apps.; however, the LCD is and important accessory to have and to learn Ping apps.
http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/List/1/ProductID/418/Default.aspx?txtSearch=smart+sensors&SortField=ProductName,ProductName
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Right_Uderstanding, Attitude, Speech, Action, Livelihood, Effort, Concentration, and Awareness
How can I solve this???
Thank you very much for your help.
I can't understand very well what you suggest with the capacitor (I am spanish and I don't understand some words you used and can't find the meaning). Could that improve the situation and make my PING sensor work better when the batteries at not absolutly new? All the other components on the robot work well with batteries providing about 5,5v... Where do I have to put the capacitor? Thanks