Fixed board clicking when enabled and no load connected
Added a check before turning on the charger for the cap voltage. Don't limit duty cycle on turn on if cap voltage is above 35V. Don't turn on diode unless voltage is below 50V
This commit is contained in:
parent
895234e20c
commit
3c1446ef2a
|
@ -2,6 +2,7 @@
|
||||||
#include "hardware/pio.h"
|
#include "hardware/pio.h"
|
||||||
#include "hardware/pwm.h"
|
#include "hardware/pwm.h"
|
||||||
#include "CC_Charger.h"
|
#include "CC_Charger.h"
|
||||||
|
#include "hardware/adc.h"
|
||||||
|
|
||||||
// Our assembled programs:
|
// Our assembled programs:
|
||||||
#include "CLK.pio.h"
|
#include "CLK.pio.h"
|
||||||
|
@ -29,7 +30,6 @@
|
||||||
|
|
||||||
//Telemetry:
|
//Telemetry:
|
||||||
#define VSENSE_TRIP_PIN 11
|
#define VSENSE_TRIP_PIN 11
|
||||||
#define CAP_VSENSE_PIN 27
|
|
||||||
|
|
||||||
PIO pio;
|
PIO pio;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ void disable_CC_timing() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void enable_CC_timing() {
|
void enable_CC_timing(bool diode_on) {
|
||||||
|
|
||||||
//Don't start the charger if the caps are already charged
|
//Don't start the charger if the caps are already charged
|
||||||
if(caps_charged == false){
|
if(caps_charged == false){
|
||||||
|
@ -105,7 +105,7 @@ void enable_CC_timing() {
|
||||||
|
|
||||||
gpio_put(CC_CHARGER_EN_PIN, true); //Enable the CC Charger gate driver
|
gpio_put(CC_CHARGER_EN_PIN, true); //Enable the CC Charger gate driver
|
||||||
|
|
||||||
gpio_put(DIODE_ON_PIN, true); //Turn on the ideal diode
|
gpio_put(DIODE_ON_PIN, diode_on); //Turn on the ideal diode
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ void disable_CC_timing();
|
||||||
/*! \brief Enable Constant Current Charger timing outputs, effectively turns on CC charger
|
/*! \brief Enable Constant Current Charger timing outputs, effectively turns on CC charger
|
||||||
\ingroup CC_Charger
|
\ingroup CC_Charger
|
||||||
*/
|
*/
|
||||||
void enable_CC_timing();
|
void enable_CC_timing(bool diode_on);
|
||||||
|
|
||||||
/*! \brief Sets the CC charger clock period, indirectly sets the switching frequency of the CC charger
|
/*! \brief Sets the CC charger clock period, indirectly sets the switching frequency of the CC charger
|
||||||
\ingroup CC_Charger
|
\ingroup CC_Charger
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#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"
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
|
|
||||||
//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 70
|
#define OUTPUT_OFF_TIME 80
|
||||||
#define ISO_PULSE false
|
#define ISO_PULSE false
|
||||||
#define CAP_VOLTAGE_SETPOINT 70
|
#define CAP_VOLTAGE_SETPOINT 70
|
||||||
|
|
||||||
|
@ -64,6 +65,8 @@ 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
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "pulse_generator.h"
|
#include "pulse_generator.h"
|
||||||
#include "CC_Charger.h"
|
#include "CC_Charger.h"
|
||||||
#include "hardware/pwm.h"
|
#include "hardware/pwm.h"
|
||||||
|
#include "hardware/adc.h"
|
||||||
|
|
||||||
#define OUTPUT_EN_PIN 2
|
#define OUTPUT_EN_PIN 2
|
||||||
#define OUTPUT_CURRENT_TRIP_PIN 10
|
#define OUTPUT_CURRENT_TRIP_PIN 10
|
||||||
|
@ -10,6 +11,8 @@
|
||||||
|
|
||||||
#define PULSE_COUNTER_PWM_PIN 24
|
#define PULSE_COUNTER_PWM_PIN 24
|
||||||
|
|
||||||
|
#define CAP_VSENSE_PIN 27
|
||||||
|
|
||||||
#define SHORT_THRESHOLD 410
|
#define SHORT_THRESHOLD 410
|
||||||
|
|
||||||
bool cutting_enabled = false;
|
bool cutting_enabled = false;
|
||||||
|
@ -114,10 +117,16 @@ 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);
|
||||||
|
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)
|
LIMIT_set_timing(97, 7, false); //Limit CC Charger PWM duty cycle to avoid inrush (was 97)
|
||||||
|
|
||||||
enable_CC_timing(); //Start CC Charger
|
enable_CC_timing(v_cap < 1300); //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
|
||||||
|
|
||||||
|
@ -141,7 +150,7 @@ int64_t begin_off_time(alarm_id_t id, void *user_data){
|
||||||
|
|
||||||
output_state = SPARK_OFF; //Set state machine state to SPARK_OFF
|
output_state = SPARK_OFF; //Set state machine state to SPARK_OFF
|
||||||
|
|
||||||
if(pulse_counter > 410) {
|
if(pulse_counter > 513) {
|
||||||
cutting_enabled = false;
|
cutting_enabled = false;
|
||||||
short_tripped = true;
|
short_tripped = true;
|
||||||
disable_CC_timing();
|
disable_CC_timing();
|
||||||
|
@ -163,7 +172,7 @@ int64_t first_off_time(){
|
||||||
|
|
||||||
LIMIT_set_timing(97, 7, false); //Limit CC Charger PWM duty cycle to avoid inrush (was 97)
|
LIMIT_set_timing(97, 7, false); //Limit CC Charger PWM duty cycle to avoid inrush (was 97)
|
||||||
|
|
||||||
enable_CC_timing(); //Start CC Charger
|
enable_CC_timing(true); //Start CC Charger
|
||||||
|
|
||||||
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
|
||||||
|
@ -212,5 +221,6 @@ void pulse_generator_init(uint32_t trip_current) {
|
||||||
|
|
||||||
gpio_add_raw_irq_handler(OUTPUT_CURRENT_TRIP_PIN, &output_current_trip_irq);
|
gpio_add_raw_irq_handler(OUTPUT_CURRENT_TRIP_PIN, &output_current_trip_irq);
|
||||||
|
|
||||||
|
adc_gpio_init(CAP_VSENSE_PIN);
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
21654338788247244
|
21654338790288434
|
||||||
Audio_Module
|
Audio_Module
|
||||||
Reverb_BTDR-1H
|
Reverb_BTDR-1H
|
||||||
Digital Reverberation Unit, http://www.belton.co.kr/inc/downfile.php?seq=17&file=pdf (footprint from http://www.uk-electronic.de/PDF/BTDR-1.pdf)
|
Digital Reverberation Unit, http://www.belton.co.kr/inc/downfile.php?seq=17&file=pdf (footprint from http://www.uk-electronic.de/PDF/BTDR-1.pdf)
|
||||||
|
|
Loading…
Reference in New Issue