Detecting a pulse


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1


    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

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    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.

  3. #3
    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

  4. #4
    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

  5. #5


    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

  6. #6
    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!

  7. #7


    Did you find this post helpful? Yes | No

    Default haha

    @trimmers
    That definitely is a classic :-)
    So the initial code would have been something like
    Code:
    If water_level exist then 
    goto sack_gen_starter
    else goto use_PIC
    end if
    Thanks for the info

    Dennis

  8. #8
    Join Date
    Jan 2010
    Location
    PHILADELPHIA, PA - USA
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Other fun and useful stuff that might be added, with various levels of cost and complexity:
    • Log generator run time
    • Monitor / Alarm fuel level
    • Monitor /Alarm engine or generator winding temperatures
    • Count power outage events / Log power out time
    • Monitor output power or voltage and current demand
    • Auto start periodically to maintain bearings and equipment health...alarm if no start
    • etc ...

    This is what I love about the versatility of using PIC chips.
    Wozzy-2010

  9. #9


    Did you find this post helpful? Yes | No

    Default still searching...

    @WOZZY-2010 yes plenty that can be added.
    Hardest part would be getting a fuel top up :-)

    OK so still no replies regarding a simple IS PULSE EXISTS command ?
    I can easily detect zero-crossing but need to know how to check for th
    I was thinking of just checking for an absolute minimum pulse using PULSIN or use COUNT since AC has a 50% duty cycle and I would be checking a frequency of 50Hz or 60Hz but how do I set the period to be infinite ?
    Using this approach I could say something like WHILE COUNT_VAR > 1

    So here are the questions ?

    1. Can COUNT period be set to inifinity ?
    2. Can COUNT be set to a tight loop to count mains pulses so a variable always stays high so that I could say something like IF COUNT >1 THEN AC EXISTS ?
    3. If I used and interrupt on change for every zero-crossing could the interrupt be checked ..something like if interrupt exists then ... or if no interrupt exists then ...

    Any thoughts/ideas are welcome ?

    Kind regards

    Dennis

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


    Did you find this post helpful? Yes | No

    Default

    Again - I don't know what else your PIC must do at the same time, but PULSIN and COUNT are generally bad, since your code can do NOTHING ELSE during the count interval.

    If that is the case just do something like:

    Code:
      CLEAR
    
    Topp:
    
       IF  InputPin = 0 THEN
            Counter = 0
       ENDIF
    
       IF Counter > 2 then goto PowerGone   
       IF Counter < 254 THEN Counter = Counter + 1
       Pause 5
       Goto Topp
    
    
    PowerGone:
       HSEROUT ["Turn on the Generator"]
       Pause 10
       END
    Charles Linquist

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