stuartpittaway / diyBMSv4ESP32

diyBMS v4 code for the ESP32 and new controller hardware
Other
181 stars 80 forks source link

CAN - Failed to queue CANBUS message (chip=TJA1057GT/3J) #287

Open brii999 opened 6 months ago

brii999 commented 6 months ago

Hi.

First of all, thanks a lot for creating such a great project like diyBMS.

I am assembling my own energy storage and I have reached the stage where I want to connect diyBMS with Cerbo GX from Victron.

I created the appropriate cable, checked whether it had continuity and connected it to Cerbo and BMS. Unfortunately, the data from the BMS did not appear in Cerbo and the BMS itself started to restart. I connected via the serial port and watched the logs:

..............

No key press detected
I (6374) diybms-set: Load WIFI config from FLASH - return 1
I (6375) diybms-set: IP=0,GW=0
I (6375) diybms: Wifi Config: SSID:XXX, Manual Config:0
I (6378) diybms: Manual IP:0.0.0.0, Netmask:0.0.0.0, GW:0.0.0.0, DNS1:0.0.0.0, DNS2:0.0.0.0
I (6386) diybms-set: Load config
I (6389) diybms-set: Count: UsedEntries = (249), FreeEntries = (381), AllEntries = (630)
I (6425) diybms: homeassist_apikey=UsMI64fQVWqCGxbBB2vKajGv
I (6425) curmon: INA229 chip absent
I (6426) diybms: Onboard/internal current monitoring chip not installed
I (6430) diybms-hal: CAN driver installed.  Filter=0 Mask=4294967295
I (6435) diybms-hal: CAN driver started
D (6440) diybms: Setup RS485
D (6442) diybms: Configure RS485
I (6447) diybms: ** Controller changed state from PowerUp to Stabilizing **
D (6451) diybms: starting wifi_init_sta
I (6475) diybms: WIFI SSID: XXX
I (6547) diybms: Hostname: DIYBMS-00EC889C
D (6547) diybms: wifi_init_sta finished
I (6547) diybms: TFT screen is NOT installed
I (13594) diybms: WIFI_EVENT_STA_START
D (13694) diybms: total_free_byte=161052 total_allocated_byte=132712 largest_free_blk=110580 min_free_byte=159108 alloc_blk=360 free_blk=7 total_blk=367
I (14402) diybms: WIFI_EVENT_STA_CONNECTED channel=1, rssi=-53
I (14414) diybms: IP ADDRESS HAS CHANGED
I (14415) diybms: Request time from time.google.com
I (14416) diybms: Timezone=UTC0DST0
I (14417) diybms: The current date/time is: Sun Mar 24 15:46:07 2024
I (14442) diybms: You can access DIYBMS interface at http://DIYBMS-00EC889C.local or http://192.168.99.210
E (14592) diybms: Failed to queue CANBUS message (0x103)
I (14593) diybms: CAN STATUS: rx-q:0, tx-q:0, rx-err:0, tx-err:128, arb-lost:0, bus-err:14, state: OFF / RECOVERY NEEDED
W (14598) diybms: Initiating recovery
E (14601) diybms: Failed to queue CANBUS message (0x103)
I (14606) diybms: CAN STATUS: rx-q:0, tx-q:0, rx-err:0, tx-err:0, arb-lost:0, bus-err:14, state: STOPPED
I (14615) diybms: Starting CANBUS ESP_OK
W (14864) diybms-webfuncs: Incorrect cookie rec 5d*gLZjZyyDXVnXi2gF6
E (15720) diybms: Failed to queue CANBUS message (0x103)
I (15720) diybms: CAN STATUS: rx-q:0, tx-q:3, rx-err:0, tx-err:128, arb-lost:0, bus-err:14, state: OFF / RECOVERY NEEDED
W (15725) diybms: Initiating recovery

assert failed: twai_handle_tx_buffer_frame twai.c:183 (p_twai_obj->tx_msg_count >= 0)

Backtrace: 0x400841a1:0x3ffbf52c |<-CORRUPTED

ELF file SHA256: 31418cd666101b8d

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DOUT, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13232
load:0x40080400,len:3028
entry 0x400805e4
[    62][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
I (66) diybms: 

               _          __ 
  _|  o       |_)  |\/|  (_  
 (_|  |  \/   |_)  |  |  __)
         /

CONTROLLER - ver:9a0a3ed26f2dc973d3faf3e2799a6688da3ab13e compiled 2023-12-27T11:59:52.391Z
ESP32 Chip model = 1, Rev 1, Cores=2, Features=50
I (226) diybms-hal: Configure I2C
I (227) diybms-hal: Scanning i2c bus
I (231) diybms-hal: Found i2c device at address 0x21
I (240) diybms-hal: Found TCA6416A
I (243) diybms: ** Controller changed state from Unknown to PowerUp **
I (245) diybms-set: nvs_flash_init
I (251) diybms: LittleFS mounted, total=524288, used=139264
I (344) diybms: Mounting SD card
[   906][W][sd_diskio.cpp:104] sdWait(): Wait Failed
[   906][W][sd_diskio.cpp:512] ff_sd_initialize(): sdWait fail ignored, card initialize continues
[   908][W][sd_diskio.cpp:516] ff_sd_initialize(): GO_IDLE_STATE failed
[   915][E][sd_diskio.cpp:805] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[  1423][W][sd_diskio.cpp:104] sdWait(): Wait Failed
[  1423][E][sd_diskio.cpp:126] sdSelectCard(): Select Failed
E (1363) diybms-hal: Card mount failed

