Transistor Affecting Timings?


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    RossWaddell,

    Why don't you use a 16F or 18F PIC series with an internal oscillator. Also, you can drive the 4 LEDs from 4 different ports without transistors. Or with Vcc=5V you can even drive two LEDs per port without a resistor (the PIC has an internal resistance).

    You can also try the same timming experiment that you did above with a 16F or 18F PIC, using the internal oscillator, to see what happens.

    Robert
    Last edited by rsocor01; - 19th April 2012 at 15:01.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    I also thought last night about removing the transistor on the 2nd PIC to test the timings and lo and behold - it also goes out-of-sync after a minute or so. I would agree that the most likely explanation lies with the tolerance of the resonators.

    To clear up a few misconceptions: I'm not trying to link the two PICS/LEDs. I had used the first schematic to test out the timings (I videotaped the blinking to match the frame rates to my source movie) and was disappointed to see it different when hooked up to the transistor (which turns out to be not relevant). I hadn't accounted for the tolerance of the resonator so either I need to use these specific components when finalizing the circuit or provide a way to tweak the timings during runtime (reading a pot, for example).

    Some final questions (I hope):

    * Is there a better resonator/oscillator I should use which would be more accurate (higher tolerances)? I was using 20Mhz because I thought the 12f629's built-in 4Mhz wasn't sufficiently accurate. Henrik - you mention this in your post so if you know an oscillator component that would be better please let me know.

    * Gusse - I've thought about using the clock output of one PIC to be the input on other PICs but it never seems to work for me. Are saying I can dispense with the 20Mzh external resonator/oscillator, remove the define and just connect GP4 to CLKIN on the other PIC?

  3. #3
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Quote Originally Posted by RossWaddell View Post
    I've thought about using the clock output of one PIC to be the input on other PICs but it never seems to work for me. Are saying I can dispense with the 20Mzh external resonator/oscillator, remove the define and just connect GP4 to CLKIN on the other PIC?
    What is your realistic accuracy requirement and where does it come from?

    If LED blinking was just a trial circuit for your end application, then OK. But if your application will be LED blinking device, then I don't get why internal 4MHz OSC with +-1% tolearance would not be enough. +/-1% means max. 5ns/cycle deviation between two corner oscillators (every 50s, 1s time difference). OK, it is quite much, but everything is relative...

    20MHz +/-50ppm means +/-1kHz deviation => an error of 26 minutes per year. Is this OK?
    With VCTCXO you can have less than +/-1ppm stability.

    If you want to use GP4 as an output, then you need to use internal 4MHz OSC, GP4 is multiplexed to OSC2 so XTAL cannot be used.
    With external clock source you can use PIC in EC mode.
    Last edited by Gusse; - 20th April 2012 at 08:22.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Charlie - I'm not trying to lock the two PICs in phase. Please see my earlier post where I tried to clear that up:

    To clear up a few misconceptions: I'm not trying to link the two PICS/LEDs. I had used the first schematic to test out the timings (I videotaped the blinking to match the frame rates to my source movie) and was disappointed to see it different when hooked up to the transistor (which turns out to be not relevant). I hadn't accounted for the tolerance of the resonator so either I need to use these specific components when finalizing the circuit or provide a way to tweak the timings during runtime (reading a pot, for example).

  5. #5
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Quote Originally Posted by RossWaddell View Post
    Charlie - I'm not trying to lock the two PICs in phase. Please see my earlier post where I tried to clear that up:
    And yet you are using a phase difference to decide the frequency is wrong? Anyway, I'm not sure how to say it any differently. If you want both circuits to be EXACTLY the same, then they need to be locked to each other. If they are not locked to each other, they will NEVER be exactly the same.This is because even hand picked components, and PICs created on the same die will have tiny differences.
    Match everything to 0.0000000000000000000000000000000001 percent, (feel free to add more 0's) and they will still eventually drift apart.

  6. #6
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Is your request then that you want to have the on-time and off-time always the same? Meaning, you want 1_second to be 1_second on Design#1 and also 1_second on Design#2.

    Then you must get your reference clock as accurate as you need it (which is what has been mentioned before). This has nothing to do with locking oscillators or anything like that. You want watch#1 and watch#2 to always read the same, correct?

    So your task is to determine what does "always read the same" means. If you need them to always be the same , with not tweaks whatsoever, forever and ever then you need to phase lock them - but this is not realistic for watches and doesn't look like it is for your application either. You then need to determine how much drift you can tolerate. Drift will happen, and you have to determine how to deal with it. Watch manufacturers (sorry I keep using watches, but it is an easy timekeeping tool) allow you to "tweak" (adjust) the time for that reason.

    You can use a crystal for your reference and pay attention to the drift requirements. The higher the number the more it will drift. You could also look at an RTC to serve you as the "time-keeper". You still may need a means to "adjust/tweak" if you want them to start right-on.

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

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Robert - the 12f629 has an internal 4 Mhz oscillator calibrated to 1%. I'd prefer something more accurate hence the external oscillator.

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Maybe a 20 Mhz crystal oscillator with capacitors is the way to go?

    "Crystals provide accurate timing to within 50 parts per million (PPM)"

    If that's true, then that's better than a resonator with 0.5 % accuracy.

  10. #10
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Quote Originally Posted by RossWaddell View Post
    Maybe a 20 Mhz crystal oscillator with capacitors is the way to go?

    "Crystals provide accurate timing to within 50 parts per million (PPM)"

    If that's true, then that's better than a resonator with 0.5 % accuracy.
    Actually it is a 0.005% accuracy!!!!! Yes, the external oscillator might be the way to go.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  11. #11
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    If you are dealing with video and not HD video then you are dealing 29.94 frames per second, a rather low frequency. Two different crystals will never sync as each is producing a sine wave or modified square wave and the start of the pulse (leading edge) will change. You might be better off using the CCP1 and CCP2 outputs and the "HPWM" command if you are working with two different frequencies. Also, the LED in your drawing should be from the emmitter to ground, You can leave R-1 from +5v to the collector. The reasoning is that in an NPN transistor there is current flow from the base to the emmitter (notice which way the arrow points). Hope this helps. Ed

  12. #12
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Quote Originally Posted by RossWaddell View Post
    Maybe a 20 Mhz crystal oscillator with capacitors is the way to go?

    "Crystals provide accurate timing to within 50 parts per million (PPM)"

    If that's true, then that's better than a resonator with 0.5 % accuracy.
    To repeat my earlier post, you will NEVER get them to stay locked in phase using 2 different oscillators - this really is oscillators 101. You are simply wasting your time trying, it is not fundamentally possible. One needs a reference from the other, it's just that simple. There are many ways to do this, including the examples already given.

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