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

Request HVPWM explanation #30

Open
gmgunderground opened this issue Jun 3, 2024 · 1 comment
Open

Request HVPWM explanation #30

gmgunderground opened this issue Jun 3, 2024 · 1 comment

Comments

@gmgunderground
Copy link

gmgunderground commented Jun 3, 2024

I'm looking inside the C source code, can someone explane the following function? Especially the used values.

void picoemp_enable_pwm(float duty_frac) {
    if(pwm_enabled) {
        return;
    }

    // Get PWM slice
    uint32_t slice = pwm_gpio_to_slice_num(PIN_OUT_HVPWM);
    gpio_set_function(PIN_OUT_HVPWM, GPIO_FUNC_PWM);
    
    // Set up clock divider
    float target_frequency = 25;
    float divider = clock_get_hz(clk_sys) / target_frequency;
    pwm_config config = pwm_get_default_config();
    pwm_config_set_clkdiv(&config, divider);
    pwm_config_set_wrap(&config, UINT16_MAX);

    // Init PWM, but don't start it yet
    pwm_init(slice, &config, false);
    // pwm_set_chan_level(slice, PWM_CHAN_A, 800); // pretty sure this line is pointless
    pwm_set_freq_duty(slice, PWM_CHAN_A, 2500, duty_frac);
    pwm_set_enabled(slice, true);
    pwm_enabled = true;
}

what the The duty_frac is used for? How is correlated to the power?
What are the bahavior of the following parameters?
pulse_time=5, pulse_power=0.012200
Are parameters that it's worth a change?
All are changable parameters from serial interface, bat is not explaned haw they can be used and wht they produce on charge of HV.

@colinoflynn
Copy link
Contributor

It might make more sense looking at the micropython source: https://github.com/newaetech/chipshouter-picoemp/blob/main/firmware/micropython/cspico_simple.py#L16

That has the short note that things were basically just empirically tuned! So there's no real magic... you could play around with things and see what happens to the charge voltage and/or recovery time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants