UltraSonic (HC-SR04) Sample Project (CY8CKIT-044)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

As someone asked for help with CY8CKIT-042, I decided to leave my CY8CKIT-044 version here.

IMG_2529.JPG

This HC-SR04 sensor module is somewhat affordable and looks simple, but the ICs on the module do nice job!

IMG_2530.JPG

At first, I set the Timer Clock Frequency to 10MHz, so that the calculation would be simple,

but with the 24MHz source clock, the error is rather large and I ended up to have measurement

errors around 2cm for CY8CKIT-044 and 4cm for CY8CKIT-042.

Then Considering the hint from lukebartol-san, I changed the Timer Clock Frequency to 12MHz

so that the clock error is much smaller, and I got less than 1cm error(s) for both CY8CKIT-044

and CY8CKIT-042.

Schematic.JPG

Last but not least, as the module requires 5V operation, we need to set J9 to 2-3 from 1-2.

moto

4 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

本サンプルは CQ出版 インターフェース 12月号に

ふえる今どきセンサNote

その11 距離を測る定番デバイス…超音波センサ

として掲載されました。

I contributed this sample project to a Japanese

technical magazine "Interface" Dec. edition.

2018年12月号 | Interface – CQ出版

moto

Hello,

I used a bit different approach, to fully utilise the programmable blocks in a PSoC. It has the advantage that no calculation is done in firmware.

https://www.element14.com/community/community/project14/programmable-logic/blog/2019/06/13/psoc-ultr...

David

MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear David-san,

Nice work!

I think that my project was porting from my mbed sample where I could not use hardware timer trigger.

And with PSoC although I wanted to use the hardware timer at the time of writing I was still beginner and I could not figure out how.

So I appreciate your posting of sample which is using the hardware timer to count the echo time, it should give us better accuracy.

I would recommend and/or ask you to post this as an individual topic to the Code Examples Page so that others can find it easily.

Community Code Examples

Last not least, I like you craft work of the case, too 🙂

Best Regards,

19-Jun-2019

Motoo Tanaka

MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I added a sample for PSoC 6 (CY8CKIT-062-WIFI-BIT) at

HOW TO INTERFACE HC-SR04 ULTRASONIC SENSOR WITH PSOC 6

I learned a timer usage from David-san's sample 😉

moto