Inner Workings of the Ultrasonic Sensor?

How does EasyC manage the Ultrasonic Sensor Internally? The sensor uses only digital interrupts and digital output ports, and yet EasyC gives an analog value. I have a theory that EasyC is doing some background magic to make this work, but it could also be that the Ultrasonic Sensor handles everything itself. But why two ports?

I would like to know how the Ultrasonic Sensor works, from the inernals to the C code. This includes the reasoning behind needing start and stop functions alongside the ability to get the current distance value.

Here is a link to an explanation of a similar sensor, the VEX sensor works on the same principle, EasyC will be constantly sending the “ping” and listening for the echo in the background.

Ultrasonic sensor tutorial


Thanks,I figured out how it worked and then I checked here.

Now, we’re having a dispute/problem: The sensor only uses digital ports and receives/sends back digital on/off values, so I would have thought it is a digital sensor. However, my intructor says it is an analog sensor because of the measurement of the time between the send/receive resulting in an analog value.

Is the sensor itself analog or digital?

A somewhat philosophical discussion but if pressed I would say it was an analog sensor with a digital interface :slight_smile:

I don’t know how exactly how this specific ultrasonic rangefinder works internally, but I highly doubt that it’s analog. As for adding to the philosophical discussion, digital is just funny looking analog.

Essentially, the ultrasonic sensor sends out a “ping”, then listens for the same sound wave to bounce off an object and return to a very sensitive microphone.

Since the speed of sound is a known value, it can take the time between sending the ping and hearing the response and do a very simple calculation to determine distance.

Technically, it is a “digital” sensor, since if all you did was listen to the ports you would essentially see a 1 or a 0, or a series of square waves as opposed to an analog signal. However, the smarts within the easyC library and the Cortex make it look like it is an “analog” sensor.

I don’t think that anyone is arguing that the sensor communicates to the cortex in an analog way. The debate was whether or not the senor is internally analog or digital.

on a similar note—
can sounds/vibrations (like stomping of feet) cause any interaction with these sensors?