Nice to see: the 16-mm ultrasonic modules fit perfectly well into the LEGO bricks.
The resonance frequency of ultrasonic modules can be higher or lower than the nominal frequency. These are the modules which are part of the HC-SR04 distance sensor. You might think that the transmitter and the receiver are selected as pairs, but they are not. So, the transmitter and the receiver will have their maximum responce at different frequencies and likely not exactly at the frequency of the signal sent by the main processor, which might be a EEM78P153S (27 MHz), STC11 (4 MHz) or even an ATtiny24 (12 MHz). (The other two chips are a MAX232 and a LM324.) If you want maximum reach of the distance sensor all the three frequencies should be the same.
Using the Arduino UNO you can generate frequencies in that range and check the voltage at the receiver. With the plotter of the "OLD" IDE, you can easily find the maximum of the resulting plot. This are the hardware connections you need: connect pins 9 and 10 (OC1A and OC1B) to the sender, connect the receiver signal to the rectifier diodes and the DC value to analog input A0.
Addendum:
the signal is generated by setting the ICR1 register to appropriate values.
If you set it to 400, the resulting frequency is 16,000,000 / 400 = 40,000 Hz.
If you set it to 399, you get 16,000,000 / 399 = 40,100.25 so steps will be about 100 Hz.
In case you want smaller steps, use a crystal of 20 MHz or even 25 MHz or go for the ARDUINO UNO R4 with 48 MHz.
It should be noted that the tickmaks that the Arduino Plotter shows on the x-axis are just sample numbers, they have nothing in common with the frequency as someone might suspect. The for-loop applies signals from 37 kHz to 43 kHz to the sender, the plotter shows the strength of the signal received.
If the distance between both is too small, the analog input is overdriven and you cannot see the exact maimum.
In this case, it is overdriven even more, and you can estimate that there is another maximum left from the main maximum. So it is very likely that the resonance frequencies of sender and receiver do not match.
More infosLukas Honerlage (german) https://wiki.hshl.de/wiki/index.php/Ultraschall_Abstandssensor_HC-SR04
David Pilling https://www.davidpilling.com/wiki/index.php/HCSR04


_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)


Comments