Ultrasonic Range finder Timing?

Hello Everyone

A colleague of mine is building a ultrasonic range finder and the design is based on Kerry Wong's design that he did.

http://www.kerrywong.com/2011/01/22/a-sensitive-diy-ultrasonic-range-sensor/

He has asked me to assist with programming the unit to make it a bit more advanced. He wants to connect a GLCD and wants me to program in menu structures for added features.

My question now after going through Kerry's code; The code is very much time dependent as I understand it since the operation of the process works with micro second periods, and if I add big menu structures I believe that I will effect the timing in some way or another?

So my question is, can I make the distance measurement calculation function work in the background, outside of my void loop so that the menu structure that I want to program into the void loop won't interfere with the timing of the process? Or is there possibly an alternative method of accomplishing this.

Thank you in advance for the assistance.

A copy of his code can be found over here:
http://www.kerrywong.com/blog/wp-content/uploads/2011/01/UltraSonicRangeFinder.tar.gz

So my question is, can I make the distance measurement calculation function work in the background

Sure, as soon as you install an operating system, so that "in the background" means something.

The Arduino doesn't have an OS, so there is no "background" process that can do anything.

What is the purpose of the menu? A range finder measures distances. I can't see how you need a menu for that.

Hey PaulS

Thanks for the quick feedback, so since there is only a single processor everything is time dependent. The idea of the menu structure is to just give it a better ui since Kerry's using the serial port to derive data from the project. To make it more of a standalone system.

Hello PaulS

If I wanted to implement the menu structure, would it be viable to have an ATTiny85 preform the measurement of the ultrasonic transducer, i.e. generate the pulse train, get the analog out from the Transducer and then communicate this value via I2C to my main processor which would then implement the menu structure.

So when I wanted to display the measurement I just read it via the I2C communication with the main micro controller and when I need to access the menu I don't read the value and run my menu functions? Let me know if this could work. Thanks in advance.

Dirk