Check out my project site at hackaday.io
Use the latest Micropython release. Copy the content of the "RP2040 Pi Pico Code_int_log" folder to the root directory of the RP2040.
The PPPM comes pre programmed ready to go to measure up to 26V and 3.2A.
If you need other / better performance on your measured object you can change the settings in the code. Everything is done in this function:
ina.configure(SHUNT_OHMS, VBUS_RANGE_16, VSHUNT_MAX_2, BADC_12BIT, SADC_12BIT, MODE_SHUNT_BUS_C)
Here's how to go:
- Estimate your maximum voltage
- VBUS_RANGE_32 for max. 26V
- VBUS_RANGE_16 for max. 16V
- Estimate the maximum current (with 0.1Ohms shunt) and set the gain
- VSHUNT_MAX_1 for range +-0.04mV -> Imax = 0.4A
- VSHUNT_MAX_2 for range +-0.08mV -> Imax = 0.8A
- VSHUNT_MAX_4 for range +-0.16mV -> Imax = 1.6A
- VSHUNT_MAX_8 for range +-0.32mV -> Imax = 3.2A
This will change the value of the LSB and thus change the precision.
The LSB is calculated like this:
$LSB = \frac{maxcurrent}{2^{15}}$ If you soldered a different shunt the max. current changes to:$I=\frac{range}{shunt}$
- Conversion speed (the faster the less accurate) Valid for BADC (Bus voltage)and SADC (Shunt voltage)
- BADC_9BIT for 9bit values in 84µs
- BADC_10BIT for 10bit values in 148µs
- BADC_11BIT for 11bit values in 276µs
- BADC_12BIT for 12bit values in 532µs
- BADC_2S for 2 Samples in 1.06ms
- BADC_4S for 4 Samples in 2.13ms
- BADC_8S for 8 Samples in 4.26ms
- BADC_16S for 16 Samples in 8.51ms
- BADC_32S for 32 Samples in 17.02ms
- BADC_64S for 64 Samples in 34.05ms
- BADC_128S for 128 Samples in 68.1ms
- Choose the mode you need
- MODE_POWER_DOWN compleatly off
- MODE_SHUNT_TRIG only shunt, triggered
- MODE_VOLT_TRIG only voltage, triggered
- MODE_SHUNT_BUS_T shunt and voltage, triggered
- MODE_ADC_OFF only adc off
- MODE_SHUNT_C only shunt, continuous
- MODE_VOLT_C only voltage, continuous
- MODE_SHUNT_BUS_C shunt and voltage, continuous