Author Topic: Issues of an STM32-based device where the MCU can adjust its own voltage?  (Read 302 times)

0 Members and 2 Guests are viewing this topic.

Offline daqqTopic starter

  • Super Contributor
  • ***
  • Posts: 2314
  • Country: sk
    • My site
Dear forum members,

I am designing an STM32-based measurement device where the MCU will be able to control its own power supply voltage. It will do so because it's required to have adjustable logic levels. Nothing fancy, just switch between 1.8V, 2.5V and 3.3V.

I want to do so by switching the feedback resistors of an adjustable output LDO ( https://www.onsemi.com/pdf/datasheet/ncp705-d.pdf ) through external NPN transistors to ground. The feedback network will be of lower impedance than recommended - this will be to make sure that the capacitance to ground added by the inactive NPN transistors and the resistors they are switching will not affect the feedback network significantly.

The safety will be ensured by the calculation of the feedback network that the only way to achieve maximum voltage will be to turn on both transistors. By default (transistors open), the output voltage would be 1.8V, by switching on the additional parallel resistors, the voltage can be increased, but only to 3.3V.

Pretty much the schematic in the attachment (the actual LDO will be different and the resistance values will be for a different feedback, this is just a convenient model I have in LTSpice to test out the concept).

My question is whether there could be any issues with this sort of dynamic input voltage switching? By dynamic I mean once every few seconds at worst and not during any critical operations, with enough time for everything to settle to the new voltage. Of course the brown out will be set to the minimal value. There will be no USB, only logic in, logic out, and the ADC will check itself against an external 1.25V reference, and there'll be no fancy ADC stuff anyway.

My gut tells me that this should work. The only thing that I can think of is that some PLL will need to re-lock briefly or something?

Can you see any issues?

Thanks,

David
Believe it or not, pointy haired people do exist!
+++Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1150
  • Country: lt
Re: Issues of an STM32-based device where the MCU can adjust its own voltage?
« Reply #1 on: September 28, 2024, 09:01:27 pm »
Don't use BJT, cause they will not be ohmic near zero CE voltage. Use small mosfets. In fact you don't even need mosfets or other external components. Just use MCU pins. They will be around 25-30 Ohms when driven low. Configure them as open drain outputs and job done, they are also low capacitance.

Such voltage transients should not be a problem for MCU, just watch that they are not super fast. Ballpark value - not faster than 100us / 1V. Maybe faster is ok, I don't know, you need to try.
 

Online Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3812
  • Country: nl

The safety will be ensured by the calculation of the feedback network that the only way to achieve maximum voltage will be to turn on both transistors. By default (transistors open), the output voltage would be 1.8V, by switching on the additional parallel resistors, the voltage can be increased, but only to 3.3V.

No, it's the other way around. When you turn on one (or both) of the BJT's the output goes lower. Maximum output voltage is when the transistors are off.

Using a MOSfet as a switch instead of a BJT probably gets you a more accurate output voltage, but it will work good enough with a BJT. Application notes (or even the datasheet itself) of the LM317 uses BJT's as suggestion for a "programmable output voltage".

But do not use the I/O pins for this directly. Sure, it works as Manul writes, but if you ever inadvertently change the pin to an output high, then you will fry your microcontroller.
I think that the core of all STM32 chips runs on something like 1.8V and they have an internal regulator, but even so, I'd try to make the power supply voltage switch slowly, for example by adding a capacitor between the base of the BJT and GND. This gives PLL's, crystal oscillators and who knows what else happens inside the STM32 some time to adjust to the changing voltage.
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1150
  • Country: lt

The safety will be ensured by the calculation of the feedback network that the only way to achieve maximum voltage will be to turn on both transistors. By default (transistors open), the output voltage would be 1.8V, by switching on the additional parallel resistors, the voltage can be increased, but only to 3.3V.

No, it's the other way around. When you turn on one (or both) of the BJT's the output goes lower. Maximum output voltage is when the transistors are off.

I'm afraid daqq is correct, why would an output get lower, when bottom leg of divider gets lower?

But do not use the I/O pins for this directly. Sure, it works as Manul writes, but if you ever inadvertently change the pin to an output high, then you will fry your microcontroller.

Why fry? If you drive it high, then that switchable resistor will effectively be in parallel with the top leg of voltage divider. That will lower the output voltage, not increase it. When GPIO peripheral is not initialized, pins are floating, then code sets GPIO to open drain. Seems ok to me. GPIO will not magically reconfigure itself and even if it does, I see nothing catastrophic. Looks like simple, elegant solution. Voltage ramp speed must be checked though and can be adjusted by changing feedforward capacitor (in parallel with top leg of divider). Higher value capacitor will make voltage ramp slower.
 

Offline daqqTopic starter

  • Super Contributor
  • ***
  • Posts: 2314
  • Country: sk
    • My site
Thanks for the replies.

Manul: I'm not sure why BJT transistors shouldn't work? Yeah, they won't be really ohmic, but with near zero current, the voltage drop on them should be near zero anyway, no? I can use MOSFETs, though they'll have to work from 1.8V. Should be pretty common these days though.

As to using pins directly, I would like to avoid that - if I mess up the software and turn the pin on as a output, logic high, then the voltage would drop to near zero, possibly causing some reset loop.

Doctorandus_P: No, that's not how the circuit works. If you lower the resistance on the "bottom" side of a feedback resistive divider for this application, the voltage goes up.
Believe it or not, pointy haired people do exist!
+++Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf