Shop OBEX P1 Docs P2 Docs Learn Events
Laser Ping operation question — Parallax Forums

Laser Ping operation question

Not sure I am doing this right, but here is what I am driving a laserPing for testing:
pub Pulse_Laser

    dira[12] := 1
    outa[12] := 0
    repeat
        outa[12] := 1
        outa[12] := 0
        dira[12] := 0
        waitcnt(clkfreq/1375 + cnt)
' for something to do
        waitcnt(clkfreq/5 + cnt)
        dira[12] := 1
This gives me a 7us pulse with a .5 second repetition rate. The 1375 value (yes, I know evil magic number. but this is only for testing) gives about a 750us delay after which I should see a pulse out of the laserPing.
the for something to do is a place holder for whatever I will do to measure the pulse width. No pulse comes back. Even switched to input so that nothing could be loading the output pin. Same behavior at 3 or 5V

If I plug in a standard PING module, then I see the pulse followed by another which varies with object to ping distance as expected.

Thanks,

Frank

Hopefully someone will say try X and here is what you did wrong rather than a non-functional laserPing.

Comments

  • The laser ping doesn't work the same as the PING module. It's serial in nature and requires configuration.

    Mike
  • iseries wrote: »
    The laser ping doesn't work the same as the PING module. It's serial in nature and requires configuration.

    Mike

    It works both ways. It does work like a normal Ping AND it can use a serial connection.
  • That is what I thought from the first half of the data sheet. If I jumper for serial, it seems from the same sheet that it should start streaming readings continuously and if it doesn't then it's likely defective.

    The timing i am getting was observed using an AD2 in scope mode.

    Thx
  • If I jumper for serial, it seems from the same sheet that it should start streaming readings continuously and if it doesn't then it's likely defective.

    FWIW, I jumpered mine for continuous serial and it works fine.

  • Quick guess... Powercycle after applying the jumper to get to serial mode?

  • Yep, Jumpered and no serial pulses. Device looks like it is non-functional.
  • @"frank freedman"

    I bought one of these recently and initially tried getting it working and failed, without noticing on the product page that it is supposed to be drop-in compatible with the Ultrasonic PING. I know from above you're aware it's compatible (not when in serial mode), but I was curious if you've tried any existing objects for the original ultrasonic ping? The driver/demo included with the PropTool library worked straight away for me.

    Cheers
  • Is maybe a pull-up/pull-down missing? Does a scope show the pin transitioning properly when driven?
  • avsa242 wrote: »
    The driver/demo included with the PropTool library worked straight away for me.

    Mine also worked fine with Ping code before I modified it for continuous serial output.

  • @JRoark, did I miss something in the docs? No mention of a pullup needed.


    @"Duane Degn" starting to try the demo you mentioned, but may have to butcher it up a bit to use serial port rather than serial LCD. Still think it's dead though.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2020-10-19 04:30
    Yep, Still dead. Will need to find out how to replace it. No silly strings shooter for your tonight!!!
  • Have you tried the demo code Duane mentioned with an unmodified LaserPing (ie. remove any jumper/etc... back to default state).

    I think this could be the code: https://www.parallax.com/downloads/ping-ultrasonic-distance-sensor-propeller-code

    Wire this up as explained in the comments at the top of the code file. The two LEDs could be left out for testing, just the LaserPing connections needed; Signal, 3.3V and Ground.

    This should work for a Ping or LaserPing. And you should be able to drop either into the same circuit and see the output on the parallax serial terminal set to 9600 baud.
    Make sure you power off/on the ping/laserping and propeller board after changing the device. (probably not critical for ping, but laserping only decides it's mode at power-up AFAIK, so if you don't see the output you expect, powercycle everything!)

    If the LaserPing fails to output in default PWM mode using unmodified Parallax code sample then it could be faulty- and in that case I'd suggest you contact support@parallax.com with your sales order number to request a replacement. I'm flagging your issue over to the support desk in-case you contact them, so they'll be aware of the details and save you time re-explaining!

  • Tried it. Ping works, laserping does not. Device is really dead. Now to find out where to send the DOA part.
  • Laser Ping now works with replacement part.

    Test fixture listed prior entry on this thread works as expected. There is a bit more variation for a fixed distance than I had expected. Not sure why.

  • Clock LoopClock Loop Posts: 2,069
    edited 2020-10-24 23:42
    Laser Ping now works with replacement part.

    Test fixture listed prior entry on this thread works as expected. There is a bit more variation for a fixed distance than I had expected. Not sure why.

    Im curious about this, as I do not have a laser ping yet.

    Is the variation similar to a accellerometer? where the values fluctuate a bit even if no movement is going on?
    Is this variation so small that it will not matter?
    (like if you move the target 1cm away from the laser ping, does the change in the pings output change way more than the variation?)
    I guess this is the devices hysteresis in a sense?

    I am wondering because I was thinking of using a laser ping to read a stream of data from a block of wood with specific notches cut out to represent a serial data stream with start bit, stop bit and data.
  • Here is the trace with the unit facing the wall at 12"distance. Ambient light does not affect the output. I have turned on 64X oversampling to give an idea of the range of variation seen. The laserping is mounted on the silly string device.
    Screenshot%20from%202020-10-24%2019-51-22.png
  • Now to get back to the silly string thing. Too bad the Mystery box did not have and emic2 in it. That could have some interesting possibilities......
  • there is a natural variance in the ToF values, they're not perfect devices, but they are pretty good.

    You can do some statistic analysis (gaussian fit) on the returned data and get some decent results.
  • For what it's worth, I've found a ultrasound sensors compliment optical sensors really well. There are some things ultrasound doesn't detect well (like my couch). Obstacles ultrasounds fails to detect are often detected by optical sensors. I think my robots with both type of sensors perform the best.

    Trying to measure the time of flight of light has got to be a lot less precise than measuring time of flight of sound. It still seems like Voodoo magic a sensor as small as the LaserPing can measure time of flight of light.
Sign In or Register to comment.