Highly Accurate driver for the Sharp 2D120X proximity sensor

There’s nothing stopping the sensors from reading at the same time, they don’t stop reading distance just because you’re not reading the ADC :slight_smile:

You’d have to implement it yourself with multiple sensor threads, i don’t have any plans to add async callbacks as i’m not sure how useful that would be. If you need to know the distance, you tend to need to know it for a specific calculation not several ms later.

http://www.tinyclr.com/forum/16/1287/#/1/msg13472

I put up some code to do this in the above link (since I couldn’t find this thread, before now :-[) - Don’t have my sensors yet, but once they come in I’ll test with them.

It should be done with either the Classic Async Pattern or the Event-Based Async Pattern. Based on the use of the class, Event based would be the correct pattern for this library.

Im trying to run the demo code from http://www.tinyclr.com/codeshare/entry/63 and Im getting an error that Im not familiar with.

Ascended.SPOT.Sensors.Distance.Sharp2D120X’: type used in a using statement must be implicitly convertible to 'System.IDisposable

it seems to not like the way its being created:

using (Sharp2D120X sensor = new Sharp2D120X((Cpu.Pin)AnalogIn.Pin.Ain0))

Admittedly Im still rather new at this and Im unable to find a suitable solution. Can someone point me in the right direction?

welcome to forum.

you can not use this class within a using statement. it was not implemented with that capability .

create without the using.

if you are still having a problem, start a we thread.

Thanks Mark. I’ve made it work now I just need to hit the books so I can understand why it works.

At least the code executes, unfortunately everything appears to be 17.x cm away. One thing at a time.

If you want a no bs long range accurate sensor I would recommend the maxbotic sonar sensors. I’ve tried pretty much all of them and the triangulation ones are junk when it comes to anything over 100cm (because of triangulation). In addition the sharp sensors are really (really) sensitive to any type of noise.

These ones are AWESOME:

They are accurate from 30cm to 500cm. Anything under 30cm reads as 30cm. The sharp sensors gets really weird if something is up close and personal to the sensor.

If you need ranges less than 30cm there are different sharp sensors which are pretty good.