Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize CV input with additional 1nF capacitor? #394

Open
chrisib opened this issue Nov 24, 2024 · 3 comments
Open

Stabilize CV input with additional 1nF capacitor? #394

chrisib opened this issue Nov 24, 2024 · 3 comments
Labels
hardware - EuroPi Hardware related issue improvement Improvement or optimization of an existing feature or script suggestion New feature or request

Comments

@chrisib
Copy link
Collaborator

chrisib commented Nov 24, 2024

Hardware Issue

A user reported on Discord that adding a 1nF capacitor in parallel with R23 improves the accuracy of the ADC, resulting in more accurate calibration.

Proposed modified input stage, adding C*:
modified_input_stage

This modification appears to match the original input stage, for example the one found in Braids:
braids_input

Planned Experiment

I've ordered some extra capacitors (I don't have any 1nF caps on-hand right now) and plan on modifying one of my EuroPis to include the proposed change. Then I'll send in fixed voltages to AIN and record the raw PWM readings over some period of time, and compare the variance before & after the modification to see how much of a difference this really makes.

@chrisib chrisib added suggestion New feature or request hardware - EuroPi Hardware related issue improvement Improvement or optimization of an existing feature or script labels Nov 24, 2024
@chrisib
Copy link
Collaborator Author

chrisib commented Nov 24, 2024

Started recording the data. I'm still waiting for the capacitors (I only ordered them yesterday, but they should arrive this week).

https://docs.google.com/spreadsheets/d/1rbvg_A5ZrKb3OqOu_JKJJ7-fPOTPx5xrRCnM5VENmN4/edit?usp=sharing

Script to generate the source data:

from europi import ain, b1, oled
from time import sleep

def main():
    def wait_for_b1(value):
        while b1.value() != value:
            sleep(0.05)

    for volts in range(11):
        oled.centre_text(f'Connect {volts}V\nPress B1')
        wait_for_b1(1)

        with open(f'{volts}_v.csv', 'w') as fout:
            fout.write(f'{volts}V\n')
            for i in range(1000):
                duty = ain.pin.read_u16()
                fout.write(f'{duty}\n')
                
        wait_for_b1(0)
            
    oled.centre_text('Done')

if __name__ == '__main__':
    main()

@chrisib
Copy link
Collaborator Author

chrisib commented Nov 28, 2024

Got my extra capacitors and added the 1nF to the back-side of the board, connected directly to the ends of R23. Re-ran the code above. Results added to https://docs.google.com/spreadsheets/d/1rbvg_A5ZrKb3OqOu_JKJJ7-fPOTPx5xrRCnM5VENmN4/edit?usp=sharing

Interestingly at 0V the noise in the duty cycle actually seemed to go up. Could be a random event; we're not dealing with a lot of trials, so data's going to be subject to some variance. But for all values above 0V, the standard deviation dropped by about half, which indicates much less noise in the duty cycle.

I'm tentatively willing to call the experiment a success, though the extra noise at 0V is worth investigating further.

If anyone else wants to repeat this experiment and post their results, I'd love to see the results of more data across a wider range of modules.

@chrisib
Copy link
Collaborator Author

chrisib commented Nov 28, 2024

Photos showing the 1nF capacitor soldered directly to the legs of R23; this is easiest if you have not cut the legs on the resistor too short.

PXL_20241128_010517013~2

PXL_20241128_010554761

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hardware - EuroPi Hardware related issue improvement Improvement or optimization of an existing feature or script suggestion New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant