Distancing Measuring with HC-SR04 For CY8CKIT-059 PSoC® 5LP

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.
Anonymous
Not applicable

Hi everyone,

   

I've very new to usage of PSoC, but I have a project that I want to attempt in using PSoC as the microcontroller to control the HC-SR04 chip and return a distance.

   

I understand how the HC-SR04 works on the ardriuno but when it comes to using the PSoC I used the following code as a guide.

   

http://www.cypress.com/forum/psoc-3-device-programming/ultrasonic-distance-sensor-hc-sro4

   

For the last couple of hours, I've been trying to port over the code the PSoC 5LP and specifically the CY8CKIT-059. When I upload the current code into the device, the distance does not show and I'm unsure as to why this is so.

   

 

   

Any Assistance would be greatly appreciated. I have uploaded the project below but it is literally a copy of Dana's project except with an adjust target device. 

   

 

   

Thanks in advance

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum.

   

The original project uses an LCD module which you in your project connected to port0. Some of the port0 pins have got bypass caps for analog and CapSense handling. When using am LCD, better connect to Port2.

   

You are using Sprintf(). This requires some modifications:

   

In .cydwr view, "System" tab: change the heap size to 0x0200

   

in "Project->Build Settings->Linker": Set "use newlib nano float formatting" to true.

   

In the case you haven't got an LCD connected you should use an UART connected to P12_7 (Tx) and P12_6 (Rx). A Terminal program as PuTTY can be used to show the values on your computer screen using the com port that shows up in device manager when you connect your -059 board to USB

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob,

   

Thanks so much for the help, I was able to get it to work following the instructions you gave me.
The next part of the project involves importing the PSoC distance data into labview through serial communication and graphing the distance result, So I am trying to get that to work now.

   

Thanks again

   

-Sam

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are always welcome, Sam.

   

Some hints: Probably quite cold in Down Under right now (we had here 35°C yesterday, SUMMER). Sonic speed is mostly dependent of environment temperature which you might take into consideration.

   

Sonic speed in air C[m/s] = 331,5 + 0.6*T[°C]

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I ported this code to my psoc 3 CY8CKIT-030 by downloading and using the device selector to change the chip.  I upgraded the user modules to the latest version and changed the pins:  the trigger is on P3[3] and the Echo on P3[4].  I see RANGE =, but it doesn't do anything until I unplug the echo pin wire and plug it back in.  Kind of strange I think.  Why is the setup using a timer instead of a counter?  Wouldn't they do the same thing?  Any ideas how I can get this to trigger without having to remove the wire?

0 Likes
Anonymous
Not applicable

error on my part.  I had the board set to run at 3.3V.  The HC-SR05 is happier at 5V.  I put the power pin on the HC-SR04 to V5.0 on the board and the device started working.  When plugged in to V3.3 it stopps working.  I had read that the sensor could do up to 5 V, but apparently it must be AT 5V.  

0 Likes