Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

write timer, read timer for C18

Status
Not open for further replies.

chansiuming

New Member
I am using 18F4550 series with C18 to find out the pulse. I got a sensor SRF04 which connected the Trigger to RD6 and Echo to RD7. The RD6 will send 10us pulse to Trigger and Echo will send back the pulse(distance) to RD7. Now my question is how can i count the Echo pulse? i found a post which is similar to my question but i dun understand at allhttps://www.electro-tech-online.com/threads/period-calculation-with-pic18-using-c18.107671/
I have to use Write timer and read timer? i have done the first part for opentimer:

OpenTimer0(Timer_INT_OFF &
T0_8BIT &
T0_source_INT &
T0_PS_1_1);

The Echo pulse will be between 100us to 25ms. And i am using 1MHz internal osc. I am confusing on write timer, read timer after i look through the data sheet and c compiler library... how can it function and how can i get it work to count the pulse?
 
You are wanting to measure the time between the sending and the receiving of the pulse right? Use a button to send the pulse and start the timer. Enable an external interrupt and when it is detected, turn the timer off and read the registers. If you want to see how to work with the timer library in the C18 compiler, check out my signature. But keep in mind using libraries will have some infact on your measurements.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top