Loading ...
Sorry, an error occurred while loading the content.

Re: Jdelay - timing question

Expand Messages
  • picclock
    Hi Vasile One cycle dropout (alternance - that famous language barrier again :~) would lose one count per week or 1 second a year. But generally that doesn t
    Message 1 of 13 , Aug 1, 2005
    • 0 Attachment
      Hi Vasile

      One cycle dropout (alternance - that famous language barrier again :~)
      would lose one count per week or 1 second a year.

      But generally that doesn't seem to happen over here - certainly not
      in my part of Surrey where I live.

      I have a digital radio alarm which gets its timing from the mains
      frequency. It has a backup battery that allows it to keep approximate
      time during a mains failure. Over the last 4 years there have been
      two mains failures, the worst one where a tree fell onto the local
      subtstation and the power was out for 2 1/2 hours. I have never
      corrected the clock time since I bought it around 4 years ago,
      although I have altered the hour for british 'summertime' (a misnomer
      if ever I heard one).

      So I guess it works - there may be missing cycles but we don't seem
      to get brownouts or flickering which seems to happen on a daily basis
      stateside.

      Designing a system that will generate the appropriate timing if mains
      failure occurs or a pulse doen't arrive on time seems a fairly simple
      task to me - perhaps there are other requirements you have that I'm
      not aware of.

      Best Regards

      Martin R Dare




      --- In jallist@yahoogroups.com, "Vasile Surducan" <vasile@s...> wrote:
      > Hi Martin,
      >
      > Maybe you understand me wrong, I wasn't talking about frequency
      > variatin but about missing alternances. The frequency could be as
      > stable as 0.4% but if you catch once per week a missing alternance
      > right on the frequency measurement moment, how do you restore the
      > right time in your clock (assuming you haven't a radio sincronised
      > clock) ?
      >
      > Please don't tell me that in England there is no missing
      alternances
      > on the mains... :) only someone who never worked in an electric
      > plant may say such thing.
      >
      > cheers,
      > Vasile
      >
      >
      > --- In jallist@yahoogroups.com, "picclock" <mdare@d...> wrote:
      > > Hi Vasile
      > >
      > > Short term frequency variation can be as much as 0.4% for
      > conditions
      > > of heavy load, but the average frequency is corrected by the
      > > suppliers. Over a 24 Hour period this is corrected to an
      extremely
      > > accurate figure.
      > >
      > > A lot of synchronous clocks rely on mains frequency for their
      > > accuracy, so I think it must be a lot better than 1 second a day.
      > >
      > > Not all countries in Europe have such high standards, so this is
      a
      > UK
      > > only spec.
      > >
      > > Best Regards
      > >
      > > Martin R Dare
      > >
      > > PS Malcolm, if you use this technique don't forget to put a 50 Hz
      > low
      > > pass filter (RC) on the comparator input to prevent line noise
      > > causing an inaccurate count.
      > >
      > >
      > > --- In jallist@yahoogroups.com, "Vasile Surducan" <vasile@s...>
      > wrote:
      > > > --- In jallist@yahoogroups.com, "picclock" <mdare@d...> wrote:
      > > > > Hi Malcolm
      > > > >
      > > > > Lots of sources of error here. I assume that your using the
      > > > internal
      > > > > osc on the 12f675. This uses a register called Oscal to set
      > the
      > > > > frequency. The factory preprogrammed value is easily
      > overwritten
      > > > > during programming, although it can be set using clkout and a
      > > > > frequency counter on the appropriate pin. Also the std
      > variation
      > > on
      > > > > frequency for this part is 2 1/2% which isn't all that great
      > if
      > > you
      > > > > want any sort of accuracy.
      > > > >
      > > > > IMHO The best bet is to use an external xtal which will give
      > much
      > > > > higher accuracy, or, if mains ac is available from a
      > transformer
      > > > use
      > > > > the mains frequency to do the timing. This is extremely
      > accurate
      > > > even
      > > > > over weeks (months - years even !).
      > > >
      > > > Hi Martin,
      > > >
      > > > How many missing alternances can you number on the english
      mains
      > in
      > > > one year ?
      > > >
      > > > cheers,
      > > > Vasile
      > > >
      > > >
      > > > >
      > > > > If your happy to muck about and its not critical just adjust
      > > OSCal
      > > > to
      > > > > get it close. To set it up just toggle the lights every 5
      secs
      > > and
      > > > > check it against a watch. Then alter the Oscal value and
      > repeat
      > > as
      > > > > necessary.
      > > > >
      > > > > Other alternative is to run at a lowr clock speed and use an
      > > > external
      > > > > RC network with a pot in part of the R bit.
      > > > >
      > > > > My personal experience is that he accuracy of intosc sucks
      > > despite
      > > > > what the data sheets say. Mabye there are good ones and I
      only
      > > got
      > > > > mediochre ones.
      > > > >
      > > > > Good luck with your project
      > > > >
      > > > > Best Regards
      > > > >
      > > > > Martin R Dare
      > > > >
      > > > >
      > > > >
      > > > >
      > > > > --- In jallist@yahoogroups.com, Malcolm <malcolm.crabbe@n...>
      > > wrote:
      > > > > > I'm trying to use a 12F675 for a simple timer to turn a set
      > of
      > > > > lights on
      > > > > > on power up and off at set times. The first stage is to
      get
      > > the
      > > > > pin to
      > > > > > turn off after a set delay, simple enough program:
      > > > > >
      > > > > > include f675_4i
      > > > > > include jlib
      > > > > >
      > > > > > pin_a0_direction = output
      > > > > > pin_a1_direction = input
      > > > > > pin_a2_direction = input
      > > > > > pin_a3_direction = input
      > > > > > pin_a4_direction = input
      > > > > > pin_a5_direction = input
      > > > > >
      > > > > > var bit LED is pin_a0
      > > > > > LED = high
      > > > > > delay_5S ( 120 )
      > > > > > LED = low
      > > > > >
      > > > > > However the using the above delay settings the pin was
      > turned
      > > low
      > > > > in
      > > > > > less than the 10 mins the calculation works out to be, and
      > as
      > > it
      > > > > lost
      > > > > > around 70 seconds for a delay of 10 mins this will be no
      > good
      > > > over
      > > > > the
      > > > > > longer periods I want to use.. I read the manual that
      using
      > a
      > > > > smaller
      > > > > > delay cycle (ms or uS) will give better accuracy, but I'm
      > not
      > > > sure
      > > > > that
      > > > > > on the multiplier to give timings of 30mins, 1 hour, 1.5
      hrs
      > > and
      > > > 2
      > > > > hrs
      > > > > > (which will be selectable in the final program depending on
      > > which
      > > > > inputs
      > > > > > are set).
      > > > > >
      > > > > > Can anyone provide the most accurate delay code that can
      > > replace
      > > > > the
      > > > > > delay_5S ( 120 ) in the above program
      > > > > >
      > > > > > Thanks
      > > > > >
      > > > > > Malcolm
    • picclock
      Hi Malcolm I suspect a lot of this will not be of group interest, but you could write up the project and put it in the files section afterward. I will Mail
      Message 2 of 13 , Aug 1, 2005
      • 0 Attachment
        Hi Malcolm

        I suspect a lot of this will not be of group interest, but you could
        write up the project and put it in the files section afterward.

        I will Mail you.

        Best Regards

        Martin R Dare

        --- In jallist@yahoogroups.com, Malcolm <malcolm.crabbe@n...> wrote:
        > Hi Martin,
        >
        > Yes you are correct. I've purchased a set of cold cathode tubes
        that I
        > use for night time illumination of an aquarium. Basically in a
        > nutshell, I want these lights to come on when the main lights go
        off (I
        > use a standard plug in timer) and then run for a set period before
        > switching off.
        >
        > I'm proposing to use a 240 volt ac relay to activate the PIC so
        that
        > when the main lights are switched off, the relay is de-energised
        and the
        > contacts close allowing 12v to be fed to the PIC from a separate
        12v
        > plug in adaptor. The pic will then run for a set time depending on
        what
        > input has been made high via a rotary switch, then switch off the
        light
        > when the period has elapsed. Obviously the cct will contain the
        > discrete components to drop the supply voltage to 5v and
        transistors to
        > switch the 12v to the inverter.
        >
        > Martin, I would really like some assistance as offered. Maybe we
        should
        > continue this via e-mail off list ??
        >
        > Thanks
        >
        >
        > Malcolm
        >
        > picclock wrote:
        >
        > > Hi Malcolm
        > >
        > > Are you just using the pic to turn lights on and off ?
        > >
        > > If so, IMHO best option is to use a 32768Hz watch/clock xtal. If
        you
        > > then set timer0 to use a prescale value of 32 the tmr0 overflow
        flag
        > > will be set every second. You can then just count and clear the
        flag
        > > when timer0 overflows.
        > >
        > > This will give fairly good accuacy, probably better than
        30secs/month.
        > >
        > > You can do this using a higher frequency xtal but because the
        timer
        > > will need to be loaded with a value the accuracy will suffer. You
        can
        > > probably get a xtal from a scrap motherboard.
        > >
        > > If you want to go that way I will be happy to show you how to set
        up
        > > the timer registers.
        > >
        > > Best Regards
        > >
        > > Martin R Dare
        > >
        > >
        > >
        > >
        > >
        > > --- In jallist@yahoogroups.com, Malcolm <malcolm.crabbe@n...>
        wrote:
        > > > Thanks guys for all your input. Accuracy doesn't have to be
        spot
        > > on to
        > > > the second, which was why I used the internal osc on the PIC.
        The
        > > > supply is via a 12v power adaptor, so I don't have mains AC
        levels
        > > so
        > > > using the 50htz frequency as a time reference is also out.
        > > >
        > > > I do however have 4 and 6 Mhz xtals, but I've never written Jal
        > > code to
        > > > use this as a reference. (my JAL is still at the "lets flash an
        > > LED"
        > > > stage :-) ) anyone able to advise what I need to do ( I'm
        > > programming
        > > > via a Microchip PICKit1 if that's any help)
        > > >
        > > > Thanks
        > > >
        > > > Malcolm
        > > >
        > > > picclock wrote:
        > > >
        > > > > Hi Vasile
        > > > >
        > > > > Short term frequency variation can be as much as 0.4% for
        > > conditions
        > > > > of heavy load, but the average frequency is corrected by the
        > > > > suppliers. Over a 24 Hour period this is corrected to an
        extremely
        > > > > accurate figure.
        > > > >
        > > > > A lot of synchronous clocks rely on mains frequency for their
        > > > > accuracy, so I think it must be a lot better than 1 second a
        day.
        > > > >
        > > > > Not all countries in Europe have such high standards, so this
        is
        > > a UK
        > > > > only spec.
        > > > >
        > > > > Best Regards
        > > > >
        > > > > Martin R Dare
        > > > >
        > > > > PS Malcolm, if you use this technique don't forget to put a
        50 Hz
        > > low
        > > > > pass filter (RC) on the comparator input to prevent line noise
        > > > > causing an inaccurate count.
        > > > >
        > > > >
        > > > > --- In jallist@yahoogroups.com, "Vasile Surducan"
        <vasile@s...>
        > > wrote:
        > > > > > --- In jallist@yahoogroups.com, "picclock" <mdare@d...>
        wrote:
        > > > > > > Hi Malcolm
        > > > > > >
        > > > > > > Lots of sources of error here. I assume that your using
        the
        > > > > > internal
        > > > > > > osc on the 12f675. This uses a register called Oscal to
        set
        > > the
        > > > > > > frequency. The factory preprogrammed value is easily
        > > overwritten
        > > > > > > during programming, although it can be set using clkout
        and a
        > > > > > > frequency counter on the appropriate pin. Also the std
        > > variation
        > > > > on
        > > > > > > frequency for this part is 2 1/2% which isn't all that
        great
        > > if
        > > > > you
        > > > > > > want any sort of accuracy.
        > > > > > >
        > > > > > > IMHO The best bet is to use an external xtal which will
        give
        > > much
        > > > > > > higher accuracy, or, if mains ac is available from a
        > > transformer
        > > > > > use
        > > > > > > the mains frequency to do the timing. This is extremely
        > > accurate
        > > > > > even
        > > > > > > over weeks (months - years even !).
        > > > > >
        > > > > > Hi Martin,
        > > > > >
        > > > > > How many missing alternances can you number on the english
        > > mains in
        > > > > > one year ?
        > > > > >
        > > > > > cheers,
        > > > > > Vasile
        > > > > >
        > > > > >
        > > > > > >
        > > > > > > If your happy to muck about and its not critical just
        adjust
        > > > > OSCal
        > > > > > to
        > > > > > > get it close. To set it up just toggle the lights every 5
        secs
        > > > > and
        > > > > > > check it against a watch. Then alter the Oscal value and
        > > repeat
        > > > > as
        > > > > > > necessary.
        > > > > > >
        > > > > > > Other alternative is to run at a lowr clock speed and use
        an
        > > > > > external
        > > > > > > RC network with a pot in part of the R bit.
        > > > > > >
        > > > > > > My personal experience is that he accuracy of intosc sucks
        > > > > despite
        > > > > > > what the data sheets say. Mabye there are good ones and I
        only
        > > > > got
        > > > > > > mediochre ones.
        > > > > > >
        > > > > > > Good luck with your project
        > > > > > >
        > > > > > > Best Regards
        > > > > > >
        > > > > > > Martin R Dare
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > --- In jallist@yahoogroups.com, Malcolm
        <malcolm.crabbe@n...>
        > > > > wrote:
        > > > > > > > I'm trying to use a 12F675 for a simple timer to turn a
        set
        > > of
        > > > > > > lights on
        > > > > > > > on power up and off at set times. The first stage is
        to get
        > > > > the
        > > > > > > pin to
        > > > > > > > turn off after a set delay, simple enough program:
        > > > > > > >
        > > > > > > > include f675_4i
        > > > > > > > include jlib
        > > > > > > >
        > > > > > > > pin_a0_direction = output
        > > > > > > > pin_a1_direction = input
        > > > > > > > pin_a2_direction = input
        > > > > > > > pin_a3_direction = input
        > > > > > > > pin_a4_direction = input
        > > > > > > > pin_a5_direction = input
        > > > > > > >
        > > > > > > > var bit LED is pin_a0
        > > > > > > > LED = high
        > > > > > > > delay_5S ( 120 )
        > > > > > > > LED = low
        > > > > > > >
        > > > > > > > However the using the above delay settings the pin was
        > > turned
        > > > > low
        > > > > > > in
        > > > > > > > less than the 10 mins the calculation works out to be,
        and
        > > as
        > > > > it
        > > > > > > lost
        > > > > > > > around 70 seconds for a delay of 10 mins this will be no
        > > good
        > > > > > over
        > > > > > > the
        > > > > > > > longer periods I want to use.. I read the manual that
        > > using a
        > > > > > > smaller
        > > > > > > > delay cycle (ms or uS) will give better accuracy, but
        I'm
        > > not
        > > > > > sure
        > > > > > > that
        > > > > > > > on the multiplier to give timings of 30mins, 1 hour,
        1.5 hrs
        > > > > and
        > > > > > 2
        > > > > > > hrs
        > > > > > > > (which will be selectable in the final program
        depending on
        > > > > which
        > > > > > > inputs
        > > > > > > > are set).
        > > > > > > >
        > > > > > > > Can anyone provide the most accurate delay code that can
        > > > > replace
        > > > > > > the
        > > > > > > > delay_5S ( 120 ) in the above program
        > > > > > > >
        > > > > > > > Thanks
        > > > > > > >
        > > > > > > > Malcolm
        > > > >
        > > > >
        > > > >
        > > > >
        > > > > --------------------------------------------------------------
        ----
        > > ------
        > > > > YAHOO! GROUPS LINKS
        > > > >
        > > > > * Visit your group "jallist
        > > > > <http://groups.yahoo.com/group/jallist>" on the web.
        > > > >
        > > > > * To unsubscribe from this group, send an email to:
        > > > > jallist-unsubscribe@yahoogroups.com
        > > > > <mailto:jallist-unsubscribe@yahoogroups.com?
        > > subject=Unsubscribe>
        > > > >
        > > > > * Your use of Yahoo! Groups is subject to the Yahoo!
        Terms of
        > > > > Service <http://docs.yahoo.com/info/terms/>.
        > > > >
        > > > >
        > > > > --------------------------------------------------------------
        ----
        > > ------
        > > > >
        > >
        > >
        > >
        > > ------------------------------------------------------------------
        ------
        > > YAHOO! GROUPS LINKS
        > >
        > > * Visit your group "jallist
        > > <http://groups.yahoo.com/group/jallist>" on the web.
        > >
        > > * To unsubscribe from this group, send an email to:
        > > jallist-unsubscribe@yahoogroups.com
        > > <mailto:jallist-unsubscribe@yahoogroups.com?
        subject=Unsubscribe>
        > >
        > > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
        > > Service <http://docs.yahoo.com/info/terms/>.
        > >
        > >
        > > ------------------------------------------------------------------
        ------
        > >
      • Eur van Andel
        ... You can use TMR1 with an external 32 kHz xtal and still have a speedy program with an internal osc of 4 MHZ. It will overflow in 2^16/32000 =2.048 seconds
        Message 3 of 13 , Aug 8, 2005
        • 0 Attachment
          On Sun, 31 Jul 2005 22:31:11 -0000, you wrote:

          >If so, IMHO best option is to use a 32768Hz watch/clock xtal. If you
          >then set timer0 to use a prescale value of 32 the tmr0 overflow flag
          >will be set every second. You can then just count and clear the flag
          >when timer0 overflows.
          You can use TMR1 with an external 32 kHz xtal and still have a speedy
          program with an internal osc of 4 MHZ. It will overflow in 2^16/32000
          =2.048 seconds * 255 = 8.7 minutes. For 10 mins, you'll need a 16 bit
          timer, like:

          if PIR1_TMR1IF then
          counter_low = counter_low + 1
          if counter_low == 0 then
          counter_high = counter_high +1
          end if
          end if
          end if

          if counter_low == 37 then
          if counter_high = 1 then -- 256 + 37 = 293 = 10* 60 / 2.048
          blink_led_in_some_way
          end if
          end if



          Yes, I do have the datasheet of the 12F675 here :-)
          My wife locked me up for two weeks in this cottage in France, so I
          took some work along. What better literature than PIC datasheets on
          your holiday?

          Eur van Andel eur@...
          from my laptop, somewhere in France, by GPRS
        • Malcolm
          Guys, You may remember that I was trying to develop a timer to automatically turn on a set of night lights for a set period of time after the main lights were
          Message 4 of 13 , Aug 10, 2005
          • 0 Attachment
            Guys,

            You may remember that I was trying to develop a timer to automatically
            turn on a set of night lights for a set period of time after the main
            lights were switched off. Martin Dare offered to help me as my
            knowledge of programming and Jal was a tad limited.

            Well I'm please to say that after a steep development curve, I now have
            a working cct on my breadboard that not only runs for one or two hours
            depending on the setting of a switch, it uses a light dependant resistor
            to detect if the main lights are on or off, so there is no risk to me or
            the fish by using a 240v ac relay like I intended !

            I'm now going to develop a PCB and hopefully in a few days build the
            first prototype. *However I would really like to take this opportunity
            to say a big public thank you to Martin for all his help and guidance
            with this project*. Whilst I still don't understand the full process of
            using the pre-scaller etc, I have learnt a lot about the logic (and the
            quirkiness ) of JAL :-)

            Regards

            Malcolm
          Your message has been successfully submitted and would be delivered to recipients shortly.