Stabilized Code (Removed clicking eliminator and reduced output voltage)
This commit is contained in:
parent
3c1446ef2a
commit
0784295572
|
@ -2,7 +2,6 @@
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include "pico/time.h"
|
#include "pico/time.h"
|
||||||
#include "hardware/pwm.h"
|
#include "hardware/pwm.h"
|
||||||
#include "hardware/adc.h"
|
|
||||||
|
|
||||||
#include "CC_Charger.h"
|
#include "CC_Charger.h"
|
||||||
#include "pulse_generator.h"
|
#include "pulse_generator.h"
|
||||||
|
@ -12,9 +11,9 @@
|
||||||
|
|
||||||
//OUTPUT PULSE PARAMETERS (times in usecs)
|
//OUTPUT PULSE PARAMETERS (times in usecs)
|
||||||
#define OUTPUT_ON_TIME 20
|
#define OUTPUT_ON_TIME 20
|
||||||
#define OUTPUT_OFF_TIME 80
|
#define OUTPUT_OFF_TIME 70
|
||||||
#define ISO_PULSE false
|
#define ISO_PULSE false
|
||||||
#define CAP_VOLTAGE_SETPOINT 70
|
#define CAP_VOLTAGE_SETPOINT 65
|
||||||
|
|
||||||
//CC Charger Parameters (don't change unless you know what you're doing)
|
//CC Charger Parameters (don't change unless you know what you're doing)
|
||||||
#define CHARGER_CURRENT 850
|
#define CHARGER_CURRENT 850
|
||||||
|
@ -65,8 +64,6 @@ int main() {
|
||||||
|
|
||||||
sleep_ms(1000);
|
sleep_ms(1000);
|
||||||
|
|
||||||
adc_init();
|
|
||||||
|
|
||||||
CC_Charger_init(CHARGER_CURRENT, CAP_VOLTAGE_PWM_LEVEL); //Setup the CC Charger Outputs
|
CC_Charger_init(CHARGER_CURRENT, CAP_VOLTAGE_PWM_LEVEL); //Setup the CC Charger Outputs
|
||||||
|
|
||||||
pulse_generator_init(70); //Setup Pulse generator
|
pulse_generator_init(70); //Setup Pulse generator
|
||||||
|
|
|
@ -117,17 +117,11 @@ int64_t begin_off_time(alarm_id_t id, void *user_data){
|
||||||
|
|
||||||
gpio_set_irq_enabled(OUTPUT_CURRENT_TRIP_PIN, GPIO_IRQ_EDGE_RISE, false); //Disable the ignition sense irq
|
gpio_set_irq_enabled(OUTPUT_CURRENT_TRIP_PIN, GPIO_IRQ_EDGE_RISE, false); //Disable the ignition sense irq
|
||||||
|
|
||||||
adc_select_input(1);
|
LIMIT_set_timing(97, 7, false); //Limit CC Charger PWM duty cycle to avoid inrush (was 97)
|
||||||
uint16_t v_cap = adc_read();
|
|
||||||
bool low_v = v_cap < 900;
|
|
||||||
gpio_put(SHORT_ALERT_PIN, low_v);
|
|
||||||
if(low_v)
|
|
||||||
LIMIT_set_timing(97, 7, false); //Limit CC Charger PWM duty cycle to avoid inrush (was 97)
|
|
||||||
|
|
||||||
enable_CC_timing(v_cap < 1300); //Start CC Charger
|
enable_CC_timing(true); //Start CC Charger
|
||||||
|
|
||||||
if(low_v)
|
add_alarm_in_us(15, change_CC_timing, NULL, true); //Setup the alarm to correct CC charger timing
|
||||||
add_alarm_in_us(15, change_CC_timing, NULL, true); //Setup the alarm to correct CC charger timing
|
|
||||||
add_alarm_in_us(pulse_off_time-11, begin_on_time, NULL, true); //Setup the alarm to turn on the output MOSFET after the off time
|
add_alarm_in_us(pulse_off_time-11, begin_on_time, NULL, true); //Setup the alarm to turn on the output MOSFET after the off time
|
||||||
|
|
||||||
pulse_counter -= pulse_history[0] & (uint32_t)0x1; //Subtract the 512th pulse state from the counter
|
pulse_counter -= pulse_history[0] & (uint32_t)0x1; //Subtract the 512th pulse state from the counter
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -63,7 +63,7 @@
|
||||||
36,
|
36,
|
||||||
40
|
40
|
||||||
],
|
],
|
||||||
"visible_layers": "8089110_7fffffe1",
|
"visible_layers": "8089130_7fffffe1",
|
||||||
"zone_display_mode": 0
|
"zone_display_mode": 0
|
||||||
},
|
},
|
||||||
"meta": {
|
"meta": {
|
||||||
|
|
Loading…
Reference in New Issue