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.
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.
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.