Transistor Affecting Timings?


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1

    Default Transistor Affecting Timings?

    I need to set precise on/off timings for a blinking LED and I was surprised to see that when I switched to a 2N2222 transistor (with a 10k resistor between the GPIO.0 output and Base) in order to drive 4 LEDs that the overall on/off rate changed (it appears longer). I'm using a 20Mhz oscillator to get the best resolution possible, so am I doing something wrong? If I want a precise duty cycle is the only way by trial and error?

    Code:
    DEFINE OSC 20
     
    @ DEVICE pic12F629, HS_OSC
    @ DEVICE pic12F629, WDT_ON
    @ DEVICE pic12F629, PWRT_ON
    @ DEVICE pic12F629, MCLR_OFF
    @ DEVICE pic12F629, BOD_ON
    @ DEVICE pic12F629, PROTECT_OFF
    @ DEVICE pic12F629, CPD_OFF
     
    CMCON    = 7         'Turn off comparators
    TRISIO.0 = 0         'Make GPIO.0 pin output
     
    LED_0 VAR GPIO.0       ' Alias GPIO.0 to LED
    DUTY VAR BYTE
    CYCLE VAR BYTE
    STEP_CNTR var byte
     
    LGHTS_ON_MS CON 1410 '36 frames given the oscilattor accuracy
    LGHTS_OFF_MS CON 550 '12 frames given the oscilattor accuracy
     
    Cycle = 1
    STEP_CNTR = 2
     
    lblLoop:
       ' Fade in
       For Duty = 0 TO 255 step STEP_CNTR
             PWM LED_0, Duty, Cycle
       Next
     
        ' Stay on LGHTS_ON_MS
        High LED_0
       Pause LGHTS_ON_MS
     
        ' Fade out
       For Duty = 255 TO 0 STEP -STEP_CNTR
             PWM LED_0, Duty, Cycle
       Next
      
       ' Stay off for LGHTS_OFF_MS
        Pause LGHTS_OFF_MS
     
       GoTo lblLoop
     
    End
    Also, I'm using PWM to fade in/out the LED to give the appearance of incandescents - does that even work with a 2N2222 transistor?

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


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    I can only assist with the transistor itself which is good to 250 MHZ so at 20 MHZ is well within its frequency limits. If timimg is a concern you may wish to go with the faster 2N2222A. You might also wish to go with a 4.7K, and then consider creating a darlington configuration (collectorof transistor 1 to collector of transistor 2, emitter of transistor 1 to the base of transistor 2, base of transistor 1 to the resistor to the PIC and the emitter of transistor 2 to your LED's). My first guess is that your are not turning the transistor on hard enough. Best, Ed

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    I think I'm already using a 2N2222A - the writing on the casing says, "MPS2222A". I'll try with a 4.7k first and then look into the Darlington configuration (I assume you're talking about two (2) 2N2222A's, right?)

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Neither replacing the 10k resistor with a 4.7k nor a darlington pair (your connections didn't work for me; this did, though) helped - after about 1.5 minutes they are out of sync.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Out of SYNC?.....
    Dave Purola,
    N8NTA
    EN82fn

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


    Did you find this post helpful? Yes | No

    Default Re: Transistor Affecting Timings?

    Not sure what "out of sync" means either. I doubt the transistors are causing much of a problem and the original idea/suggestion was to ensure that the transistors were driven hard enough to light the LED's. A schmatic/drawing would help if possible. Just an idea, maybe using "HPWM" to set your frequency might help? Perhaps even a combination of "HPWM" and "pause"? Yes I was talking about using 2 transistors. My guess is that you are placing your LED's on the emitter side of the transistors and not the collector?

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