I want to measure the time it takes a penny to fall a distance equal to its circumference, which is very close to .75". By my calculation, it should take about 62.3 mS if uninhibited. However, I intend to slow its fall with neodymium magnets, and I don't know how much time will be added to that 62.3 mS by the effect of the magnets, since I haven't yet built the contraption.
I do have a PIC12F509 in a circuit with an LED and a phototransistor that is recognizing the logic level shift from the phototransistor as the penny blocks the light from the LED. And, I have an LCD connected that will display the time if I can record it.
What I don't have is the code to measure the time it takes the penny to pass between the LED and the phototransistor. I had hoped to use the PULSIN command, and made some progress with it until I realized that the maximum time it can measure is 16.38 mS.
My next hope is to use Timer0, however Timer0 can only measure up to 65.5 mS (assuming a 4MHz clock, which is what I am using.) Thus, I suppose I need to use the prescaler function to measure longer times. How much longer, I really don't know, but I guess that doubling the time to 131 mS would be sufficient. I can't imagine that the small neodymium magnets that I plan to use would be more effective than that.
Any suggestions would be welcome; sample code would be wonderful. I am using PicBasicPro 3 as the compiler, and I am very green with it.
Thanks.
I do have a PIC12F509 in a circuit with an LED and a phototransistor that is recognizing the logic level shift from the phototransistor as the penny blocks the light from the LED. And, I have an LCD connected that will display the time if I can record it.
What I don't have is the code to measure the time it takes the penny to pass between the LED and the phototransistor. I had hoped to use the PULSIN command, and made some progress with it until I realized that the maximum time it can measure is 16.38 mS.
My next hope is to use Timer0, however Timer0 can only measure up to 65.5 mS (assuming a 4MHz clock, which is what I am using.) Thus, I suppose I need to use the prescaler function to measure longer times. How much longer, I really don't know, but I guess that doubling the time to 131 mS would be sufficient. I can't imagine that the small neodymium magnets that I plan to use would be more effective than that.
Any suggestions would be welcome; sample code would be wonderful. I am using PicBasicPro 3 as the compiler, and I am very green with it.
Thanks.