Power Supply Voltage Monitor Hack

In recent weeks, there have been a couple of issues that I have wondered were due to power supply “sagging” with the issue being that this something that happens over time and unpredictably. Understanding if this is the issue can be expensive as DC power supply monitors are instruments with a somewhat limited market.

Thinking about it, I wondered if a Klipper based printer itself could monitor the power supply voltage through an unused thermistor connector - I realize that this means somewhat higher end main controller boards as most boards only have two thermistor connectors (for the extruder and heated bed) but many have three,to allow the user to add a second extruder.

The concept is to bring the power supply power to one of the thermistor ports but there are two issues, the first being that the voltage is much higher than what the MCU pin can handle and the second being that the sensor pin is pulled up (normally with a 4k7 resistor). The solution was to put the power supply output through a voltage divider that is shared with the sensor pin as you can see in the set up I simulated:

Just as a note, I designed this for 0 to 70V for anybody running with a 56V system (ie for TMC5160s) - the power supply resistor could be increased to 1k for a 24V system to give more granularity but I’m not sure how useful that would be. If the resistor was changed to 1k, I would recommend rerunning the simulation to understand the new voltage levels for the adc_temperature statement presented below.

I realize that the simulator “schematic” presented here ain’t great but if you can accept the “4.7k” resistor side, away from the “3.3V” power source is one of the thermistor pins and the bottom line is the circuit Ground and the other thermistor pin, then you should see that I have set up a 2k2/100Ω voltage divider with the thermistor pin in the middle, the power supply output at one end and Ground at the other end.

The Bill of Materials for my prototypes is:

  • 2k2 1% 1/4W resistor, radial package
  • 100Ω 1% 1/4W resistor, radial package
  • Two Pin JST-XH (2.54mm) plug connector with 2x Crimp Connectors
  • Red and Black 26 AWG wire
  • Heat Shrink Tubing
  • Ring Connector for Power Supply connection (although I just used a bared wire)

It took me 20 minutes to put together my first prototype including time to find the parts. I’ve added it to my other three printers (3x M8Ps and 1x Octopus Pro) with the time required to make the hacks being less than ten minutes each.

The statements that I added to my Manta M8P printer.cfg are:

[adc_temperature ps_voltage]
# PSU Voltage Value from Thermistor Value
# Assumuptions:
# 1. Power Supply Voltage from 0V to 70V
# 2. Thermistor ADC Pullup 4.7k
temperature1: 2
voltage1: 0.151
temperature2: 70
voltage2: 3.049
[temperature_sensor ps_voltage]
adc_voltage: 3.3
sensor_pin: PA2  # <== "TH1" 
sensor_type: ps_voltage
min_temp: 22  # For 24V Power Supply
max_temp: 26  # For 24V Power Supply
gcode_id: Ps_voltage  

When I first tried it out for the first time, on my Mainsail dashboard I saw:

Which wasn’t bad but my actual power supply output is 24.15V (as measured by my Fluke DVM). I’m assuming the difference is due to part tolerances.

If I play with the [adc_temperature ps_voltage] values, I can get it nuts on, but it’s a bit tedious and the purpose of this is to be able to do a quick check of the voltage output as well as keep a log of the power supply output values over time.

I was pleased to see in the printer’s klippy.log in each “Stats ###.#” line:

... ps_voltage: temp=23.7 ...

Which means that the value is recorded continuously.

When I tweaked the adjustment pot on the power supply, I can see the changes reflected in the displayed/logged values - although I only did it for 0.2V in either direction.

I’m calling this a “Hack” because I’m taking advantage of the thermistor circuitry on the main controller board and Klipper’s ability to define custom temperature sensors. It would be just about perfect if there was a way to display the values as “V” instead of “°C”.

Here are my notes including the simulation I did on the circuit including the graph showing the sensor voltage with respect to the power supply voltage (it’s a linear function) along with the printer.cfg statements listed above.

2024.01.21 - 3D Printer Power Supply Monitor Circuit.pdf (144.7 KB)

Comments? Would this be useful for people?

5 Likes

Nice work @mykepredko :+1:
For continuous monitoring, I think this is very useful. Guess it will miss short drops or transient spikes due to the sampling frequency.

1 Like

Interesting idea. Thanks for sharing.

It’s certainly possible to make a new Klipper module to extract the ADC values, convert them to voltages, and log them.

Also, FYI, many of the STM chips have an internal voltage sensor (on the internal 3.3V line) similar to their internal temperature sensors.

-Kevin

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.