Detecting a pulse


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1

    Default Detecting a pulse

    Hi all

    Because of the amount of power failures in our area , I am building a circuit to auto-switch my generator because it's quite a mission getting up at 2am sometimes to go and switch it on when there is a power failure.

    I plan to use an opto-isolator initially to detect the power failure however some form of zero-crossing detection may also be a consideration.

    This of course raises a good few (maybe silly for some) questions:
    1.Which would most accurately detect the pulses ? PULSIN or COUNT? are there other methods?
    2.Using either of these does the incoming pulse have to be a known value or can on just check to see if a pulse (ofany/unknown size) exists ?
    3.Have I chosen the correct RTC (DS1302) for the job ?

    I have been searching the forum for the last few days but haven't qyet found the right example.

    I really would appreciate some advice or guidance on how to detect the pulse and absence of a pulse just to get me started.


    Kind regards

    Dennis

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Use a rectifier (1N4004) and a 10K 2W resistor in series with the LED side of an optoisolator. Put another rectifier across the LED in the reverse direction to protect it against reverse voltage. Connect these across the power line. Put a 10K resistor on the collector of the phototransistor to 5V. The output will be an isolated 50 or 60 Hz square wave.

    I would use an interrupt to "watch" this, so your PIC could do other things while watching the power line. Of course the output of the phototransistor will only be LOW for each half-cycle, so if you sampled the phototransistor every 5 ms or so, and it never went low, it would be an idication that the power was "gone'. Note that the rising and falling edges of the square wave will be very close to the zero-crossings of the power line.
    Charles Linquist

  3. #3
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    OK, I gotta be curious... is the whole purpose of this *just* to start a generator?
    Do you really need to detect zero crossing and all that?

    How about just stepping down the voltage (little transformer), rectifying and putting a small filter cap on the output. Feed it to a PIC pin. If the pin is high... got power. If the pin is low... no power. Poll the pin about once a second should be fine for starting a generator, eh?
    Seriously. How quickly do you need to get a generator running? How quickly will it even start? It seems a few seconds delay without power is inevitable if you gotta start an engine.

    Of course maybe you have other ideas for this that need the zero crossing anyway?
    Just curious...

    Heck, I still gotta go out in the rain and put a hand crank on mine to start it.


    steve


  4. #4


    Did you find this post helpful? Yes | No

    Default Awesome suggestion :-)

    @Steve :-)

    That's some Geni , what's the output ? Can't be fun switching it on at 2AM :-)
    Mine has electric start :-) will try get a pic up this week for you :-)

    Great idea !

    I suppose component count and power draw are two reasons why I would go with the sensor.
    Searching the forum for lamp-dimmer and mains detect shows huge amounts of info for this kind of thing.
    As per quite a few app notes and posts I have seen, a single resistor can be used from LIVE and directly into a PIC pin as a zero-crossing sensor.
    OR you can use the opto-isolator.
    All that remains then is to check that you are getting a pulse on the pin.
    I would like to try the opto-isolator option first but am unsure as to whether to use PULSIN or COUNT (or another method) to check the pulse and what that little line of code should look like.

    Kind regards

    Dennis

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    I humbly beg to differ here. Why do you even need a PIC to do this? A simple mains rectifier output indicates power present. Similarly, when the power fails, the reservoir capacitor will hold the voltage a little while before indicating mains failure(takes care of short power glitches if you get them)
    Sizing this value appropriately can give you some delay before you command the generator to switch on.

    In short, mains adaptor -> transistor inverter -> relay is all that is needed to achieve this.

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Or an AC relay plugged into an outlet!
    Charles Linquist

  7. #7
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dennis View Post
    @Steve :-)
    That's some Geni , what's the output ? Can't be fun switching it on at 2AM :-)
    6HP @ 650RPM. Aprox 4KW max output and it'll run on just about any flammable liquid you've got.


    Mine has electric start :-)
    Yeah, I've heard about guys like you.

    Maybe electric start for me someday. I've got enough tools and steel to build something for it, but it ain't real high on the priority list.

    I don't start it much at 2AM though...
    I start at when I get up and kill it when I sleep.
    I have enough 12 volt lighting (and big batteries) to get me through the night, and I can always fire up the 1KW inverter if I really need AC at night.


    I'd be scared to do any data logging here and find out how many days a year our power is really out.

    steve

  8. #8


    Did you find this post helpful? Yes | No

    Default still digginig ...

    @Steve .. at least you have the geni for those outages :-)

    @ any and everyone ... is there really no simple command like
    IF PULSE EXIST THEN ... ?

    Kind regards

    Dennis

  9. #9
    timmers's Avatar
    timmers Guest


    Did you find this post helpful? Yes | No

    Default

    When I worked in Nigeria a few years ago, we employed somebody to start the generator and switch over from utility supply to generator supply. Worked fine, no getting up at 2am like some!

    -trouble started when we bought a new generator. We instructed our gen-starter how to check the oil and and where to dip his finger to check the water (couldn't see the level due to the soundproof case).
    When we came home later that day, he was busy pouring water into the generator from a watering can. after his second refill I became curious as to why the generator was needing so much water, and there on the top of the case, was the oil filler cap as another 2 gallons disappeared down to the depths of our brand new generator. When I pulled the dipstick out, a spout of water flowed.

    After that episode I sacked the gen-starter and I built a PIC based auto starter, which would check the incoming 3 phase for over volts (occaisionaly), under volts (often), one or all phases missing (very common) and then switch over as required. It had a variable brown out facility to prevent reccuring start / stop and control of other variables like cranking time out and cool down runs. It even switched the contactor from utility to local automatically. It used 3x opto couplers to monitor the 3 phases and 3 relays for run, glow & crank.

    Worked a treat!

  10. #10


    Did you find this post helpful? Yes | No

    Default OK...

    It seems a sentence was left out of my posting!

    I wish to log the power failure durations, times and dates as well and that's why I would like to use a PIC as well an an RTC.
    The PIC cirucit would either form part of an existing circuit or be battery/solar powered and have little or no draw on my home circuit.

    Kind regards
    Dennis

    Quote Originally Posted by Dennis View Post
    Hi all

    Because of the amount of power failures in our area , I am building a circuit to auto-switch my generator because it's quite a mission getting up at 2am sometimes to go and switch it on when there is a power failure.

    I plan to use an opto-isolator initially to detect the power failure however some form of zero-crossing detection may also be a consideration.

    This of course raises a good few (maybe silly for some) questions:
    1.Which would most accurately detect the pulses ? PULSIN or COUNT? are there other methods?
    2.Using either of these does the incoming pulse have to be a known value or can on just check to see if a pulse (of any/unknown size) exists ?
    3.Have I chosen the correct RTC (DS1302) for the job ?

    I have been searching the forum for the last few days but haven't yet found the right example.

    I really would appreciate some advice or guidance on how to detect the pulse and absence of a pulse just to get me started.


    Kind regards

    Dennis

  11. #11
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Aha!
    I figured there must be more to it than just getting the beastie running at 2AM.

    Data logging is a good use for a PIC.

    Just detecting lack of AC power to start a motor is not.

    steve

Similar Threads

  1. Pulse Capture and byte building
    By boroko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st July 2009, 01:59
  2. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  3. How to reverse polarity on output pulse??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th June 2009, 13:25
  4. Replies: 3
    Last Post: - 13th September 2008, 17:40
  5. Pulse Frequency Multiplication
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st August 2005, 10:39

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts