Microcontroller with 5V supply to control 3.3V power
Started by 6 years ago●11 replies●latest reply 6 years ago●368 viewsI own an HM-TRP radio module which I want automatically configured using just a microcontroller (at89C2051) and an external 5VDC power supply (USB). In the past I can successfully detect when the module is successfully configured for operation at a specific speed on initialization just by reading the magic string.
Now the problem is complex.
The only two ways I can tell if the radio module is at the correct speed are either a) wait for a remote unit to transmit data at the same speed, which in this case is never, or b) detect the magic string.
So the way I can achieve this is to somehow control the power supply programmatically so that the microcontroller guesses the correct speed (by setting serial mode 1 and playing with the timer reload values) and have it turn on the radio module. If after several hundred milliseconds, the magic string doesn't appear, then microcontroller needs to shut the radio module off and change the timer reload value so that its on a different baud rate.
I have no problem with doing this in software, but I was wondering if my schematic is correct for this purpose. In my previous circuits, I had the 3V power supply directly wired to the LM1117 3.3V regulator (IC3) so that the radio module stays on while the rest of the circuit is powered. Now I want to allow the microcontroller to completely switch on and off the power at its will.
Is the PN2222 NPN transistor ok for this purpose? If so, then what about resistor values, does the collector pull-up resistor need to be in the low hundreds ohm range to give the radio module enough power? Or should I use another part in place of the PN2222? and if another part, what should it be? can it be a part that's commonly available in stores?
P.S. The 74HCT04 inverters are used to help turn the 5V signals from the micro to the 3V signals for the radio module itself. I'm not sure if they can also be used to power the radio module as well. The radio module accepts a max of 3.9V.
If I understand your circuit correctly, you use the transistor to short the power for the radio module and hope that you can find a resistor value for R2 that is small enough so that the current consumption of the RF module causes only negligible voltage drop but high enough so that the short current doesn't harm the transistor or the regulator.
Instead of shorting the power you'd be better off using a FET in series with the RF module's power. Common logic level FETs can be easily switched with the output port of the micro, they can take a lot of current and, most importantly, they have very little resistance when on - in the 10-s of mohms range. That eliminates all your problems (no voltage drop on the resistor, no high current from the short, no wasted power) and saves you a resistor (or, if the micro boots with pull-up port pins, two).
I could give you a few P-channel FET types, but I don't, because on the one hand I usually use SMD FETs and I assume you need through-hole and on the other I have no idea what can you buy in the local electronics store. But go to DigiKey and look for MOS FETs. There's a pretty good selection filter, where you can set P-channel, through-hole, logic level and the relevant voltage and current limits and you will be presented with many tens of types - check which one is sold in your store.
Yes you're understanding my logic.
The local store does sell a few mosfets...
https://secure.sayal.com/STORE/ActionIndexC.asp?CL...But I'm not sure which one to choose that can handle 3 to 5V. If I'm not mistaken, most mosfets need 10+V to do their magic? And what about capacitance in the mosfets? I mean if they're too high, wouldn't that negatively affect operations?
I also have a local store that does order from digikey but I will be charged a higher price most likely.
What specific part numbers do you recommend and why?
Most MOS FETs do not need 10+ V to do anything. In fact, many can be killed with that kind of gate voltage. There are many which fully open at less than 2.5V, some less than 1.8V.
They have a Cgs indeed, but we're talking about a 0.1 to 10nF range of equivalent capacitance (the Cgs is not a real passive capacitor, but let's not go into that). Even if your micro can only supply 1mA on its port and you use some 100A FET with 10nF Cgs it would take only 30us to fully open or close the FET. That would not work in a switch mode power supply but your timeframe is in the many milliseconds range, where the 30us delay is irrelevant.
I don't really have the time to go trough your local store's catalog, but for example the LP0701 from Microchip can easily do the job; if you can't get that, look at its datasheet and find a FET with similar performance. The LP0701 is not that crash-hot, but with a 3.3V gate voltage and an assumed 100mA load from the RF module it has a voltage drop of maybe 200mV which should be fine. And if you put it in front of the regulator rather than behind it, then the gate voltage will be 5V and the Vds wouldn't really matter anyway.
question is, would my timeframe be in the milliseconds range?
I mean if I'm testing the radio modules at different speeds, the magic string will come at different speeds as well.
For example, if I was testing for 115kbps then I'll need to process way faster than many milliseconds to see if the characters are coming through correctly.
Now I'm not sure how long it takes for the first character to be output from the module the moment it is powered up by the transistor (or fet). Timing is very important as I don't want to lose sync.
Ok, maybe I'd be willing to lose the first and second character, but I want to be able to let the micro still identify the module with the remaining characters the module spits out.
There is an easy way for this, if the protocol is your own. Add first 5-8 bytes in communication as 0x55 or 0xAA, and use it to wake-up and determine the speed. Since first few bytes are known, you can use it to determine the speed also and capture the packet.
The number of initial bytes should be such that the fastest baud rate should accommodate at least 1 character time in slowest baud, for eg, if fastest is 115.2 kbps, and slowest is 38.4 kbps, then no of initial bytes should be > (115.2/38.4 = 3).
But I'm not trying to send and receive data through the air.
Every time the radio module turns on and the micro communicates it with the baud rate it expects to be communicated at, the string sent to the micro is "HM-TRP-V02!". I want to be able to retrieve this string an unlimited number of times without a remotely connected unit sending that string back. So the way to do it is to shut the radio module power off, then turn the radio module power back on again.
Well, for starters, when the RF module is powered down, you will receive a constant 0, which is a break condition. When you turn the power on, first the RF module's power has to ramp up, then it needs to initialise itself and drive the line to high. Then your micro needs to realise that the break condition is gone and start to hunt for start bits. All that won't happen in a few microsecs, for sure.
Now, the 10nF and 30us was just to demonstrate the magnitude of the worst-case upper limit on the switch8ing delay. The actual gate charge of the FET I suggested is about 2nC, which with a more realistic 5mA I/O drive can be delivered or eliminated in about 400ns. So the FETs gate capacitance is not going to be an issue.
By the way, bipolar transistors are not exactly fast either. Your design powers the module when the transistor is off and turning off a fully saturated transistor is usually slower than turning off a FET.
The thing with this particular circuit is that I won't keep it powered forever. I'm only going to use it every time I need to program a radio module to the proper speed. And As for power consumption, most of the time, I would just leave the module on to save power because turning it off with the transistor setup would cause 3/(collector resistor) amps to be wasted for nothing. Plus if I wanted to turn off the power module for good, I'd disconnect the primary power.
I'm not sure that I can get away with a 2N3904. Its a faster transistor than 2N2222 but I don't know if it can handle the power the module needs. I own both of those transistors.
What happens if you disconnect the "ADJ" line on the LM1117 from everything else?
Does the output ("OUT") line of the LM1117 drop to 0V with a small load attached to it?
That's probably true, but I don't want a manual solution. I'm looking for one where I can control power using software
You're not picking up what I am putting down.