Implemented:

- MMPT class for data store
- SerialPort library for USB-CAN connection
- Stream to Singnlak's DataBrowser 3
This commit is contained in:
Giuseppe Raffa
2026-05-25 13:14:19 +02:00
parent 9d6766cda1
commit 91161d2d2c
5 changed files with 966 additions and 0 deletions

80
src/core/constants.js Normal file
View File

@@ -0,0 +1,80 @@
/*
Costanti del protocollo Poweren MPPT Boost.
Riferimento: Manuale Doc. 40.0000.206, Hw v1.2 Rev 01.
Il microcontrollore degli MPPT (PIC24/dsPIC33 a virgola fissa) trasmette interi a 16 bit.
Per ottenere il valore fisico bisogna dividere il raw per il fattore di conversione.
*/
// Fattori di conversione (valore_fisico = raw / factor)
const conversionsFactors = {
voltageInput: 10, // tensione ingresso [V] es: 296 -> 29.6 V
currentInput: 100, // corrente ingresso [A] es: 1100 -> 11.00 A
powerInput: 10, // potenza ingresso [W] es: 3260 -> 326.0 W
voltageOutput: 10, // tensione uscita [V] es: 864 -> 86.4 V
currentOutput: 100, // corrente uscita [A] es: 380 -> 3.80 A
powerOutput: 10, // potenza uscita [W] es: 3110 -> 311.0 W
temperaturePhase1: 10, // temperatura fase 1 [°C]
temperaturePhase2: 10, // temperatura fase 2 [°C]
chargeCapacity: 100, // capacita' caricata [Ah] es: 1234 -> 12.34 Ah
};
// Flag del registro Status1 (registro 4): mappa bit -> codice operativo
const status1Flags = {
0: 'PwrEna', // Power stage abilitato via software
1: 'ChgEna', // Ponte Pin1-Pin8 inserito (enable hardware)
2: 'ChgOk', // Condizioni di ricarica OK
3: 'PwrOn', // Stadio di potenza acceso (eroga corrente)
4: 'StorMod', // Modalita' storage attiva
5: 'FloatMod', // Modalita' float (mantenimento)
6: 'CtrlEna', // Algoritmo MPPT abilitato
7: 'CCapRst', // Reset contatore Ah
8: 'Ph1Ena', // Fase 1 abilitata
9: 'Ph2Ena', // Fase 2 abilitata
10: 'QREna', // Quasi-Resonant Mode
11: 'DirMPPT', // Direzione algoritmo MPPT
};
// Flag del registro Warning (registro 6): mappa bit -> codice di errore/warning
const errorsFlags = {
0: 'fault',
1: 'vi_under_voltage_protection',
2: 'vi_low_voltage', // MPPT in standby
3: 'vi_over_voltage_protection',
4: 'li_over_current_protection',
5: 'under_minimum_battery_voltage',
6: 'over_maximum_battery_voltage',
7: 'current_to_battery_over_max', // protezione hw a 7A verso batteria
8: 'internal_hardware_protection',
9: 'over_temperature_protection', // sopra 120 °C
10: 'memory_flash_read_error',
};
// Indirizzi dei registri richiesti via polling attivo
const registerAddresses = {
powerInput: 20,
powerOutput: 21,
temperature1: 35,
temperature2: 36,
};
// Mapping dei bitrate CAN al comando slcan corrispondente (Lawicel CAN232/CANUSB)
const slcanBitrateCommands = {
10000: 'S0',
20000: 'S1',
50000: 'S2',
100000: 'S3',
125000: 'S4',
250000: 'S5',
500000: 'S6',
800000: 'S7',
1000000: 'S8',
};
module.exports = {
conversionsFactors,
status1Flags,
errorsFlags,
registerAddresses,
slcanBitrateCommands,
};