Menu

RPM measure with CCP1

Help
Capaction
2009-11-28
2013-05-30
  • Capaction

    Capaction - 2009-11-28

    We want to measure from 200 RPM up to 6000RPM.
    We have a PIC16f628 and a hall sensor on CCP1 pin.

    Of course we want fewer CCP interrupts & noise immunity

    How can we determine the best values for Timer1 prescaler and for the CCP1CON.
    Thank you

     
  • Alistair George

    Alistair George - 2009-11-28

    Actually, I'm in a similar boat:
    Am using the 32khz T1 internal xtal offered with some Microchip PIC types. I figure (maybe wrong) but the internal xtal will afford me good stability at lower cost. This oscillator is div 4=8192Hz
    My calculation for offset is wrong. I'm trying to achieve a 1 second interrupt, setting value T1 for the main loop. When there is a T1 interrupt, the interrupt contains the following correction code:

        sub clockevent
        'default timeout 8192cps/ (0.0001220703125*FFFF)=7.9998779296875
        '0000/on rollover this is the default value; higher =shorter timeout 'calc=65535-8192=0xDFFF
        '0xDFFF+4=0xe0ff allows for 4 cycles calling IRQ and changing offset
        TMR1=0x0
        TMR1H = 0xe0 '0xDF
        TMR1L = 0x03 '0xFF
        T1=1
        end sub

    However the timing over a few hours is out by about 25%. Can anyone advise where I am going wrong?
    Tks vm.
    Al.

     
  • Alistair George

    Alistair George - 2009-11-28

    Im hoping that my previous reply will give you some help in determining a good stable clock source. You do not need to use the prescaler using the internal xtal, just add the TMR1 values **note the higher TMR1 val, the shorter the interrupt timeout.** For example, using the default TMR1 value of 0000 interrupts will occur every 8 seconds

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.