Yay! The Sleep Pixies delivered.
On a Pico it is entirely possible to have a digital output, set that high or low, then read the voltage on that pin when using an ADC pin.
That makes it as easy as pushing two resistors into holes on a Pico board, nothing more barring the code.
Rather surprisingly my 330R Rs also measures 330R, and, more surprisingly still, my notional 4700R Rh also measures the same 4690R as the OP. I didn't expect that but at least it means we are comparing as like-to-like as we can.
Because we can do the calculations with ADC readings, without converting those to voltages, I chose those for my Vh, V and Vs. I sample each ADC repeatedly to make sure the S&H cap is at the correct level and also take multiple readings of all ADC sets so we have an average to hopefully reduce any induced noise. I use 12-bit ADC values so they match the raw hardware readings, and that also removes any oddities MicroPython may have added in converting those to 16-bit.
One interesting discovery is things are a lot worse when GPIO23 is set high to enable the regulator PWM mode which supposedly has less ripple.
Using this circuit -Sanity check for approximate voltages readHow close V reading is to expected V calculated from actual Rh:RsCalculate Rh and see how close it is to actual RhCalculate average Rh and see how close it is to actual RhSo it's still a mixed bag and inconsistent on the Pico.
Going right back to the second table, the 'V' I am getting against what would be expected the discrepancy is consistently far greater in my 'FWD' readings. That is a mystery which needs solving.
If we don't have reliable input data we won't get reliable results. Even so there are some considerable inconsistencies which wouldn't have been expected.
On a Pico it is entirely possible to have a digital output, set that high or low, then read the voltage on that pin when using an ADC pin.
That makes it as easy as pushing two resistors into holes on a Pico board, nothing more barring the code.
Rather surprisingly my 330R Rs also measures 330R, and, more surprisingly still, my notional 4700R Rh also measures the same 4690R as the OP. I didn't expect that but at least it means we are comparing as like-to-like as we can.
Because we can do the calculations with ADC readings, without converting those to voltages, I chose those for my Vh, V and Vs. I sample each ADC repeatedly to make sure the S&H cap is at the correct level and also take multiple readings of all ADC sets so we have an average to hopefully reduce any induced noise. I use 12-bit ADC values so they match the raw hardware readings, and that also removes any oddities MicroPython may have added in converting those to 16-bit.
One interesting discovery is things are a lot worse when GPIO23 is set high to enable the regulator PWM mode which supposedly has less ripple.
Using this circuit -
Code:
| O Pico O | | O O | Rh ___ | O O | Vh .-----|___|----. | O GP28 ADC2 34 O |-----' 4690 | | O GND 33 O | / | O GP27 ADC1 32 O |------------------< V | O GP26 ADC0 31 O |-----. \ | O O | Vs | Rs ___ | | O O | `-----|___|----' | O O | 330 | O O |
Code:
.-----.-----. .------.------.------. .-------.---------.-------. | Dir | Pin | | Vh | V | Vs | | Vh | V | Vs | |-----|-----| |------|------|------| |-------|---------|-------| | FWD | 1 0 | | 4080 | 307 | 40 | | 3.188 | 0.240 | 0.031 | | REV | 0 1 | | 40 | 3810 | 4082 | | 0.031 | 2.977 | 3.189 | | FWD | 1 0 | | 4081 | 307 | 40 | | 3.188 | 0.240 | 0.031 | | REV | 0 1 | | 40 | 3813 | 4084 | | 0.031 | 2.979 | 3.191 | | FWD | 1 0 | | 4083 | 307 | 40 | | 3.190 | 0.240 | 0.031 | | REV | 0 1 | | 40 | 3814 | 4080 | | 0.031 | 2.980 | 3.188 | | FWD | 1 0 | | 4082 | 307 | 40 | | 3.189 | 0.240 | 0.031 | | REV | 0 1 | | 40 | 3813 | 4082 | | 0.031 | 2.979 | 3.189 | `-----^-----' `------^------^------' `-------^---------^-------'
Code:
.-----.-----. .------.------.------. .--------------.----------. | Dir | Pin | | Vh | V | Vs | | V Expected | Error | |-----|-----| |------|------|------| |--------------|----------| | FWD | 1 0 | | 4081 | 308 | 40 | | 305.643 | +0.7710% | | REV | 0 1 | | 40 | 3812 | 4082 | | 3816.29 | -0.1124% | | FWD | 1 0 | | 4083 | 308 | 40 | | 305.775 | +0.7277% | | REV | 0 1 | | 40 | 3815 | 4082 | | 3816.29 | -0.0338% | | FWD | 1 0 | | 4083 | 307 | 40 | | 305.775 | +0.4007% | | REV | 0 1 | | 40 | 3814 | 4079 | | 3813.49 | +0.0134% | | FWD | 1 0 | | 4079 | 307 | 40 | | 305.512 | +0.4871% | | REV | 0 1 | | 40 | 3815 | 4079 | | 3813.49 | +0.0396% | `-----^-----' `------^------^------' `--------------^----------'
Code:
.-----.-----. .------.------.------. .--------------.----------. | Dir | Pin | | Vh | V | Vs | | Rh Calc | Error | |-----|-----| |------|------|------| |--------------|----------| | FWD | 1 0 | | 4081 | 307 | 40 | | 4664.49 | -0.5438% | | REV | 0 1 | | 40 | 3816 | 4083 | | 4666.97 | -0.4911% | | FWD | 1 0 | | 4083 | 307 | 40 | | 4666.97 | -0.4911% | | REV | 0 1 | | 40 | 3812 | 4082 | | 4610.22 | -1.7010% | | FWD | 1 0 | | 4082 | 307 | 40 | | 4665.73 | -0.5175% | | REV | 0 1 | | 40 | 3815 | 4081 | | 4683.27 | -0.1435% | | FWD | 1 0 | | 4084 | 307 | 40 | | 4668.2 | -0.4648% | | REV | 0 1 | | 40 | 3812 | 4082 | | 4610.22 | -1.7010% | `-----^-----' `------^------^------' `--------------^----------'
Code:
.-----------------.-----------------. .--------------.----------. | FWD Rh Calc | REV Rh Calc | | Rh Calc Avg | Error | |-----------------|-----------------| |--------------|----------| | 4664.49 | 4666.97 | | 4665.73 | -0.5175% | | 4666.97 | 4610.22 | | 4638.59 | -1.0961% | | 4665.73 | 4683.27 | | 4674.5 | -0.3305% | | 4668.2 | 4610.22 | | 4639.21 | -1.0829% | `-----------------^-----------------' `--------------^----------'
Going right back to the second table, the 'V' I am getting against what would be expected the discrepancy is consistently far greater in my 'FWD' readings. That is a mystery which needs solving.
If we don't have reliable input data we won't get reliable results. Even so there are some considerable inconsistencies which wouldn't have been expected.
Statistics: Posted by hippy — Fri May 10, 2024 11:46 am