Shop OBEX P1 Docs P2 Docs Learn Events
Having trouble getting PWM transistor voltage up to 5 V? — Parallax Forums

Having trouble getting PWM transistor voltage up to 5 V?

HarrisracingHarrisracing Posts: 10
edited 2011-08-02 14:19 in Propeller 1
First of all - I am a mechanical engineer, not electrical, so forgive my ignorance on transistors, but I'm learning and getting closer every day.

I am reading a Pot + Resistor + Capacitor loop on one pin with RC Time with great results. I am then using these results to run another COG that sends a Pulse-Width-Modulated signal out of another pin. When I measure voltage out of this pin I get a VERY nice, smooth and steady voltage signal out of it with a smooth sweep from 0 - 3.3V as I adjust the POT.

Since I need this output to go to 5V, I used the 5V power from my Professional Development Board and wired it to a 2N2904 NPN Transistor. I am running the 0 - 3.3V PWM output to the BASE and the 5V to ground (or through LED for testing) across the COLLECTOR / EMITTER legs. I am getting solid 5V to the one leg, but as I move the BASE from 0-3.3V (checked there too), the output is only going 0 - 2.71V

I have tried replacing the NPN transistor with different transistors and even a Darlington transistor all with the same results.

What am I doing wrong?
How can I get 5V out of this transistor?

Thank You,
Patrick

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-08-02 11:25
    By your description it seems you're attempting an emitter follower. Its output will always be a diode drop less than the base voltage: 3.3V - 0.7V = 2.6V
  • HarrisracingHarrisracing Posts: 10
    edited 2011-08-02 11:43
    So, would using an OP-AMP in a non-inverting amplifier do the trick? Here is the wikipedia example: http://en.wikipedia.org/wiki/File:Op-Amp_Non-Inverting_Amplifier.svg

    All I'd have to do is set my R1 and R2 values according to the equation to end up with my 0-5V output...right?

    So in this case, I have 2.66V and want to get up to 5V I can use Resistor values of R1 = 4.3k and R2 = 4.7k. ???

    Patrick
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-08-02 12:21
    What to do depends a lot on what you need to do with it.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2011-08-02 13:23
    Try one of these Non-Inverting level shifters.

    3.3V_to_5V_Level-shifter.png

    Duane
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-02 13:31
    oops while I was writing my posting Duane has posted exact the circuit I described in words.

    as soon as a current flows there will be a voltage-drop across resistors.

    If you tie the emitter to ground and put a resistor between +5V and collector the voltage can vary from 5V - voltage drop
    (caused by the current towards the input you want to feed the 0V-5V signal in) at dutycycle 0% on

    to almost 0V if dutycycle is 100% on. Output always on means transistor is conductant and almost of the 5V drops over the resistor between 5V and collector.

    The analog voltage is inverted. 0%-Dutycycle means 5V 100% dutycycle means 0V

    I measured this on my PPDB with a transistor BC238 which is a 200mA general purpose transistor similar to a 2N2904

    For a stable analog voltage you need a RC-DAC circuit anyway. Depending on the load and the speed you want to change the voltage the capacity and resistor are chosen.

    If you don't mind adding some components I would add a OP-amp supplied with minimum 6.5V and a capacitor between non-inverting input and GND
    and a capacitor between output and GND of the OP-Amp to smoothen the ripple-voltage down to 5-20mV.

    maybe more advanced electronic experts than me have another easy to build solution.
    For a suitable solution tell us what is the maximum changing-speed of the voltage?
    What kind of device you are feeding in this voltage and what is the input-impedance of this device (meaning how much current will it draw)

    keep the questions coming
    best regards

    Stefan
  • HarrisracingHarrisracing Posts: 10
    edited 2011-08-02 14:19
    Thanks very much for the replies! Now we are getting somewhere!

    My goal is to create a device for my car that does the following things:

    1) Hook up a 0-5V pressure sensor that is existing on my car. This sensor correlates manifold pressure and I have the factory sensor scaled already, the higher the voltage the higher the pressure. This will be read as an input to the Propeller through an ADC. It is a very simple gauge that has +5V, ground, and voltage out. I am assuming it doesn't use much power at all.

    2) Follow this boost signal and output a 0-5V PWM signal to the ecu. Again VERY low current I'm imagining. I will likely use a pretty high frequency to smooth the flow. There is ONE TRICK to this in that the logic will eventually clamp the signal at a certain voltage. In my case it will be around 4.3V maximum - this will eliminate the computer from seeing an "Overboost" code which shuts down the car. 4.3V is 13 psi. Any more will trigger Overboost fuel cut.

    3) Control an LED display to readout the current ACTUAL boost pressure. 0-5V from the sensor is actually related pressure and the ECU senses overboost at 13 psi (or 4.3V). I'd still like to use the rest of the scale (up to 5V) to drive this gauge while still being able to "fool" the computer into thinking it's not going over the 14 psi.

    4) Later I will get a different pressure sensor which will be able to read even higher than the factory one and scale the gauge accordingly.

    5) Much later this controller may drive a solenoid to actually CONTROL boost pressure that I will be able to set - but that will happen later.

    Thank You all - keep the ideas coming.
    Patrick
Sign In or Register to comment.