Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 17 of 17

Thread: Teensy V3.2 - Boost PWM Output from 3V to 9V

  1. #1

    Teensy V3.2 - Boost PWM Output from 3V to 9V

    Hi I need to boost the PWM output freq from 3V to ~9V. I've seen other posts regarding this w/ 5V. Can someone provide a good circuit using a MOSFET for something like this. I need to provide a input freq of 8.5V into some other hardware. I'd like to use the Teensy to do it if there's a quick and simple solution for it that works. Thanks for your help.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Look for "Mosfet gate driver" chips. These are meant to take PWM logic signals and drive the gates of mosfet transistors, which typically need about 10V. Look for ones claiming to have TTL inputs. Most of them are designed to be able to output very high peak current, since they're meant for driving the large (and voltage varying) capacitance of a mosfet, but it's perfectly fine to use them for less demanding loads.

    For example, LM5111 might work.

    http://www.ti.com/product/lm5111

    https://www.digikey.com/product-deta...296-48924-1-ND

  3. #3
    Thanks Paul. Would this circuit work for this w/ the VCC= 9v, R1 = 10K and RG1 = 1K? Ultimately, I'd like pump in a constant PWM freq 111hz into a 3.3v to 9v booster then use another PWM port on the teensy w/ a freq acting a gate control (~30hz) for the constant freq which I need to pass as an input to another circuit, not sure how to pull this off circuit wise since I'm a software guy and not an electrical expert =)

    Click image for larger version. 

Name:	TransistorNotGate.png 
Views:	19 
Size:	46.3 KB 
ID:	14269
    Last edited by wildview; 07-24-2018 at 06:31 PM.

  4. #4
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    260
    Yes, with correction to the resistor values. You have them the wrong way around. RG1 should be 10K and R1 should be 1K. The value of RG1 is not critical and could be a higher value at 100K. Its purpose is to pull the gate voltage down to zero volts (ground) when there is no input signal driving it (such as at power up when Teensy pins are inputs, before configured as outputs).

    You can use general purpose n channel FETs such as 2N7000. They have a gate turn on voltage of between 2.5 and 3 volts nominal (temperature dependant) so 3v3 from a Teensy pin will just suffice to put it into the "on" conducting region. Normally, the gate voltage would be higher at, say 10 volts, but with a R1 drain load resistor of 1K, then a 9 volt supply will set the "on" current at 9/1000 equals 9 mA (Ohms law). 3v3 will turn the FET on sufficiently to give this small current [at least mine do :-)].

    You could also use a general purpose bipolar transistor such as 2N3904. Again use a 1K resistor as the output in series with the "collector" to the +9v supply. The transistor "base" would have the 10K in series with it (connected from teensy pin straight to the base, not to ground). There would be no requirement for a resistor to ground because if there is no "base" current (as when the Teensy pin is low) then the transistor will be "off".

    The "emitter" is, of course, connected to ground - just like the "source" terminal in your diagram.

    Either of these should work fine.
    Last edited by TelephoneBill; 07-26-2018 at 07:59 AM.

  5. #5
    Senior Member
    Join Date
    Dec 2013
    Posts
    215
    So this is open drain setup right, I need this for serial TX. I'm just curious how fast I can transmit the data with the setup.
    Will 2N2222A NPN transistor work?

  6. #6
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    260
    2N2222A is a high speed device, so yes, as a device its a good choice - as a transistor (low collector to base or ground capacitance).

    The speed "factor" will be dependant on the value of the collector load. If you have "open collector" set up, that means the load is at the far end, where a pull-up resistor will pull the Tx line high when the 2N2222A turns off. Just how fast this returns to the high state depends on the Tx line length, or more accurately, the capacitance it has (intrinsic) to ground. You can get an estimate if you know the capacitance (roughly). If the pull up is 1K , and the capacitance is say 100 pF, the time constant from this RC combination is R times C seconds, or 10e3 times 10e-10 = 10e-7 seconds. That would indicate a speed of 10 MHz, but generally speaking, you should allow five time constants rise time, so that brings it down to about 2 MHz.

    A smaller pull-up load resistor (470R) would pull it up faster, but more current has to be switched on and off. Its usually a compromise.

    Better than a single transistor (pulling down) is a LINE DRIVER, which has a totem pole output - that means a complementary PNP transistor pulling upwards at the send end, rather than relying on the load resistor alone to pull the line high. But that's more complex and not a simple "open setup".

  7. #7
    Thanks TelephoneBill for the input and all the options. I have a bunch of IRLB8721PBF N-CH MOSFET packages laying around that trigger at low voltages, so I'll probably use that part.

    Since I need to gate the constant freq being fed into another circuit that is expecting an ~8v constant/gated freq, I will first convert the freq output up to 9V using the MOSFET, then from the source of that part through 1K resistor into the Collector of a 3904 which the base of that part will be another freq ~30hz input from the Teensy to control the gating of the constant freq fed into the Collector. The Emitter output of the 3904 should be the constant/gated ~9V freq required for my other hardware. Do you think this theory will work? Tnx.

  8. #8
    Senior Member
    Join Date
    Dec 2013
    Posts
    215
    Ok I'm not trying to hijack this thread so I wasn't going to reply but perhaps this is useful info, NPN transistors and Radio Shack:
    If you're in North America and picked up the multipack from RadioShack NPN Transistors (15-Pack) 2761617 pay attention they show the pinout from Bottom View (easy to miss), this is sort of confusing and wasted some time.
    Click image for larger version. 