Press SPACE BAR to enter console WiFi configuration....

....................

No key press detected
I (6374) diybms-set: Load WIFI config from FLASH - return 1
I (6375) diybms-set: IP=0,GW=0
I (6375) diybms: Wifi Config: SSID:XXX, Manual Config:0
I (6378) diybms: Manual IP:0.0.0.0, Netmask:0.0.0.0, GW:0.0.0.0, DNS1:0.0.0.0, DNS2:0.0.0.0
I (6386) diybms-set: Load config
I (6389) diybms-set: Count: UsedEntries = (249), FreeEntries = (381), AllEntries = (630)
I (6425) diybms: homeassist_apikey=UsMI64fQVWqCGxbBB2vKajGv
I (6425) curmon: INA229 chip absent
I (6426) diybms: Onboard/internal current monitoring chip not installed
I (6430) diybms-hal: CAN driver installed.  Filter=0 Mask=4294967295
I (6435) diybms-hal: CAN driver started
D (6440) diybms: Setup RS485
D (6442) diybms: Configure RS485
I (6447) diybms: ** Controller changed state from PowerUp to Stabilizing **
D (6451) diybms: starting wifi_init_sta
I (6474) diybms: WIFI SSID: XXX
I (6550) diybms: Hostname: DIYBMS-00EC889C
D (6550) diybms: wifi_init_sta finished
I (6550) diybms: TFT screen is NOT installed
I (13600) diybms: WIFI_EVENT_STA_START
D (13700) diybms: total_free_byte=161052 total_allocated_byte=132712 largest_free_blk=110580 min_free_byte=159108 alloc_blk=360 free_blk=7 total_blk=367
I (14406) diybms: WIFI_EVENT_STA_CONNECTED channel=1, rssi=-55
I (14419) diybms: IP ADDRESS HAS CHANGED
I (14420) diybms: Request time from time.google.com
I (14421) diybms: Timezone=UTC0DST0
I (14422) diybms: The current date/time is: Sun Mar 24 15:46:18 2024
I (14454) diybms: You can access DIYBMS interface at http://DIYBMS-00EC889C.local or http://192.168.99.210
E (14594) diybms: Failed to queue CANBUS message (0x103)
I (14594) diybms: CAN STATUS: rx-q:0, tx-q:0, rx-err:0, tx-err:128, arb-lost:0, bus-err:14, state: OFF / RECOVERY NEEDED
W (14599) diybms: Initiating recovery
E (14602) diybms: Failed to queue CANBUS message (0x103)
I (14607) diybms: CAN STATUS: rx-q:0, tx-q:0, rx-err:0, tx-err:0, arb-lost:0, bus-err:14, state: STOPPED
I (14616) diybms: Starting CANBUS ESP_OK
W (14966) diybms-webfuncs: Incorrect cookie rec 5d*gLZjZyyDXVnXi2gF6
E (15721) diybms: Failed to queue CANBUS message (0x103)
I (15721) diybms: CAN STATUS: rx-q:0, tx-q:3, rx-err:0, tx-err:128, arb-lost:0, bus-err:14, state: OFF / RECOVERY NEEDED
W (15726) diybms: Initiating recovery

assert failed: twai_handle_tx_buffer_frame twai.c:183 (p_twai_obj->tx_msg_count >= 0)

Backtrace: 0x400841a1:0x3ffbf52c |<-CORRUPTED

I changed the firmware to an older one, suspecting that there might be some regression in the latest one. I loaded the version from 2023-03-29, after turning on CAN communication, the "CAN send error" counter started to increase, but the BMS did not restart, logs from the serial port below:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DOUT, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13104
load:0x40080400,len:3036
entry 0x400805e4
[     8][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
I (65) diybms: 

               _          __ 
  _|  o       |_)  |\/|  (_  
 (_|  |  \/   |_)  |  |  __)
         /

CONTROLLER - ver:4e72db94af375c391bad47b9b98507b3271b069d compiled 2023-03-29T08:22:59.136Z
ESP32 Chip model = 1, Rev 1, Cores=2, Features=50
I (80) diybms-hal: Configure I2C
I (82) diybms-hal: Scanning i2c bus
I (88) diybms-hal: Found i2c device at address 0x21
I (97) diybms-hal: Found TCA6416A
D (99) diybms-hal: Configure VSPI
I (101) diybms: ** Controller changed state from Unknown to PowerUp **
I (102) diybms-set: nvs_flash_init
I (106) diybms-hal: CAN driver installed.  Filter=1621098496 Mask=6291455
I (111) diybms-hal: CAN driver started
I (129) diybms: LittleFS mounted, total=524288, used=126976
I (267) diybms: Mounting SD card
I (267) diybms-hal: Mounting SD card
[   775][W][sd_diskio.cpp:104] sdWait(): Wait Failed
[   775][W][sd_diskio.cpp:512] ff_sd_initialize(): sdWait fail ignored, card initialize continues
[   778][W][sd_diskio.cpp:516] ff_sd_initialize(): GO_IDLE_STATE failed
[   784][E][sd_diskio.cpp:802] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[  1292][W][sd_diskio.cpp:104] sdWait(): Wait Failed
[  1292][E][sd_diskio.cpp:126] sdSelectCard(): Select Failed
E (1286) diybms-hal: Card mount failed

Press SPACE BAR to enter console WiFi configuration....

....................

No key press detected
I (6294) diybms-set: Load WIFI config
I (6296) diybms-set: Read key (SSID)
I (6296) diybms-set: Read key (PASS)
I (6296) diybms-set: Load config
I (6299) diybms-set: Count: UsedEntries = (229), FreeEntries = (401), AllEntries = (630)
I (6307) diybms-set: Read key (totalBanks)
I (6310) diybms-set: Read key (totalSeriesMod)
I (6315) diybms-set: Read key (baudRate)
I (6318) diybms-set: Read key (interpacketgap)
I (6323) diybms-set: Read key (rulevalue)
I (6327) diybms-set: Read key (rulehysteresis)
I (6331) diybms-set: Read key (rulerelaystate)
I (6335) diybms-set: Read key (rulerelaydef)
I (6339) diybms-set: Read key (relaytype)
I (6342) diybms-set: Read key (g_voltagehigh)
I (6346) diybms-set: Read key (g_voltagelow)
I (6350) diybms-set: Read key (BypassOverTemp)
I (6354) diybms-set: Read key (BypassThresmV)
I (6358) diybms-set: Read key (minutesTZ)
I (6362) diybms-set: Read key (daylight)
I (6366) diybms-set: Read key (logEnabled)
I (6370) diybms-set: Read key (logFreqSec)
I (6373) diybms-set: Read key (curMonEnabled)
I (6378) diybms-set: Read key (curMonMBAddress)
I (6382) diybms-set: Read key (curMonDevice)
I (6386) diybms-set: Read key (curMonshuntmv)
I (6390) diybms-set: Read key (curMonShtMaxCur)
I (6394) diybms-set: Read key (curMonBatCap)
I (6398) diybms-set: Read key (curMonFullChgV)
I (6402) diybms-set: Read key (curMonTailCur)
I (6406) diybms-set: Read key (curMonChargeEff)
I (6411) diybms-set: Read key (curMonShuntCal)
I (6415) diybms-set: Read key (curMontemplimit)
I (6419) diybms-set: Read key (curMonovervolt)
I (6423) diybms-set: Read key (curMonundervolt)
I (6427) diybms-set: Read key (curMonovercur)
I (6432) diybms-set: Read key (curMonundercur)
I (6436) diybms-set: Read key (curMonoverpower)
I (6440) diybms-set: Read key (curMontempcoef)
I (6444) diybms-set: Read key (curMonTempCompE)
I (6448) diybms-set: Read key (485baudrate)
I (6452) diybms-set: Read key (485databits)
I (6456) diybms-set: Read key (485parity)
I (6460) diybms-set: Read key (485stopbits)
I (6464) diybms-set: Read key (canbusprotocol)
W (6468) diybms-set: Key not initialized (nominalbatcap)
I (6473) diybms-set: Read key (cha_volt)
I (6477) diybms-set: Read key (cha_current)
I (6481) diybms-set: Read key (dis_current)
I (6484) diybms-set: Read key (dis_volt)
I (6488) diybms-set: Read key (cellminmv)
I (6492) diybms-set: Read key (cellmaxmv)
I (6496) diybms-set: Read key (kneemv)
I (6499) diybms-set: Read key (sensitivity)
I (6503) diybms-set: Read key (cur_val1)
I (6507) diybms-set: Read key (cur_val2)
I (6510) diybms-set: Read key (cellmaxspikemv)
I (6514) diybms-set: Read key (cha_templow)
I (6518) diybms-set: Read key (cha_temphigh)
I (6522) diybms-set: Read key (dis_templow)
I (6526) diybms-set: Read key (dis_temphigh)
I (6530) diybms-set: Read key (stopchargebal)
I (6534) diybms-set: Read key (socoverride)
I (6538) diybms-set: Read key (socforcelow)
I (6542) diybms-set: Read key (dynamiccharge)
I (6546) diybms-set: Read key (preventchar)
I (6550) diybms-set: Read key (preventdis)
I (6554) diybms-set: Read key (mqttenable)
I (6558) diybms-set: Read key (infenabled)
I (6562) diybms-set: Read key (inflogFreq)
I (6566) diybms-set: Read key (tileconfig)
I (6569) diybms-set: Read key (ntpServer)
I (6573) diybms-set: Read key (language)
I (6577) diybms-set: Read key (mqtt_uri)
I (6580) diybms-set: Read key (mqtt_topic)
I (6584) diybms-set: Read key (mqtt_usern)
I (6588) diybms-set: Read key (mqtt_pword)
I (6592) diybms-set: Read key (inf_serverurl)
I (6596) diybms-set: Read key (inf_bucket)
I (6600) diybms-set: Read key (inf_apitoken)
I (6604) diybms-set: Read key (inf_orgid)
I (6607) curmon: INA229 chip absent
I (6610) diybms: Onboard/internal current monitoring chip not installed
D (6618) diybms: Setup RS485
D (6620) diybms: Configure RS485
D (6623) diybms-hal: SetOutputState 0=153
D (6626) diybms-hal: SetOutputState 1=153
D (6630) diybms-hal: SetOutputState 2=153
D (6634) diybms-hal: SetOutputState 3=153
I (6637) diybms: ** Controller changed state from PowerUp to Stabilizing **
D (6644) diybms: starting wifi_init_sta
I (6666) diybms: WIFI SSID: XYZ
D (6706) diybms: tca6416a_isr
I (6773) diybms: Hostname: DIYBMS-003FD728
D (6773) diybms: wifi_init_sta finished
I (6773) diybms: TFT screen is NOT installed
D (6774) diybms: total_free_byte=166880 total_allocated_byte=120084 largest_free_blk=110580 min_free_byte=166576 alloc_blk=329 free_blk=5 total_blk=334
I (15449) diybms: Got ip:192.168.99.32
I (15450) diybms: Request time from time.google.com
I (15451) diybms: Timezone=UTC0DST0
I (15452) diybms: The current date/time is: Thu Jan  1 00:00:07 1970
I (15476) diybms: You can access DIYBMS interface at http://DIYBMS-003FD728.local or http://192.168.99.32
D (15567) diybms: Sent CAN message 0x351
E (15668) diybms: Fail to queue CANBUS message (0x103)
E (15669) diybms: Fail to queue CANBUS message (0x103)
E (15669) diybms: Fail to queue CANBUS message (0x103)
E (15672) diybms: Fail to queue CANBUS message (0x103)
E (15677) diybms: Fail to queue CANBUS message (0x103)
E (15682) diybms: Fail to queue CANBUS message (0x103)
W (16553) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (16787) diybms: Fail to queue CANBUS message (0x103)
E (16888) diybms: Fail to queue CANBUS message (0x103)
E (16888) diybms: Fail to queue CANBUS message (0x103)
E (16888) diybms: Fail to queue CANBUS message (0x103)
E (16891) diybms: Fail to queue CANBUS message (0x103)
E (16896) diybms: Fail to queue CANBUS message (0x103)
E (16901) diybms: Fail to queue CANBUS message (0x103)
I (17588) diybms-rules: Set error 4
E (18006) diybms: Fail to queue CANBUS message (0x103)
E (18106) diybms: Fail to queue CANBUS message (0x103)
E (18106) diybms: Fail to queue CANBUS message (0x103)
E (18106) diybms: Fail to queue CANBUS message (0x103)
E (18110) diybms: Fail to queue CANBUS message (0x103)
E (18114) diybms: Fail to queue CANBUS message (0x103)
E (18119) diybms: Fail to queue CANBUS message (0x103)
I (19179) diybms-rules: Set warning 9
I (19179) diybms-rules: Set warning 7
I (19180) diybms-rules: Set warning 8
I (19180) diybms: Active errors=1
E (19224) diybms: Fail to queue CANBUS message (0x103)
E (19324) diybms: Fail to queue CANBUS message (0x103)
E (19324) diybms: Fail to queue CANBUS message (0x103)
E (19324) diybms: Fail to queue CANBUS message (0x103)
E (19327) diybms: Fail to queue CANBUS message (0x103)
E (19332) diybms: Fail to queue CANBUS message (0x103)
E (19337) diybms: Fail to queue CANBUS message (0x103)
I (20070) diybms: Task 1
E (20442) diybms: Fail to queue CANBUS message (0x103)
E (20542) diybms: Fail to queue CANBUS message (0x103)
E (20542) diybms: Fail to queue CANBUS message (0x103)
E (20542) diybms: Fail to queue CANBUS message (0x103)
E (20545) diybms: Fail to queue CANBUS message (0x103)
E (20550) diybms: Fail to queue CANBUS message (0x103)
E (20555) diybms: Fail to queue CANBUS message (0x103)
E (21660) diybms: Fail to queue CANBUS message (0x103)
E (21760) diybms: Fail to queue CANBUS message (0x103)
E (21760) diybms: Fail to queue CANBUS message (0x103)
E (21760) diybms: Fail to queue CANBUS message (0x103)
E (21763) diybms: Fail to queue CANBUS message (0x103)
E (21768) diybms: Fail to queue CANBUS message (0x103)
E (21773) diybms: Fail to queue CANBUS message (0x103)
I (22181) diybms-rules: Set error 4
I (22182) diybms-rules: Set warning 9
I (22182) diybms-rules: Set warning 7
I (22182) diybms-rules: Set warning 8
I (22184) diybms: Active errors=1
E (22878) diybms: Fail to queue CANBUS message (0x103)
E (22978) diybms: Fail to queue CANBUS message (0x103)
E (22978) diybms: Fail to queue CANBUS message (0x103)
E (22978) diybms: Fail to queue CANBUS message (0x103)
E (22981) diybms: Fail to queue CANBUS message (0x103)
E (22986) diybms: Fail to queue CANBUS message (0x103)
E (22991) diybms: Fail to queue CANBUS message (0x103)
W (23529) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (24096) diybms: Fail to queue CANBUS message (0x103)
E (24196) diybms: Fail to queue CANBUS message (0x103)
E (24196) diybms: Fail to queue CANBUS message (0x103)
E (24196) diybms: Fail to queue CANBUS message (0x103)
E (24199) diybms: Fail to queue CANBUS message (0x103)
E (24204) diybms: Fail to queue CANBUS message (0x103)
E (24209) diybms: Fail to queue CANBUS message (0x103)
E (24567) diybms: CANBUS timeout
I (25187) diybms-rules: Set error 4
I (25188) diybms-rules: Set warning 9
I (25188) diybms-rules: Set warning 7
I (25188) diybms-rules: Set warning 8
I (25190) diybms: Active errors=1
E (25314) diybms: Fail to queue CANBUS message (0x103)
E (25414) diybms: Fail to queue CANBUS message (0x103)
E (25414) diybms: Fail to queue CANBUS message (0x103)
E (25414) diybms: Fail to queue CANBUS message (0x103)
E (25417) diybms: Fail to queue CANBUS message (0x103)
E (25422) diybms: Fail to queue CANBUS message (0x103)
E (25427) diybms: Fail to queue CANBUS message (0x103)
W (25564) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
I (25587) diybms: Task 2
E (26532) diybms: Fail to queue CANBUS message (0x103)
E (26632) diybms: Fail to queue CANBUS message (0x103)
E (26632) diybms: Fail to queue CANBUS message (0x103)
E (26632) diybms: Fail to queue CANBUS message (0x103)
E (26636) diybms: Fail to queue CANBUS message (0x103)
E (26640) diybms: Fail to queue CANBUS message (0x103)
E (26645) diybms: Fail to queue CANBUS message (0x103)
W (27595) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (27750) diybms: Fail to queue CANBUS message (0x103)
E (27850) diybms: Fail to queue CANBUS message (0x103)
E (27850) diybms: Fail to queue CANBUS message (0x103)
E (27850) diybms: Fail to queue CANBUS message (0x103)
E (27853) diybms: Fail to queue CANBUS message (0x103)
E (27858) diybms: Fail to queue CANBUS message (0x103)
E (27863) diybms: Fail to queue CANBUS message (0x103)
I (28193) diybms-rules: Set error 4
I (28194) diybms-rules: Set warning 9
I (28194) diybms-rules: Set warning 7
I (28194) diybms-rules: Set warning 8
I (28196) diybms: Active errors=1
E (28968) diybms: Fail to queue CANBUS message (0x103)
E (29068) diybms: Fail to queue CANBUS message (0x103)
E (29068) diybms: Fail to queue CANBUS message (0x103)
E (29068) diybms: Fail to queue CANBUS message (0x103)
E (29071) diybms: Fail to queue CANBUS message (0x103)
E (29076) diybms: Fail to queue CANBUS message (0x103)
E (29081) diybms: Fail to queue CANBUS message (0x103)
W (29622) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
D (29718) diybms: total_free_byte=147704 total_allocated_byte=137756 largest_free_blk=106484 min_free_byte=136280 alloc_blk=423 free_blk=10 total_blk=433
E (30186) diybms: Fail to queue CANBUS message (0x103)
E (30286) diybms: Fail to queue CANBUS message (0x103)
E (30286) diybms: Fail to queue CANBUS message (0x103)
E (30286) diybms: Fail to queue CANBUS message (0x103)
E (30289) diybms: Fail to queue CANBUS message (0x103)
E (30294) diybms: Fail to queue CANBUS message (0x103)
E (30299) diybms: Fail to queue CANBUS message (0x103)
D (31089) diybms: Task 3, s=0 e=0
I (31199) diybms-rules: Set error 4
I (31199) diybms-rules: Set warning 9
I (31200) diybms-rules: Set warning 7
I (31200) diybms-rules: Set warning 8
I (31202) diybms: Active errors=1
E (31404) diybms: Fail to queue CANBUS message (0x103)
E (31504) diybms: Fail to queue CANBUS message (0x103)
E (31504) diybms: Fail to queue CANBUS message (0x103)
E (31504) diybms: Fail to queue CANBUS message (0x103)
E (31507) diybms: Fail to queue CANBUS message (0x103)
E (31512) diybms: Fail to queue CANBUS message (0x103)
E (31517) diybms: Fail to queue CANBUS message (0x103)
W (31648) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (32622) diybms: Fail to queue CANBUS message (0x103)
E (32722) diybms: Fail to queue CANBUS message (0x103)
E (32722) diybms: Fail to queue CANBUS message (0x103)
E (32722) diybms: Fail to queue CANBUS message (0x103)
E (32725) diybms: Fail to queue CANBUS message (0x103)
E (32730) diybms: Fail to queue CANBUS message (0x103)
E (32735) diybms: Fail to queue CANBUS message (0x103)
W (33674) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (33840) diybms: Fail to queue CANBUS message (0x103)
E (33940) diybms: Fail to queue CANBUS message (0x103)
E (33940) diybms: Fail to queue CANBUS message (0x103)
E (33940) diybms: Fail to queue CANBUS message (0x103)
E (33943) diybms: Fail to queue CANBUS message (0x103)
E (33948) diybms: Fail to queue CANBUS message (0x103)
E (33953) diybms: Fail to queue CANBUS message (0x103)
I (34205) diybms-rules: Set error 4
I (34206) diybms-rules: Set warning 9
I (34206) diybms-rules: Set warning 7
I (34206) diybms-rules: Set warning 8
I (34208) diybms: Active errors=1
E (34567) diybms: CANBUS timeout
E (35058) diybms: Fail to queue CANBUS message (0x103)
E (35158) diybms: Fail to queue CANBUS message (0x103)
E (35158) diybms: Fail to queue CANBUS message (0x103)
E (35158) diybms: Fail to queue CANBUS message (0x103)
E (35161) diybms: Fail to queue CANBUS message (0x103)
E (35166) diybms: Fail to queue CANBUS message (0x103)
E (35171) diybms: Fail to queue CANBUS message (0x103)
W (35701) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (36276) diybms: Fail to queue CANBUS message (0x103)
E (36376) diybms: Fail to queue CANBUS message (0x103)
E (36376) diybms: Fail to queue CANBUS message (0x103)
E (36376) diybms: Fail to queue CANBUS message (0x103)
E (36379) diybms: Fail to queue CANBUS message (0x103)
E (36384) diybms: Fail to queue CANBUS message (0x103)
E (36389) diybms: Fail to queue CANBUS message (0x103)
I (37211) diybms-rules: Set error 4
I (37212) diybms-rules: Set warning 9
I (37212) diybms-rules: Set warning 7
I (37212) diybms-rules: Set warning 8
I (37214) diybms: Active errors=1
E (37494) diybms: Fail to queue CANBUS message (0x103)
E (37594) diybms: Fail to queue CANBUS message (0x103)
E (37594) diybms: Fail to queue CANBUS message (0x103)
E (37594) diybms: Fail to queue CANBUS message (0x103)
E (37597) diybms: Fail to queue CANBUS message (0x103)
E (37602) diybms: Fail to queue CANBUS message (0x103)
E (37607) diybms: Fail to queue CANBUS message (0x103)
W (37726) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (38712) diybms: Fail to queue CANBUS message (0x103)
E (38812) diybms: Fail to queue CANBUS message (0x103)
E (38812) diybms: Fail to queue CANBUS message (0x103)
E (38812) diybms: Fail to queue CANBUS message (0x103)
E (38815) diybms: Fail to queue CANBUS message (0x103)
E (38820) diybms: Fail to queue CANBUS message (0x103)
E (38825) diybms: Fail to queue CANBUS message (0x103)
W (39751) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (39930) diybms: Fail to queue CANBUS message (0x103)
E (40030) diybms: Fail to queue CANBUS message (0x103)
E (40030) diybms: Fail to queue CANBUS message (0x103)
E (40030) diybms: Fail to queue CANBUS message (0x103)
E (40033) diybms: Fail to queue CANBUS message (0x103)
E (40038) diybms: Fail to queue CANBUS message (0x103)
E (40043) diybms: Fail to queue CANBUS message (0x103)
I (40217) diybms-rules: Set error 4
I (40218) diybms-rules: Set warning 9
I (40218) diybms-rules: Set warning 7
I (40218) diybms-rules: Set warning 8
I (40220) diybms: Active errors=1
E (41148) diybms: Fail to queue CANBUS message (0x103)
E (41248) diybms: Fail to queue CANBUS message (0x103)
E (41248) diybms: Fail to queue CANBUS message (0x103)
E (41248) diybms: Fail to queue CANBUS message (0x103)
E (41251) diybms: Fail to queue CANBUS message (0x103)
E (41256) diybms: Fail to queue CANBUS message (0x103)
E (41261) diybms: Fail to queue CANBUS message (0x103)
W (41777) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
I (42091) diybms: Task 1
E (42366) diybms: Fail to queue CANBUS message (0x103)
E (42466) diybms: Fail to queue CANBUS message (0x103)
E (42466) diybms: Fail to queue CANBUS message (0x103)
E (42466) diybms: Fail to queue CANBUS message (0x103)
E (42469) diybms: Fail to queue CANBUS message (0x103)
E (42474) diybms: Fail to queue CANBUS message (0x103)
E (42479) diybms: Fail to queue CANBUS message (0x103)
I (43223) diybms-rules: Set error 4
I (43224) diybms-rules: Set warning 9
I (43224) diybms-rules: Set warning 7
I (43224) diybms-rules: Set warning 8
I (43226) diybms: Active errors=1
E (43584) diybms: Fail to queue CANBUS message (0x103)
E (43684) diybms: Fail to queue CANBUS message (0x103)
E (43684) diybms: Fail to queue CANBUS message (0x103)
E (43684) diybms: Fail to queue CANBUS message (0x103)
E (43687) diybms: Fail to queue CANBUS message (0x103)
E (43692) diybms: Fail to queue CANBUS message (0x103)
E (43697) diybms: Fail to queue CANBUS message (0x103)
W (43805) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (44567) diybms: CANBUS timeout
D (44719) diybms: total_free_byte=146136 total_allocated_byte=139212 largest_free_blk=106484 min_free_byte=134940 alloc_blk=430 free_blk=9 total_blk=439
E (44802) diybms: Fail to queue CANBUS message (0x103)
E (44902) diybms: Fail to queue CANBUS message (0x103)
E (44902) diybms: Fail to queue CANBUS message (0x103)
E (44902) diybms: Fail to queue CANBUS message (0x103)
E (44905) diybms: Fail to queue CANBUS message (0x103)
E (44910) diybms: Fail to queue CANBUS message (0x103)
E (44915) diybms: Fail to queue CANBUS message (0x103)
W (45831) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (46020) diybms: Fail to queue CANBUS message (0x103)
E (46120) diybms: Fail to queue CANBUS message (0x103)
E (46120) diybms: Fail to queue CANBUS message (0x103)
E (46120) diybms: Fail to queue CANBUS message (0x103)
E (46123) diybms: Fail to queue CANBUS message (0x103)
E (46128) diybms: Fail to queue CANBUS message (0x103)
E (46133) diybms: Fail to queue CANBUS message (0x103)
I (46229) diybms-rules: Set error 4
I (46229) diybms-rules: Set warning 9
I (46229) diybms-rules: Set warning 7
I (46229) diybms-rules: Set warning 8
I (46231) diybms: Active errors=1
E (47238) diybms: Fail to queue CANBUS message (0x103)
E (47338) diybms: Fail to queue CANBUS message (0x103)
E (47338) diybms: Fail to queue CANBUS message (0x103)
E (47338) diybms: Fail to queue CANBUS message (0x103)
E (47341) diybms: Fail to queue CANBUS message (0x103)
E (47346) diybms: Fail to queue CANBUS message (0x103)
E (47351) diybms: Fail to queue CANBUS message (0x103)
I (47595) diybms: Task 2
W (47892) diybms-webfuncs: Incorrect cookie rec QdIbLi78xhvaTtGitMv6
E (48456) diybms: Fail to queue CANBUS message (0x103)
E (48556) diybms: Fail to queue CANBUS message (0x103)
E (48556) diybms: Fail to queue CANBUS message (0x103)
E (48556) diybms: Fail to queue CANBUS message (0x103)
E (48559) diybms: Fail to queue CANBUS message (0x103)
E (48564) diybms: Fail to queue CANBUS message (0x103)
E (48569) diybms: Fail to queue CANBUS message (0x103)
I (49234) diybms-rules: Set error 4
I (49235) diybms-rules: Set warning 9
I (49235) diybms-rules: Set warning 7
I (49235) diybms-rules: Set warning 8
I (49237) diybms: Active errors=1
E (49674) diybms: Fail to queue CANBUS message (0x103)

I tried using the second and third controller boards and different ESP32 - it didn't change anything, still the same messages. I tried to look for some trace on the network, but I only found one to check the voltage level on PIN 8 of TJA1057GT/3J - in my case it was 0V regardless of whether CAN was turned on or off. I also decided to check the supply voltage for this system and it was 5.1V and for Vio 3.2V.

The 120 Ohm resistor is active (JP1 bridge soldered), the resistance between the terminal ends has been checked. Cerbo has a 120Ohm terminator. To make sure that the problem was not Cerbo, I checked using Sparkfun CANBUS Shield whether any packets were passing through. After connecting to Cerbo, you can see that Cerbo is sending packets and I am receiving them without any problems. I later connected to DIYBMS to the CAN terminals, but unfortunately there were no packets visible here and the CAN send error counter kept growing. I replaced the pins just in case, but it didn't change anything.

The CAN chip I have soldered (the entire assembly was done by JLCPCB) is NXP A1057G3 (CQSL4 Zn206).

I have no idea what could be wrong - I would be grateful for any tips on how to pursue the issue further.

stuartpittaway commented 6 months ago

Hello @brii999, thanks for trying out DIYBMS.

The CAN controller chip I use on the controller is SN65HVD1050D https://www.ti.com/lit/ds/symlink/sn65hvd1050.pdf

