+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 2
    Points: 517, Level: 4

    Join Date
    Jan 2010
    Posts
    2
    Helped
    0 / 0
    Points
    517
    Level
    4

    voltage level sent to a pin port on PIC18F

    Hi guys, I am currently working on a project. I am using a PICF18 microcontroller, in addition I am using mikroC Pro to code. I need a bit of help with the coding.....i want to be able to turn on/off a BJT that will be connected to one of my pin ports. How can I send the needed dc voltage level to this pin port?? I am going to be using a keypad (i already wrote this code), so I would just need a function that sends this needed voltage to the pin when the user wants to activate the switch (send 1.5 Vots) and a function that will deactivate the BJT(send 0 volts to the pin port). Any ideas??

    •   AltAdvertisement

        
       

  2. #2
    Member level 5
    Points: 1,856, Level: 10

    Join Date
    Mar 2006
    Location
    China
    Posts
    80
    Helped
    10 / 10
    Points
    1,856
    Level
    10

    voltage level sent to a pin port on PIC18F

    If you need to send a voltage different from VCC through io port, then you should need a da.
    I think there is one more simpler way to implent you function then using da.

    First, devide pin port output voltage, like this:



    •   AltAdvertisement

        
       

  3. #3
    Newbie level 2
    Points: 517, Level: 4

    Join Date
    Jan 2010
    Posts
    2
    Helped
    0 / 0
    Points
    517
    Level
    4

    Re: voltage level sent to a pin port on PIC18F

    I was thinking of doing that....I actually got the 5 volts that the PIC can supply....so i was thinking of just using voltage divider to get it to close to 1.5 V



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 81,755, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,410
    Helped
    4472 / 4472
    Points
    81,755
    Level
    69

    Re: voltage level sent to a pin port on PIC18F

    If you are driving the output pin high and low (writing to the pin without changing TRIS) you can omit R2 in most cases. The transistor will always hold about 0.65V between base and emitter so all you have to do is choose R1 so the current through it is adequate. Choose R1 with the formula (Vpin - 0.65) / Ib. You can decide Ib by dividing the BJT collector current by its Hfe parameter which is on the data sheet.

    For example, if the BJT collector current was 100mA and it's Hfe is 50, Ib would be (0.1/50) = 0.002A. If you assume the PIC pin is 5V when high, R1 would be (5-0.65)/.002 = 2175Ω. In practice you could use 2.2KΩ.

    Your values might be different but you have not specified the real BJT or load current.

    Brian.



--[[ ]]--