ronexg
Newbie level 5
- Joined
- Nov 21, 2013
- Messages
- 8
- Helped
- 5
- Reputation
- 10
- Reaction score
- 5
- Trophy points
- 1,283
- Activity points
- 1,347
Hello friends,
I want to share my small project...Ultrasonic distance measuring.
Compiler : MikroC Pro V.6
Xtal : 16MHz
Sensor : HC-SR04 from ebay
LCD : 20x4
Trigger pin was connected to RC3
Echo pin connected to RD0
Duration measure formula:
Duration(us) = TMR * Clock speed per instruction(Fosc/4) * timer pre-scale(1:4)
Clock speed per instruction(Fosc/4) : 16/4= 4MHz
Here i am using 1:1 Prescaler
So we get us = TMR*0.25*1............ 4MHz == 250 Nano sec == 0.25 us
for distance in centemeter divide by 58
Suppose we get 9327 as TMR value, the distance in mm is: (9327/58)*25 == 4020 mm (25 is 0.25 * 100 for avoiding floating value)
I want to share my small project...Ultrasonic distance measuring.
Compiler : MikroC Pro V.6
Xtal : 16MHz
Sensor : HC-SR04 from ebay
LCD : 20x4
Trigger pin was connected to RC3
Echo pin connected to RD0
Duration measure formula:
Duration(us) = TMR * Clock speed per instruction(Fosc/4) * timer pre-scale(1:4)
Clock speed per instruction(Fosc/4) : 16/4= 4MHz
Here i am using 1:1 Prescaler
So we get us = TMR*0.25*1............ 4MHz == 250 Nano sec == 0.25 us
for distance in centemeter divide by 58
Suppose we get 9327 as TMR value, the distance in mm is: (9327/58)*25 == 4020 mm (25 is 0.25 * 100 for avoiding floating value)