This chip operates at 5 volt and doesn't use pin 5 - its not connected on the PCB.

If you are using the TJA1057GT/3 then pin 5 is expected to be "VIO" - you might be able to make your chip work by connecting pin 5 to +5V (a wire soldered between pin 3 and pin 5 should do it).

Alternatively, swap out that CAN chip for the recommended SN65HVD1050D

brii999 commented 6 months ago

Thanks for reply. I tried with providing 5V supply for PIN5 of CAN controller with no luck. I ordered mentioned chip (SN65HVD1050D). When it arrives I'll solder it and provide update in this topic. Once again thanks for interesting in this problem.

brii999 commented 6 months ago

I soldered the recommended chip but it didn't change anything... I understand that there is nothing smart that can be done except checking whether the PCB has all trace continuity?

stuartpittaway commented 6 months ago

Its a fairly simple circuit - first check that your ESP32 is the correct pin layout (devkitc footprint).

After that, check the connection to these two chips at U1 and U7. U1 is tiny, so easy to cause solder bridging.

Also check that your CANBUS A/B wires are correct. You can also try without a ground wire between controller and charger/inverter.

image

brii999 commented 6 months ago

I have no TSX0102DCU chip - TXD and RXD of SN65HCD1050D goes stright to ESP32 board to pins: TXD (1) on SN65 to G16 on ESP32 (U2_RXD) RXD (4) on SN65 to G17 on ESP32 (U2_TXD) Revision of diyBMS V4.4 board is: c8f1403

