ULP with ultrasonic sensor HC-SR04 / JSN-SR04T

martinius96
Posts: 33
Joined: Thu Dec 13, 2018 1:39 am

ULP with ultrasonic sensor HC-SR04 / JSN-SR04T

Postby martinius96 » Wed Apr 06, 2022 10:42 pm

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?

SOUF3D
Posts: 2
Joined: Tue Apr 12, 2022 3:56 pm

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

Postby SOUF3D » 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?

martinius96
Posts: 33
Joined: Thu Dec 13, 2018 1:39 am

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

Postby martinius96 » Wed Sep 21, 2022 9:52 am

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.

martinius96
Posts: 33
Joined: Thu Dec 13, 2018 1:39 am

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

Postby martinius96 » Sun Dec 31, 2023 6:17 pm

Year later, still no luck

boarchuz
Posts: 604
Joined: Tue Aug 21, 2018 5:28 am

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

Postby boarchuz » Mon Jan 01, 2024 11:01 am

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.

martinius96
Posts: 33
Joined: Thu Dec 13, 2018 1:39 am

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

Postby martinius96 » Sun Mar 17, 2024 12:37 am

Aren't you interested to write it for me, based on deal for service?

Who is online

Users browsing this forum: No registered users and 75 guests