New revisions of PWM and MPPT 10A boards included

This commit is contained in:
Martin Jaeger
2019-05-02 10:27:16 +02:00
parent 2ac2d1c3ad
commit ff53f6ff99
4 changed files with 268 additions and 8 deletions
+33 -8
View File
@@ -13,7 +13,9 @@
#env_default = libresolar_0_10
#env_default = cloudsolar_0_2
#env_default = cloudsolar_0_4
#env_default = cloudsolar_0_6
#env_default = pwm_0_1
#env_default = pwm_0_2
[common]
@@ -35,8 +37,8 @@ build_flags =
-D MBED_BUILD_PROFILE_RELEASE
# -D MBED_BUILD_PROFILE_DEBUG
lib_deps_external =
https://github.com/ThingSet/thingset-cpp
lib_deps =
https://github.com/ThingSet/thingset-cpp#ca0e7025950e9ea932801ef5dd810d3bf84b3244
SX1276GenericLib
lib_ignore = USB, mbed-USBDevice, mbed-mbedtls
@@ -52,7 +54,7 @@ upload_protocol = ${common.upload_protocol}
monitor_speed = ${common.monitor_speed}
build_flags = ${common.build_flags}
-D PCB_LS_005=1
lib_deps = ${common.lib_deps_external}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
# https://github.com/LibreSolar/MPPT-Charger_20A/tree/5bc39183c8
@@ -64,7 +66,7 @@ upload_protocol = ${common.upload_protocol}
monitor_speed = ${common.monitor_speed}
build_flags = ${common.build_flags}
-D PCB_LS_010=1
lib_deps = ${common.lib_deps_external}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
# https://github.com/LibreSolar/MPPT-Charger_10A/tree/586626f3d8
@@ -76,7 +78,7 @@ upload_protocol = ${common.upload_protocol}
monitor_speed = ${common.monitor_speed}
build_flags = ${common.build_flags}
-D PCB_CS_02=1
lib_deps = ${common.lib_deps_external}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
# https://github.com/LibreSolar/MPPT-Charger_10A/tree/63e5842671
@@ -88,10 +90,21 @@ upload_protocol = ${common.upload_protocol}
monitor_speed = ${common.monitor_speed}
build_flags = ${common.build_flags}
-D PCB_CS_04=1
lib_deps = ${common.lib_deps_external}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
# https://github.com/LibreSolar/PWM-Charger_20A
[env:cloudsolar_0_6]
platform = ${common.platform}
framework = mbed
board = nucleo_l073rz
upload_protocol = ${common.upload_protocol}
monitor_speed = ${common.monitor_speed}
build_flags = ${common.build_flags}
-D PCB_CS_06=1
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
# initial test version (obsolete)
[env:pwm_0_1]
platform = ${common.platform}
framework = mbed
@@ -100,5 +113,17 @@ upload_protocol = ${common.upload_protocol}
monitor_speed = ${common.monitor_speed}
build_flags = ${common.build_flags}
-D PCB_PWM_01=1
lib_deps = ${common.lib_deps_external}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
# https://github.com/LibreSolar/PWM-Charger_20A
[env:pwm_0_2]
platform = ${common.platform}
framework = mbed
board = nucleo_l073rz
upload_protocol = ${common.upload_protocol}
monitor_speed = ${common.monitor_speed}
build_flags = ${common.build_flags}
-D PCB_PWM_02=1
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
+4
View File
@@ -71,8 +71,12 @@
#include "pcbs/pcb_cs_02.h"
#elif defined(PCB_CS_04)
#include "pcbs/pcb_cs_04.h"
#elif defined(PCB_CS_06)
#include "pcbs/pcb_cs_06.h"
#elif defined(PCB_PWM_01)
#include "pcbs/pcb_pwm_01.h"
#elif defined(PCB_PWM_02)
#include "pcbs/pcb_pwm_02.h"
#else
#error "PCB has to be specified!"
#endif
+109
View File
@@ -0,0 +1,109 @@
/* LibreSolar MPPT charge controller firmware
* Copyright (c) 2016-2018 Martin Jäger (www.libre.solar)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __PCB_CS_06_H_
#define __PCB_CS_06_H_
#include "mbed.h"
// DC/DC converter settings
#define PWM_FREQUENCY 50 // kHz 50 = better for cloud solar to increase efficiency
#define PWM_TIM 3 // use TIM3 timer
#define DCDC_CURRENT_MAX 10 // PCB maximum DCDC output current
#define LOAD_CURRENT_MAX 10 // PCB maximum load switch current
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
#define PIN_UEXT_SDA PB_7
#define PIN_UEXT_MISO PB_4
#define PIN_UEXT_MOSI PB_5
#define PIN_UEXT_SCK PB_3
#define PIN_UEXT_SSEL PA_15
#define PIN_SWD_TX PA_9
#define PIN_SWD_RX PA_10
#define PIN_LOAD_EN PC_13
#define PIN_USB_PWR_EN PB_10
#define PIN_V_SOLAR_EN PC_14
#define PIN_5V_PGOOD PC_15
#define PIN_EXT_BTN PB_12
#define PIN_REF_I_DCDC PA_4
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
// assignment LED numbers on PCB to their meaning
#define NUM_LEDS 5
#define LED_SOC_1 0 // LED1
#define LED_SOC_2 1 // LED2
#define LED_SOC_3 2 // LED3
#define LED_LOAD 3 // LED4
#define LED_RXTX 4 // LED5, used to indicate when sending data
// LED pins and pin state configuration to switch above LEDs on
#define NUM_LED_PINS 3
static const PinName led_pins[NUM_LED_PINS] = {
// A B C
PB_13, PB_2, PB_14
};
static const pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = {
{ PIN_HIGH, PIN_LOW, PIN_FLOAT }, // LED1
{ PIN_LOW, PIN_HIGH, PIN_FLOAT }, // LED2
{ PIN_HIGH, PIN_FLOAT, PIN_LOW }, // LED3
{ PIN_FLOAT, PIN_HIGH, PIN_LOW }, // LED4
{ PIN_FLOAT, PIN_LOW, PIN_HIGH } // LED5
};
// pin definition only needed in adc_dma.cpp to detect if they are present on the PCB
//#define PIN_ADC_TEMP_FETS PA_5
// typical value for Semitec 103AT-5 thermistor: 3435
#define NTC_BETA_VALUE 3435
#define ADC_GAIN_V_BAT (105.6 / 5.6) // both voltage dividers: 100k + 5.6k
#define ADC_GAIN_V_SOLAR (105.6 / 5.6)
#define ADC_GAIN_I_LOAD (1000 / 4 / 50) // amp gain: 50, resistor: 4 mOhm
#define ADC_GAIN_I_DCDC (1000 / 4 / 50)
// position in the array written by the DMA controller
enum {
ADC_POS_V_BAT, // ADC 0 (PA_0)
ADC_POS_V_SOLAR, // ADC 1 (PA_1)
ADC_POS_I_LOAD, // ADC 5 (PA_5)
ADC_POS_I_DCDC, // ADC 6 (PA_6)
ADC_POS_TEMP_BAT, // ADC 7 (PA_7)
ADC_POS_VREF_MCU, // ADC 17
ADC_POS_TEMP_MCU, // ADC 18
NUM_ADC_CH // trick to get the number of elements
};
// selected ADC channels (has to match with above enum)
#define ADC_CHSEL ( \
ADC_CHSELR_CHSEL0 | \
ADC_CHSELR_CHSEL1 | \
ADC_CHSELR_CHSEL5 | \
ADC_CHSELR_CHSEL6 | \
ADC_CHSELR_CHSEL7 | \
ADC_CHSELR_CHSEL17 | \
ADC_CHSELR_CHSEL18 \
)
#endif
+122
View File
@@ -0,0 +1,122 @@
/* LibreSolar MPPT charge controller firmware
* Copyright (c) 2016-2018 Martin Jäger (www.libre.solar)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __PCB_PWM_02_H_
#define __PCB_PWM_02_H_
#include "mbed.h"
#define CHARGER_TYPE_PWM 1 // PWM charge controller instead of MPPT
#define PWM_TIM 3 // use TIM3 timer
#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
#define PIN_UEXT_SDA PB_7
#define PIN_UEXT_MISO PA_11
#define PIN_UEXT_MOSI PA_12
#define PIN_UEXT_SCK PB_3
#define PIN_UEXT_SSEL PA_15
#define PIN_SWD_TX PA_9
#define PIN_SWD_RX PA_10
#define PIN_LOAD_DIS PB_2
#define PIN_USB_PWR_DIS PB_5
#define PIN_REF_I_DCDC PA_4
#define PIN_TEMP_INT_PD PA_8
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
// assignment LED numbers on PCB to their meaning
#define NUM_LEDS 5
#define LED_SOC_1 0 // LED1
#define LED_SOC_2 1 // LED2
#define LED_SOC_3 2 // LED3
#define LED_LOAD 3 // LED4
#define LED_RXTX 4 // LED5, used to indicate when sending data
// LED pins and pin state configuration to switch above LEDs on
#define NUM_LED_PINS 3
static const PinName led_pins[NUM_LED_PINS] = {
// A B C
PB_13, PB_14, PB_15
};
static const pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = {
{ PIN_HIGH, PIN_LOW, PIN_FLOAT }, // LED1
{ PIN_LOW, PIN_HIGH, PIN_FLOAT }, // LED2
{ PIN_HIGH, PIN_FLOAT, PIN_LOW }, // LED3
{ PIN_FLOAT, PIN_HIGH, PIN_LOW }, // LED4
{ PIN_FLOAT, PIN_LOW, PIN_HIGH } // LED5
};
/*
// LEDs with wrong polarity
static const pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = {
{ PIN_LOW, PIN_HIGH, PIN_FLOAT }, // LED1
{ PIN_HIGH, PIN_LOW, PIN_FLOAT }, // LED2
{ PIN_LOW, PIN_FLOAT, PIN_HIGH }, // LED3
{ PIN_FLOAT, PIN_LOW, PIN_HIGH }, // LED4
{ PIN_FLOAT, PIN_HIGH, PIN_LOW } // LED5
};
*/
// pin definition only needed in adc_dma.cpp to detect if they are present on the PCB
#define PIN_ADC_TEMP_BAT
// typical value for Semitec 103AT-5 thermistor: 3435
#define NTC_BETA_VALUE 3435
#define NTC_SERIES_RESISTOR 8200.0
#define ADC_GAIN_V_BAT (132 / 12)
#define ADC_GAIN_V_SOLAR (1 + 120/12 + 120/8.2)
#define ADC_GAIN_I_LOAD (1000 / 2 / (68/2.2)) // op amp gain: 68/2.2, resistor: 2 mOhm
#define ADC_GAIN_I_SOLAR (1000 / 2 / (68/2.2))
#define ADC_OFFSET_V_SOLAR (-120.0 / 8.2) // to be multiplied with VDDA to get absolute voltage offset
// position in the array written by the DMA controller
enum {
ADC_POS_V_BAT, // ADC 0 (PA_0)
ADC_POS_V_SOLAR, // ADC 1 (PA_1)
ADC_POS_I_LOAD, // ADC 5 (PA_5)
ADC_POS_I_SOLAR, // ADC 6 (PA_6)
ADC_POS_TEMP_BAT, // ADC 7 (PA_7)
ADC_POS_VREF_MCU, // ADC 17
ADC_POS_TEMP_MCU, // ADC 18
NUM_ADC_CH // trick to get the number of elements
};
// selected ADC channels (has to match with above enum)
#define ADC_CHSEL ( \
ADC_CHSELR_CHSEL0 | \
ADC_CHSELR_CHSEL1 | \
ADC_CHSELR_CHSEL5 | \
ADC_CHSELR_CHSEL6 | \
ADC_CHSELR_CHSEL7 | \
ADC_CHSELR_CHSEL17 | \
ADC_CHSELR_CHSEL18 \
)
#endif