atanisoft commented 6 months ago

If your PCB is this one, you should be able to use the TJA1057/3 chip by making sure JP5 is bridged to 5v. I've not used mine diyBMS boards for CAN but I do have extensive use of TJA1057/3 (and a few others) in the split voltage configuration without issues.

Also the error code 0x103 indicates that the TWAI/CAN driver is in an incorrect state for sending, this is usually due one of the following:

  1. CAN-RX and CAN-TX configured in reverse (unlikely).
  2. CAN-H and CAN-L reversed on one of the devices.
  3. Missing 120Ohm termination on BOTH ends of the CAN bus.

A very quick test for the third item, turn off all devices but leave the CAN bus connected on both ends. Set your multimeter to resistance testing and check for a 60Ohm resistance (roughly) between CAN-H and CAN-L. If you see 120Ohm then only one side is terminated and you might be able to fix this by soldering JP1. If you see a dead short between CAN-H and CAN-L check the soldering of the TJA1057/3 IC to make sure there isn't a stray bridge, you can see the traces are pretty much direct from U1 (TJA1057/3) through the center two pins on the right side (6 and 7) connecting to D8 (CAN TVS) and then to J7 CAN-H/CAN-L. CAN-H is on pin 7 of TJA1057/3 and is connected to R6 and D8 (top left) -> J7. CAN-L is routed to JP1 -> D8 (right side) -> J7.

