Page 1 of 1

ULP with ultrasonic sensor HC-SR04 / JSN-SR04T

Posted: Wed Apr 06, 2022 10:42 pm
by martinius96
Hello there, I am looking for advice from users with experience with programming ULP processor on ESP32 board (ESP32-WROOM-32 / ESP32-S).
Image
ESP32 main processor Xtensa will sleep in deep-sleep mode and ULP processor will be operating.
I want to use ESP32 with ultrasonic sensor HC-SR04 or JSN-SR04T.
Both sensors have Trigger and Echo signal.
Trigger is used for sending waves and Echo for their receiving.
In standard program, let's say Arduino Core there is used pulseIn() function that can return number of milliseconds from Echo pin state from LOW to HIGH - when wave was received.
Image
I don't know how to implement that in Assembly for ULP processor, because I haven't use Assembly in my life and it is something totally different for thinking about programming for me. It looks like I can use only RTC_IO pins and RTC_SLOW memory for ULP processor program storage and also for sharing datas between main application and ULP processor.

I have studied ESP-IDF documentation related to ULP processor and its instructions, but I don't know how to create two things:
  • How to measure time? From what i see in documentation I can only use ticks for measurement, that means 150k per second? How can I handle this value, when there is just 16-bit register so that is not enough, that's 65535 max value...
  • How to wait in program until GPIO read is HIGH?
Do you think it is possible to create program for that?

Re: ULP with ultrasonic sensor HC-SR04 / JSN-SR04T

Posted: Wed Apr 13, 2022 2:26 pm
by SOUF3D
Hello, I have the same issue, I want to wake up the ULP co-processor with an ultrasonic sensor. Did you find a solution for that?

Re: ULP with ultrasonic sensor HC-SR04 / JSN-SR04T

Posted: Wed Sep 21, 2022 9:52 am
by martinius96
SOUF3D wrote:
Wed Apr 13, 2022 2:26 pm
Hello, I have the same issue, I want to wake up the ULP co-processor with an ultrasonic sensor. Did you find a solution for that?
Unfortunately no. I haven't find any program implementation for ULP coprocessor that could I use.
All available implementations around are just for GPIO control (that is maximally what I can use).
But there isn't any for measuring time or pulseIn() C funtion equivalent.

Re: ULP with ultrasonic sensor HC-SR04 / JSN-SR04T

Posted: Sun Dec 31, 2023 6:17 pm
by martinius96
Year later, still no luck

Re: ULP with ultrasonic sensor HC-SR04 / JSN-SR04T

Posted: Mon Jan 01, 2024 11:01 am
by boarchuz
martinius96 wrote:
Wed Apr 06, 2022 10:42 pm
How to measure time?
The RTC tick counter is 48 bits, so there's more than enough. True, you can only read 16 bits in one instruction, but you can use multiple instructions, or you can sacrifice some resolution at the lower end by reading RTC_SLOW_TICKS[18:3], for example.
martinius96 wrote:
Wed Apr 06, 2022 10:42 pm
How to wait in program until GPIO read is HIGH?
Read the pin level. If zero, goto previous instruction.
martinius96 wrote:
Wed Apr 06, 2022 10:42 pm
Do you think it is possible to create program for that?
Yes, I admire your patience but I think you'll be surprised how doable this is if you have a try yourself. Share your code here if you hit any snags. Leave the timing logic til last, that will be the most complex part.

Re: ULP with ultrasonic sensor HC-SR04 / JSN-SR04T

Posted: Sun Mar 17, 2024 12:37 am
by martinius96
Aren't you interested to write it for me, based on deal for service?