12 years, 1 month ago.

Pulse width input to nxp lpc 11u24

Hi All,

Wonder if anyone can give any advice. I am currently trying to get an ultrasonic range sensor working. I have it working using the analog voltage output it gives no problem (although some scaling work is required!) The data sheets for the ultrasonic sensor state that for best results the pulse width output should be used. I was wondering if anyone could give me any advice on whether the microcontroller will accept this and if it does then what input I use, etc. The data sheet states a pulse width of 58 micro seconds per cm.

I'm using the NXP LPC 11U24 microcrontroller The ultrasonic sensor is a MB7060 XL Maxsonar WR http://www.maxbotix.com/documents/MB7060-MB7070_Datasheet.pdf

Any help would be greatly appreciated. I'm fairly new to this but have a general grasp of things (I think!)

Many Thanks Rob

2 Answers

12 years, 1 month ago.

58 microseconds is quite a long time for a microcontroller. You could do something complicated with timer registers, but I would just use Timer + DigitalIn. If you want it non-blocking (so other code runs while it is rangefinding), you can use interruptIn.

If you search on ultrasonic: http://mbed.org/search/?type=&q=ultrasonic, you get quite some rangefinder modules. Some might be exactly the same as what you need, but at least most will also use a pulse width input.

12 years, 1 month ago.

Hi Thanks for that. I have found many examples of code which can read the pulse signal. One last thing, could you tell me which pin on the microcontroller I need to use to connect the signal from the sensor (the pulse width signal)? Thanks

If you use DigitalIn you can use any pin. If you use InterruptIn you need one which supports InterruptIn (http://mbed.org/handbook/InterruptIn)

posted by Erik - 17 Jul 2013

Thanks. It appears the best way is to use the Interruptin. I assume using any digital in pin (except 19 and 20) will give a logic 0 for voltage below 0.8v and logic 1 for voltage over 2v. Its just a case of putting together a program which can accurately time how long this is for? I don't suppose anyone would know the accuracy that could be achieved with this? As mentioned above the shortest would be 58 micro seconds for a distance of 1 cm. Would it be quick enough to pick this up? Many Thanks Rob

posted by robert heaney 17 Jul 2013

With the 11u24 you should be able to use any pin. Might be just as easy to begin with DigitalIn. But the timing goes with microsecond resolution, it might be a few off due to overhead, but not more than that.

posted by Erik - 17 Jul 2013

That's great. Thanks for your help.

posted by robert heaney 17 Jul 2013