Shop OBEX P1 Docs P2 Docs Learn Events
Very strange problem with PING))) sensor, is it broken? Please help! — Parallax Forums

Very strange problem with PING))) sensor, is it broken? Please help!

cprcrackcprcrack Posts: 12
edited 2008-07-22 12:21 in Robotics
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:
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

  • lairdtlairdt Posts: 36
    edited 2008-07-21 23:37
    Greetings!

    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
  • cprcrackcprcrack Posts: 12
    edited 2008-07-21 23:42
    Of course I have read the documentation. I thought about the delay, but it does not work even with a 1000 ms pause! The first readings record 0 on time variable. In my real program the delay is aproximately of 20ms, so I don't think thats the problem know, but maybe what cause my sensor to break... what do you think?

    Thank you for your answer
  • lairdtlairdt Posts: 36
    edited 2008-07-22 00:19
    Hmmm... Doesn't sound like a delay issue then with that much delay. My ACT only flashes when I'm polling the Ping, but I was only polling every 300ms, so for your quick cycle that's normal. If you attempt to poll too fast you don't get a valid number, it comes back as junk (lease it did with my Prop setup). I don't think your setup is broken, but don't know what's up.

    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.
  • Larry SutherlandLarry Sutherland Posts: 77
    edited 2008-07-22 00:22
    cprcrack

    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
  • cprcrackcprcrack Posts: 12
    edited 2008-07-22 00:52
    lairdt said...
    Hmmm... Doesn't sound like a delay issue then with that much delay. My ACT only flashes when I'm polling the Ping, but I was only polling every 300ms, so for your quick cycle that's normal. If you attempt to poll too fast you don't get a valid number, it comes back as junk (lease it did with my Prop setup). I don't think your setup is broken, but don't know what's up.

    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.
    My data line uses an extension wire and another wire connected to the Breadboard of the Sumo-Bot, and then to the BS2 pin. I thinks it is correct because there is continuity and I have checked using another pin and the same happens. About the 5v, I have been checking it and I think that could be the problem. My BS2 correctly transforms my 6v to 5v, but when PING is connected, it seems that during the first readings the voltage is about 4 - 4,2v and then it goes to 5v and starts working well! That could also be related with the start of the motors I mention earlier, because the have a power consumption, although they use 6v directly.

    How can I solve this???

    Thank you very much for your help.
  • lairdtlairdt Posts: 36
    edited 2008-07-22 03:15
    Voltage is certainly low! Running from 9v battery I found it didn't last long with Ping running. Depending on the draw, you might be able to boost your saging voltage with a capacitor close to the Ping module, but it's not going to boost enough if the draw is too high.
  • cprcrackcprcrack Posts: 12
    edited 2008-07-22 12:21
    I have tried 4 new fresh batteries (1,5v) which provide 6,4v and the problems was solved. Then I used another 4 batteres which provided 6v and the problem was softer, but there was a little problem. If my batteries only work well when they provide 6v or more, I think I will expend a fortune in new batteries!

    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
Sign In or Register to comment.