PDA

View Full Version : TIMER1 Interrupts and CCP



mcbeasleyjr
- 27th January 2009, 07:37
I need help. I've tried using the timers before and I just don't seem to be doing something quite right. My goal is this. I have developed an intelligent mobile robot using the PIC16F877A. It uses Infrared Technology for obstacle avoidance and at some point, possibly even serial communications. Other implementations are: temperature sensing, voltage measurement, 2 x 16 (or 4 x 20) lcd display, cds photocells for light measurement. I would now like to implement an ultrasonic range finder on this system. The problem that I am having is that I don't know how to use TIMER1 to time how long it takes for the transmission signal to be received. I know the calculations, i.e., 340m/s @ 20C and t/2 for half of the measurement. I just need to know how to use TIMER1 and the CCP module to capture the interrupt and tell me how long it took. I am using the PicBasic language as I am not familiar with assembly. Besides, its converted to assembly and hex for programming. If you could please help me with this I would appreciate it. I've also considered the RCTIME command but I'm not certain that would give me the accuracy that I am looking for. Please help if you can. Thank you all in advance.

P.S., I can post the code that I have for my robot if you are interested in that also. Maybe you could even tell me where to put the interrupts in it...lol. Thanks again!

Bruce
- 27th January 2009, 16:41
Here's an example of using capture http://www.melabs.com/resources/samples/x2/pbp/ccpx2.bas