WOOOHOOO !   IT IS WORKY !!! ... or mostly so - some fine tuning is still required...

But holy cow lets compare ....

236 micro seconds vs 18,392 micro seconds ..

Ya a bit of a difference...   

Here are some pros and cons of the new PulseIn

PROS

  • WAY FASTER (nearly 2 orders of magnitude)
  • Probably DOES NOT INTERFERE WITH SERVOS !!! - a big one for me

CONS

  • Possibly a little less accurate - although I have not noticed .. additionally a little pre-filtering can be done easily

Another nice accessory from this project was the load timings.. now the Arduino load becomes easily observable ..  this takes a considerable amount of mystery out of trouble-shooting

beetlejuice

10 years 4 months ago

Congrat, it's a lot faster !

I've a question : with the non blocking script, how to take the current value ?

By exemple can we use someting like this ? : if ( sr04.value() <= 30) .....

I didn't found UltraSonic service in the javadoc .

Hi Bettlejuice ..

Ya - Javadocs are out often out of sync.
Please refere to this post for strategies on getting meaningful information - http://myrobotlab.org/content/what-methods-can-i-use
My latest developments have not yet been "checked-in"..

But the interface should be similar to this :

(blocking mode)

 if (sr04.range() <= 30)

(non-blocking event mode)

sr04.addRangeListener(python)
sr04.startRanging()

def range(dist):
    if (dist <= 30)

 

The blocking mode is pretty trivial to implement - the non-blocking event mode would be very good for robotics ! (hopefully I can figure out how to do this)