• AVR Freaks

Hot!how to calculate precise value for timer 0 on PIC16F630 with 4m crystal resonator

Author
oxygène
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2020/06/21 02:16:17
  • Location: 0
  • Status: offline
2020/10/19 05:20:45 (permalink)
0

how to calculate precise value for timer 0 on PIC16F630 with 4m crystal resonator

I'm trying to write a decoder for ev1527 remote controls and due to the RF modules in the market being extremely sensitive to noise and applying environment being extremely noisy I have to use timer 0 and a crystal resonator for delay before I clear the interrupt flag and make the device ready to capture the change on data input pin. Fortunately, the programming part is over but I need to know for sure what to use for required delay. There are 5 types of ev1527 remotes in the market with different data cycles: 1.34ms, 1.48ms, 1.71ms, 1.82ms and 2.035ms.
My question is:
1. Is the preamble low part equal to (cycle/4)*31? or is it cycle*31?
2. Is it possible to use TMR0 and 7 as option_reg (x256 prescaler) to have that long of a delay (assuming I have a remote with longest 2.035 cycle)? And how do I calculate the value for the timer.
Thanks in advance.

Attached Image(s)


Don't be AVR: Easy to program, unstable in harshness.
Be PIC: Hard to figure out, resistant to noise.
#1

3 Replies Related Threads

    dan1138
    Super Member
    • Total Posts : 3990
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: how to calculate precise value for timer 0 on PIC16F630 with 4m crystal resonator 2020/10/19 13:36:40 (permalink)
    +2 (2)
    The data sheets for the EV1527 do not describe the data pattern well in English.

    I believe you do not fully understand what the "EV1527 Rosc & data cycle" table describes.


    The modulated data is described in terms of time relative to the total time it takes to transmit one data packet.

    The modulation method use is called Carrier Wave Pulse modulation.

    This means that the RF is turned on for a time interval then off for a time interval.

    A data packet is make up of a (Preamble + 20-bits of code + 4-bits of key) this represents 32 "cells".

    Each "cell" is made up of four time intervals.

    The preamble is something of a special case.

    The preamble is made up of 8 "cells", the first "cell" is a data(L) "cell", for the next 7 "cells" the RF is kept off. There is no other modulation pattern like this in a valid data transmission.

    One possible method to decode this pattern would be:

    When looking for a start of packet:

       Measure the width of a received pulse.
       When a new pulse arrives after 31 times the measure pulse width this is the start of the data.


    When decoding the data:

       A one bit the RF is on for 3 times and off for 1 times the measured pulse width.
       A zero bit the RF is on for 1 times and off for 3 times the measured pulse width.
       There is 24 bits of data.

    I have not found it in the data sheets I have looked at but I suspect there is a delay between data packet transmissions equal to the time required to send a data packet.


    Some a parting comments:


    Using a PIC16F630 is an awful choice. This controller is very old and support for in circuit debug is very limited. Even finding the debug header is all but impossible now.


    The newer device programmers from Microchip (PICkit3, PICkit4, ICD3, ICD4, Snap) all have a tendency to loose the oscillator calibration settings when there is a problem programming the PIC16F630. The PICkit1 and PICkit2 can regenerate the calibration but these device programmers are obsolete and hard to find.


    So please consider how much trouble you want to go through to use a PIC16F630.
    post edited by dan1138 - 2020/10/19 18:05:36

    Attached Image(s)

    #2
    oxygène
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2020/06/21 02:16:17
    • Location: 0
    • Status: offline
    Re: how to calculate precise value for timer 0 on PIC16F630 with 4m crystal resonator 2020/10/20 00:09:19 (permalink)
    0
    Hi and thanks for the very well described and detailed answer.
    dan1138
    One possible method to decode this pattern would be:

    When looking for a start of packet:

       Measure the width of a received pulse.
       When a new pulse arrives after 31 times the measure pulse width this is the start of the data.


    When decoding the data:

       A one bit the RF is on for 3 times and off for 1 times the measured pulse width.
       A zero bit the RF is on for 1 times and off for 3 times the measured pulse width.
       There is 24 bits of data.

    I did, didn't work (I can share the code in case you're interested). The noise keeps causing interrupts even if I skip the preamble. How do I know that you may ask, well I wrote anther program just to capture the interrupts and store the timer value and I ended up having random numbers due to the noise, I even took one step further and made an ev1527 emulator send device but reduced the data cycle time (I guess it was around 0.1ms) and it worked flawlessly. So I decided to use an entirely different approach.
    dan1138
    Using a PIC16F630 is an awful choice. This controller is very old and support for in circuit debug is very limited. Even finding the debug header is all but impossible now.

    The newer device programmers from Microchip (PICkit3, PICkit4, ICD3, ICD4, Snap) all have a tendency to loose the oscillator calibration settings when there is a problem programming the PIC16F630. The PICkit1 and PICkit2 can regenerate the calibration but these device programmers are obsolete and hard to find.

    Consider it some sort of [rather difficult] training to improve my programming skills, I happen to have a PICKIT2 too (couldn't find the debug header though).
    post edited by oxygène - 2020/10/20 00:14:28

    Don't be AVR: Easy to program, unstable in harshness.
    Be PIC: Hard to figure out, resistant to noise.
    #3
    dan1138
    Super Member
    • Total Posts : 3990
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: how to calculate precise value for timer 0 on PIC16F630 with 4m crystal resonator 2020/10/20 01:05:35 (permalink)
    0
    Until your code can accurately detect the preamble I doubt you can get any good results.
     
    This is because everything will look like random noise.
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5