How can i use HC-SR04(Ultrasonic Sensor) with FRDM-TFC shield , KL25Z Board?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How can i use HC-SR04(Ultrasonic Sensor) with FRDM-TFC shield , KL25Z Board?

4,832 次查看
crististancana
Contributor I

Hello,  

I want to make a self-parking car with KL25Z board and FRDM-TFC Board(tfc kit for freescale cup). I can move the car forward ,backward , left and right and now i want to use HC-SR04 Sensor to measure distance to see if is enough space for parking and i found some problems:

1.I saw that the Sensor has 4 PINS (Vcc +5V,GND,Trig,Echo) the problem is that the board can give only 3.3V do you think it will work or i will need to use another source.

2.The library that i use is from here : https://community.nxp.com/docs/DOC-93914#comments  and i don t know exactly how to integrate that sensor in the code.

3.I understood the functionality of the sensor but i don t know exactly how to implement it.

If somebody have another idea how to measure the distance in any other which will work with that code i will really appreciate. 

I will need to finish that project until 15 June , if anyone can help me with those problem i will appreciate a lot .

Thank You!

Cristi frdm–kl25z, #frdm-tfc #freescale-cup #Sensor 

0 项奖励
回复
3 回复数

3,425 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Cristi,

Regarding your question how to connect the HC-SR04 Sensor to the FRDM-Kl25Z board, as you know that the HC-SR04 has four pins: VCC,GND,Trig,Echo. Firstly, the HC-SR04 use 5V logic, while the FRDM-Kl25Z uses 3.3V logic, you have to use the external open drain circuit such as 74LS05/06 to do the logic conversion, another anternative is to change KE family for example FRDM-KE06Z, the KE family is 5V logic.

Regarding the signal connection, I think you can connect the Trig signal of sensor to GPIO pin of Kinetis, connect the ECHO signal to the TPM or FTM channel.

for the software, you can set GPIO, delay some time, clear the GPIO, it is okay to generate the trigger signal. The TPM and FTM channel pin has capture function, you can set TPM/FTM in rising/falling edge triggering, once an edge of TPM/FTM channel is detected, the counter value of TPM/FTM will be latched to the CnV register automatically, an interrupt is triggered, in the ISR, you can read the CnV register and get the difference of two consecutive ISR, it is the pusle width.

Hope it can help you.

BR

Xiangjun Rong

0 项奖励
回复

2,671 次查看
wjchoi0712
Contributor I

Hello Xiangjun,

I also have question regarding this matter.

I am unsure how to the calculate the actual distance from the CnV values.

My Mod=7500 and the clock frequency is 20.97Mhz.

Thank you!!

0 项奖励
回复

2,668 次查看
ErichStyger
Specialist I

I wrote a tutorial for the FRDM-KL25Z a while back here:

https://mcuoneclipse.com/2013/01/01/tutorial-ultrasonic-ranging-with-the-freedom-board/

I hope this helps,

Erich

0 项奖励
回复