Hi, teckelThanks for the answer. I want to make my library better and I need your help. Tell me a little more about problems in libraries like mine? Thank you.
I take a different approach - use as many standard Arduino framework features as possible, so I do not have problems (like you do) with the Arduino MCU Zoo (AVR,Teensy, ESP8266, ESP32, STM32, Nordic RN52). For examle I have not seen direct port manipulations for popular ESP8266, ESP32, STM32, Nordic RN52 in your library. Correct me if I wrong. Why are you mixing the Arduino framework with low AVR-GCC, etc.? It will be cleaner & loop faster if you made all code in avr-gcc, esp-udf, stm hal etc.I'm to trying to say that you library is bad. It is different. With your fast low level port manipulation you lose the versatility of the Arduino. This is an examle:"This allows a// properly developed sketch to multitask. Be aware that because the ping_timer method uses Timer2,// other features or libraries that also use Timer2 would be effected. For example, the PWM function on// pins 3 & 11 on Arduino Uno (pins 9 and 11 on Arduino Mega) and the Tone library. Note, only the PWM// functionality of the pins is lost (as they use Timer2 to do PWM), the pins are still available to use.// NOTE: For Teensy/Leonardo (ATmega32U4) the library uses Timer4 instead of Timer2."P.S. Do not blame me that the library is slow, blame Arduino framework. If you want fast code, then the Arduino framework is not for you.
I bought one of those parking sensors from aliexpress and it has a lower limit of 30cm...Having reverse engineering it, does't seem to me that switching from output to input is actually the problem. In my case, the sensing side of the circuit is always listening.As far as I understand, one problem is the fact that it transmits 20 pulses (in my case at least) and that limits the minimum distance to about 10cm. The biggest problem though by far, is the oscilations on the output transformer that occur once the pulses from the microcontroller have stopped.I am gonna try replacing the microcontroller with one that I can programm and adding a little aditional circuitry to dumpen the oscilation once the pulses have finished.I think by reducing the number of pulses and with the additional circuitry, I will be able to get reaadings down to about 10cm
Or you could just save the hassle and buy other waterproof ultrasonic sensors. There are other IP67 waterproof rated ultrasonic sensors with 3cm minimum distance costing around $20.
Yes but that's not fun..Can you link some of those 3cm minimum distance sensors?I suspect they use two sensors for transmiting and recieving.I want to mount them on my car so the single sensor ones are more suitable for me.
Yes, you are correct, it does use 2 sensors, 1 for transmitting and 1 for receiving.