KeithWalker
- Joined Jul 10, 2017
- 3,093
MrChips circuit in post #13 does exactly what you wanted. A 3V PWM input signal will result in a 5V PWM signal out.
Q.E.D.
Q.E.D.
I was trying to get a 3v PWM input to a 0-5 analog out signal.MrChips circuit in post #13 does exactly what you wanted. A 3V PWM input signal will result in a 5V PWM signal out.
Q.E.D.
We understand that. You can convert the PWM signal to 0-1V analog and then use an opamp to amplify it to 0-5V.I was trying to get a 3v PWM input to a 0-5 analog out signal.
We understand that. You can convert the PWM signal to 0-1V analog and then use an opamp to amplify it to 0-5V.
Which sensor do you have? Generally, i2C cannot be amplified and you can't increase resolution of the sensor with an amplifier.Do you have an example circuit and a good simulator you could point me to so I could try to learn more? Need to walk away too frustrated.... the more you think you know the less you know
BME280 I posted the diagram earlier, but the sensor is a BME280 and its setup to an esp8266 mod. Have a few uses for this setup around the house. Was hoping to general purpose it.Which sensor do you have? Generally, i2C cannot be amplified and you can't increase resolution of the sensor with an amplifier.
So, the esp8266 can directly pull the temperature value from the sensor with I2C digital communication. There is no need for analog values (in or out) and no need for PWM.BME280 I posted the diagram earlier, but the sensor is a BME280 and its setup to an esp8266 mod. Have a few uses for this setup around the house. Was hoping to general purpose it.
I'm using the esp8266 to wifi connect to my home controller for some logic controls.So, the esp8266 can directly pull the temperature value from the sensor with I2C digital communication. There is no need for analog values (in or out) and no need for PWM.
Do you understand how I2C communication works?
What are you trying to do with PWM?
It's a common-gate circuit - it should work.You can't use an N-MOFET for that, since the Vgs gate voltage must be several volts to turn on, which makes the gate voltage several volts above 5V.
But it's not clear what that circuit is doing.
Explain the "analog write function" and what your code is supposed to do.
After some learning, the OPs title doesn't exactly describe the OP's goal. Re-read the last Qp posts or so. Yes, 2n7000 are used commonly for logic level shifting but thst is not what the OP needs, even though he thought he needed it. But the key was, he is a self-described beginner (post 1).It's a common-gate circuit - it should work.
Pin (Source) = 0V - gate = 3.3V - MOSFET turns on - output = 0V
Pin (Source) = 3.3V - gate = 3.3V - MOSFET turns off - output pulls up to 5V via 10k resistor.
I suspect that there is a load on the circuit which is pulling it down.
The time constants are all wrong - 11k in one direction and 1k in the other. I would suggest swapping the 1k and 10k resistors to make it more equal.
But I would really suggest using a 74HCT04 as a buffer - it will level-shift from 3V to 5V, because the high-level threshold is 2.4V
Then you have an output resistance which is the same in both directions.
So would the 74HCT04 work for what I need or am I way off base stating logic shift?After some learning, the OPs title doesn't exactly describe the OP's goal. Re-read the last Qp posts or so. Yes, 2n7000 are used commonly for logic level shifting but thst is not what the OP needs, even though he thought he needed it. But the key was, he is a self-described beginner (post 1).
You can pass the 3.3v PWM (analogWrite) signal to the inputs of a 74AHTC125 chip that is powered by a 5v source.So would the 74HCT04 work for what I need or am I way off base stating logic shift?
Yes, but as I said earlier a single device is inverting which puts the PWM 'upside down', so analogWrite(255) = 0 out and analogWrite(0) = 100% which is counter-intuitive, especially for a beginner! and by the time you've deployed 3 transistors or MOSFETs for a non-inverting push-pull output you might as well use a chip, its less wiring and more reliable.actually, if the intent is only to get a 5v output, then a NPN transistor with a resistor at the collector pull up to 5v would do the trick.
the base goes to the pin.
e.g. 2N2222
https://en.wikipedia.org/wiki/2N2222
https://en.wikipedia.org/wiki/Common_emitter
the trouble is this is 'inverting', so either daisy chain 2 stages, or ensure that the transistor is switched on i.e. bring the base high once it is powered up.
A thing about pwm dac is i think there may be residual ac signals unless C is pretty high, LPF reduces linearly by decade frequencies after all e.g. 10 hz, 100hz, 1000hz etc
I've been wanting to 'control' a varicap diode feeding a FM (80mhz-108mhz) colpitts oscillator stage. And i keep having doubts about whether pwm dac would feed signals into into the oscillator and cause things to go off track.
e.g. if one wants to tune 80 mhz, doing pwm dac to control the varicap would that cause the FM oscillation to go out of control and off track? pwm dac isn't quite 'pure dc'
That is an important point to which I did not pay attention. I suspect that @loca5790 will be able to solve that with one or two lines of code. One philosophy connected with the use of microcontrollers is that using external hardware to solve a problem that can be solved in software (and in this case trivially) is a waste. Now that @Irving has identified a needed modification loca5790 can solve it if they want to. And yes, if they don't want to they can find the hardware solution on this page above. It is their choice.Yes, but as I said earlier a single device is inverting which puts the PWM 'upside down', so analogWrite(255) = 0 out and analogWrite(0) = 100% which is counter-intuitive, especially for a beginner! and by the time you've deployed 3 transistors or MOSFETs for a non-inverting push-pull output you might as well use a chip, its less wiring and more reliable.
A pmw DAC with an active multipole filter can be pretty clean on the output. An LC rather than an RC filter is another option. A single pole RC filter is a pretty poor filter.
The other issue with the single transistor arrangement is the the default output, at startup, is 5v not 0v. This may not be so convenient for the external systems and not so trivial to resolve without, for example, another GPIO providing some form of secondary interlock.That is an important point to which I did not pay attention. I suspect that @loca5790 will be able to solve that with one or two lines of code. One philosophy connected with the use of microcontrollers is that using external hardware to solve a problem that can be solved in software (and in this case trivially) is a waste. Now that @Irving has identified a needed modification loca5790 can solve it if they want to. And yes, if they don't want to they can find the hardware solution on this page above. It is their choice.
The lowest emitter-collector voltage of most small signal NPN transistors is about 0.2 to 0.4V so the bottom 8% of the dynamic range is lost with a simple NPN option - which would be the highest 8% range after the OP inverts his code to accommodate the inversion which may also require a library to be edited if he is using a peripheral. Note, the OP wants to filter the output with an RC networks to turn the level-converted PWM to analog value which is missing from the schematic in post 13.These last half dozen posts only drag the thread off into Never-Never Land. The solution presented by @MrChips in post #13 solves the problem neatly and does not require replacing the computing platform or using external components more complicated than a transitor.
I think @loca5790 will be very happy with what that simple circuit accomplishes, and he should ignore attempts to redefine the problem as being more complicated than it is.
Thus to be limited to the esp8266 for the footprint and capability I went with analog write to PWM in hopes I could step up the 3.3v to 5v and the LP RC filter it to smooth it out for better analog mimicking vs increasing frequency. I tried driving it above 1kHz but had issues with compiling.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
P | How to add 2n7000 to LT Spice? | Analog & Mixed-Signal Design | 7 | |
Several questions about 2N7000 transistors | General Electronics Chat | 20 | ||
C | 2n7000 spice model and datasheet mismatch | PCB Layout , EDA & Simulations | 7 | |
1-bit EEPROM with 2N7000 MOSFET | Digital Design | 38 | ||
Driving 2N7000 from Arduino | Microcontrollers | 6 |