Transistor Affecting Timings?


Results 1 to 26 of 26

Threaded View

  1. #21
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Hi,

    If your goal is to have a LED flash at exactly timed intervals always and forever you could look into connecting your PIC to the AC lines in your house. Most countries have 50Hz (some has 60) and if you can detect the zero crossing you will have a 100 Hz reference signal that you can use for timing purposes.

    Then you can run the PIC on any kind of oscillator or x-tal since you only need to get the pic running on that clock source. For the LED flashing part you connect the 100Hz reference signal into a counter-input pin. If your counter is 8bit you then load it with with the value 155 and it will overflow 100 counts later to get the LED flash 1 sec on .. and 1 sec off. If you want it to be 0.1 sec on and 0.1 sec off you load 245 into the counter register.

    When you get the counter to overflow your interrupt service routine should reload the counter with the desired value (155 or 245) and toggle the LED. This way the LED is always toggled at really stable intervals and will not drift with time. If you have several similar circuits they will always keep in phase (flash at the same time) as long as they are started at the same time.

    The down side is: Main AC voltage is a potential killer and it will fry your circuit or you if you dont connect in a proper way. With a good circuit and enclosed in a plastic box it is usually ok but you need to understand the risks. With an OPTO coupler the risks are lower since most of your circuit will not be high voltage but if the only thing you want to do is flash a led then running the things from main AC should really be feasable. If you on the other hand want to connect a USB to your expensive PC or similar it is less of a great idea!

    The up side is that you get a really stable reference that will not drift with time or temperature and is indepedent of any clockspeed you use for running the PIC.

    The really good thing is that it is usually easy to find short circuits and bad designs, you only need to look for glowing parts and follow the smoke signals.

    Or you can get a off-the-shelf 220V to 5V AC power supply...
    Last edited by Jumper; - 21st April 2012 at 05:09.

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