brii999 commented 6 months ago

Thanks for reply in this topic.

On JP5 default 5V is selected. I mesaure voltage between GND and center pad of JP5 and it is 5V. On powered off board I checked with multimeter continuity test that there is connection between left and center pad. Right pad (3,3V) is not connected with center pad. There is connection betweend center pad of JP5 and third pin of TJA1057 chip.

  1. I wrote simple program in Arduino and put it on this ESP32 to print something on Serial2 (TX2, RX2) and after connecting to CP2102 i have communication on appropriate pins. So serial port works correctly.
  2. I tried both options of connection with the same result
  3. I've got solder blob on JP1 and resistor in plugs connected to sparkfun board. Resistance between lines is exactly 60,05Ohm (i'am not joking - its practical ideal).

I used osciloscope to check if something is transfered from ESP32 to TJA1057 chip and to my suprise I see only flat line on 3,3V level. I tried triggering on different options and nothing changed, osciloscope dont detect any signal changes on ESP32 TX pin (GPIO17) connected to TJA 4 pin (RX)...

I have no idea whats can be wrong...

UPDATE:

I test it now on my desk - controller only without modules connected. Fresh after firmware upload I 'am going to "More" and select "Charge/Discharge configuration" then I chang "CANBUS protocol emulation" to "Victron Cerbo GX" and use "generic" for "Inverter brand/model" and 500k for "CANBUS baud rate". Field "Enable dynamic charge control" is enabled and after I click "Save" I have still situation like on begining of this topic. Is it enough to provoke diyBMS controller to send any data to CAN interface?

stuartpittaway commented 6 months ago

I have no TSX0102DCU chip - TXD and RXD of SN65HCD1050D goes stright to ESP32 board to pins:

Sorry, my mistake, if you have the older PCB board, then the TJA chip is the correct one to use.

brii999 commented 5 months ago

A little udate: I took two controller boards and two ESP32, wrote small programs - one to send data over CAN, the other to receive. After connecting the controller boards, there is no communication.... After connecting the ESP32 directly without using the controller board, communication works.... Evidently the problem is in the controller board but I have no idea where to look further for the cause of the problem. All paths lead to the correct pins and have continuity. When choosing PylonTech instead of Victron, the errors are the same but at least I don't get a bootloop....

stuartpittaway commented 5 months ago

Just checking that the ESP32 you have is using the DEVKIT-C footprint? There are several different ESP32 footprint layouts and the pins would be incorrect if its not the DEVKIT-C one.

brii999 commented 5 months ago

I used ESP32-WROOM-32D (ESP32_DevkitC_V4) and now I ordered ESP-32S (both with 38 pins).

Could You recommend some ESP from this page?: https://allegro.pl/kategoria/plytki-drukowane-moduly-moduly-67363?string=esp32%20devkitc

stuartpittaway commented 5 months ago

Check your existing ESP32 pin out matches this one... https://components101.com/microcontrollers/esp32-devkitc

brii999 commented 5 months ago

I ordered another two different ESP32 Devkit C which has confirmed that UART2 is output on GPIO16 and GPIO17. Still the same result... I checked if PINs connected to controller board are connected to ESP32 module and they are connected proper PINs of module.

stuartpittaway commented 5 months ago

Is this the esp32S variant? That isn't the correct one, the wroom one is.

I'm not sure where to point you to now to fix this problem. I've built/used/sold a lot of the controller boards and I would have had a lot of complaints if they didn't work over canbus.

Is there any damage to the tracks on the PCB? Perhaps the can chip if damaged/faulty?