Name:	15-PACK.jpg 
Views:	11 
Size:	110.4 KB 
ID:	14288

    Click image for larger version. 

Name:	to-92.jpg 
Views:	9 
Size:	15.1 KB 
ID:	14289
    Looking at the flat side of the package, the wires are E, B, C from left to right.

  9. #9
    So Chris, what is your point in your reply. Everyone on this thread pretty much knows the pinout of a Transistor. It's using them that most people usually need assistance with. Your reply is kind of off topic from the original question =)

  10. #10
    Senior Member
    Join Date
    Dec 2013
    Posts
    215
    My question was about open drain because this is what you have here.
    Open drain = behaves like a switch that is either connected to ground or disconnected, I need to supply (20v) flash strobe voltage multiplexed on the same UART TX line when the transistor is disconnected under software control.
    I hope this clears a bit and sorry.

  11. #11
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    260
    Quote Originally Posted by wildview View Post
    Do you think this theory will work? Tnx.
    Part of the joy with Teensy (and electronics in general) is the fun of finding out the answer. You learn that way (particularly when things do not go as planned).

    Use a scope to check what is happening with your circuit (you may be surprised) - plenty old analogue ones going begging these days if pennies are tight. A good quality digital scope can show you even more.

    In general, most engineers would gate signals before they were elevated to higher voltages - but what works is what counts. And often something crops up that you were not expecting.

    Have you considered "gating" in software? Get something working first (as you describe) - then see if you can simplify.

    I think Chris's point is "beware - pinouts look a different 123 order when viewed from below". Even old hands can get caught out.

    Have fun...

  12. #12
    Thanks, yeah pinouts are not an issue for me, thanks though for the heads up. I have actually designed some pretty cool projects using the Teensy including my LLLT laser device which is amazing for healing, so I'm pretty familiar w/ the package.

    Regardless, I would rather use a software gate as you mentioned, but I don't think I can get the accuracy without using external hardware. Unless you know a good way =) I need a 111hz output gated at around 30hz. I can use the analogWriteFrequency(pin,freq) to set the freq I need, but don't know how I would gate it exactly unless I use a IntervalTimer on the same pin.

    Tnx.Click image for larger version. 

Name:	BioHealerBH1 (Demo).jpg 
Views:	28 
Size:	97.2 KB 
ID:	14301

  13. #13
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    260
    The main concern in this area - is safety. Bio Med products must "fail safe" if they are used as treatment. An old engineer would ask what failure conditions might be experienced. Logic can fail either high or low - would this mean outputs may go to full power? What would be the consequences if they did? If a cosmic ray arrives with your name on it, then even the Teensy pin circuitry can go pop.

    This forum is obviously not the place to go into more depths... but you might want to measure the output by an independant means and take action in software - if certain conditions are not fulfilled - much like a watchdog idea.

  14. #14
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    With a single transistor as common-source or common-emitter (as show in msg #3), you'll get a slight distortion of the waveform, in addition to increasing the voltage and inverting the signal. The distortion happens because the output fall time is very fast, due to the low on-resistance of the transistor. But the low-to-high rise time is much slower, because the pullup resistor has much higher resistance. Ultimately the time depends on the capacitance, which is mostly the mosfet's drain-to-source capacitance plus whatever you connect to the output. If you're sending the signal over a lengthy cable or using it to drive the gate of another mosfet, the capacitance might be quite substantial.

    Or maybe it'll be a non-issue. The answer also depends on how much you care about the signal's PWM duty cycle maintaining accuracy. Many PWM applications don't demand high accuracy, only good relative resolution. But if you care about 50.00% not becoming 50.02%, then even a small capacitance could really ruin things for you.

  15. #15
    Thanks Paul. I think it'll work fine since I don't need perfect accuracy and it's all being used together in a circuit and not through a long wire. Is there a clean way to implement a software type gate that I can apply to the PWM output port. Or would it be better to do it externally w/ say a 3904 transistor w/ the gate being driven by another PWM output port. Tnx.

  16. #16
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Well that depends on what you mean by "a clean way".

  17. #17
    The clean way would be to do the gating using the teensy code. I need to output a PWM frequency of say 111Hz using the analogWriteFrequency() method, but need an adjustable gate on that port at ~30Hz, is this possible to do in the Teensy code by using an intervalTimer on the same port? I really can't find any examples of doing this in the software. Maybe it can't be done, not sure. I can always resort to using an external transistor so, it's not a big deal, but would like to try the software method if it can be done.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •