DIYBMS v4

Those devices are not programmers for the ATTiny841. You need a dedicated usbASP programmer such as this one. 10Pin to 6Pin STK500 USBASP AVR Programmer Adapter Board USB Adapter Fit Arduino | eBay or something similar. You also need a cable that has a 6 pin connection.

No problem! Glad to share my troubles, itā€™s absolutely driving me bonkers lol.

Ok so I made new power cables
From this, (maybe 26awg)


To this (18awg)

But it didnā€™t change anythingā€¦
I measured each cell and updated the modules accordingly, so the modules would display closely to what I physically measured., but once again it cuts out.

Indeed the modules do reset, constantly, maybe every 20 or 30 seconds, but only under charging conditions. I thought maybe the controller might be causing the reset so I removed it from the equation, all the modules still resetā€¦ All at the same timeā€¦

Also just as a point of interest, I set all of the modules to bypass at 3.9v, all came on and discharged properly (took a few hours) . There were a couple anomalies in the values on a couple modules for example at just under 4 volts, it would go into bypass, voltage would drop to 3.6v ish, but when bypass turned off the voltage would spike to 4.3v, It wasnā€™t consistantly like that, just randomly at timesā€¦

Oh and I lost another module during my last recharge testā€¦ Reading 0 volts in the web interfaceā€¦ So thatā€™s 3 lol

Sorry for asking, is it possible to flash the ATtiny with the ArduinoISP or do I need a USBasp?

That reset is crazy, did you start charging at that point?

When you program the modules using platformio does it report the fuse settings as:

avrdude: safemode: Fuses OK (E:FE, H:D6, L:E2)

No need to be sorry! Yes the ArduinoISP can be used to program the ATTINY chips.

1 Like

Just for info. Iā€™ve split the main repo on github today.

The circuit is at the original repo location
diyBMSv4

and the code is now here
diyBMSv4Code

Iā€™ve also updated the controller to use the latest versions of JQuery and the graph library.

Also minor changes:

  • The controller is now configured to use 15mbyte of its 16mbyte flash as storage for SPIFF data (this will likely mean you will need to re-enter the WIFI details when programming for first time)
  • The cell modules now use the BLUE led when triggered from the watchdog timer (double flash). The GREEN led is only used to indicate a packet of data being received and processed by that module.
  • When programming the modules ensure platformio reports fuse configuration as
    avrdude: safemode: Fuses OK (E:F4, H:D6, L:E2)

Charger was running when that happens. When I first turn the charger on everything looks ok then the reseting begins, probably around the same cycle time about 20-30 seconds.

I do remember seeing the fuses being ok when I programmed, but I will double check.

Thank you for reply. I have been trying for some time to get avrdude to work with my arduino. Unfortunately without success so far. Can you give me a hint how the parameters should look like?

Take a look here

Okay, if you get chance please flash the latest code to the modules and controller.

re-flashing now,

avrdude: verifying ā€¦
avrdude: 7644 bytes of flash verified

avrdude: safemode: hfuse reads as D6
avrdude: safemode: efuse reads as F4
avrdude: safemode: Fuses OK (E:F4, H:D6, L:E2)

avrdude done. Thank you.

everything seems to be good in regards to the reflashing

I modified the platformio.ini file to allow selecting for the type of programmer your using, usbasp or arduino uno.

if you are using the arduino uno as isp you also need to set your comport. i tried to just upload the file but is not an allowed type to upload. anyways just cut and replace what is in the platformio.ini file. also I put the wiring information for the uno to bms module 6 pin header

default_envs = attiny841 ; uncomment if using usbasp for programming
;default_envs = attiny841_ARDUINOISP ; uncomment if using arduino uno as isp
comport = COM5 ; ** USED FOR ARDUINO ISP, Change this to the comport YOUR arduino uno is on

I have tested with my arduino uno, but not the usbasp device, so if someone could do that and let me know if it programmed as expected, then maybe Stuart can incorporate into published source.

; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; Redirecting...
;
[platformio]
; options set default_envs to
; ā€œattiny841ā€ if using a usb programmer
; ā€œattiny841_ARDUINOISPā€ if using an Arduino as isp
;
;***** ONLY CHANGE HERE ******
;
default_envs = attiny841 ; uncomment if using usbasp for programming
;
;default_envs = attiny841_ARDUINOISP ; uncomment if using arduino uno as isp
;
comport = COM5 ; ** USED FOR ARDUINO ISP, Change this to the comport YOUR arduino uno is on
;
;*****************************
;
; if using an arduino uno as isp the following is the wire connections
; bms module - PIN 1 (MISO) ā†’ Arduino Uno - PIN 12
; bms module - PIN 2 (5V) ā†’ Arduino Uno - 5V
; bms module - PIN 3 (SCK) ā†’ Arduino Uno - PIN 13
; bms module - PIN 4 (MOSI) ā†’ Arduino Uno - PIN 11
; bms module - PIN 5 (RESET) ā†’ Arduino Uno - PIN 10
; bms module - PIN 6 (GND) ā†’ Arduino Uno - GND
;
;
[common_env_data] ; common environment data
upload_flags =
-vv
-Uefuse:w:0b11110100:m
-Uhfuse:w:0b11010110:m
-Ulfuse:w:0b11100010:m
;
lib_deps =
GitHub - bakercp/PacketSerial: An Arduino Library that facilitates packet-based serial communication using COBS or SLIP encoding.
GitHub - mike-matera/FastPID: A fast, integer based PID controller suitable for Arduino.
;
;//==========================================================================
[env:attiny841] ; build parameters when using ā€œUSBASPā€ programmer
platform = atmelavr
board = attiny841
framework = arduino
;
board_build.f_cpu = 8000000L
board_build.core = tinymodern
;
lib_deps =
${common_env_data.lib_deps}
;
upload_protocol = usbasp
;
; efuse = 1111 0100 = Enables SPM instruction
; hfuse = 1101 0110 = EESAVE & 1.8V BOD detection level
; lfuse = 1110 0010 = CKDIV8 & Calibrated Internal 8MHz Oscillator
;
; E2
board_fuses.lfuse = 0b11100010
; D6
board_fuses.hfuse = 0b11010110
; F4
board_fuses.efuse = 0b11110100
;
; each flag in a new line
;-B16 option needed for my USBASP programmer to slow it down!
upload_flags =
${common_env_data.upload_flags}
-B16
-Pusb
;
;//==========================================================================
;
;//==========================================================================
[env:attiny841_ARDUINOISP] ; build parameter when using arduino as isp
platform = atmelavr
board = attiny841
framework = arduino
;
board_build.f_cpu = 8000000L
board_build.core = tinymodern
;
lib_deps =
${common_env_data.lib_deps}
;
upload_protocol = stk500v1
;
upload_port = ${platformio.comport}
upload_speed = 19200
;
; efuse = 1111 0100 = Enables SPM instruction
; hfuse = 1101 0110 = EESAVE & 1.8V BOD detection level
; lfuse = 1110 0010 = CKDIV8 & Calibrated Internal 8MHz Oscillator
;
; E2
board_fuses.lfuse = 0b11100010
; D6
board_fuses.hfuse = 0b11010110
; F4
board_fuses.efuse = 0b11110100
;
; each flag in a new line
upload_flags =
${common_env_data.upload_flags}
-P$UPLOAD_PORT
-b$UPLOAD_SPEED
;
;//==========================================================================

1 Like

Does the board_fuses.lfuse setting work for you? Iā€™ve just reverted that change in master branch

Klaus,

What settings are you using for your modules?

4000mv for bypass threshold (each cell)? And what is your charger set to? You must have set the voltage limit for the charger, 28v? And do you know if your charger (Iā€™m assuming solar charge controller) is capable of constant current and constant voltage for lipo cells? Or is it changing to a float charge after the bulk absorption phase? Basically as the target voltage is reached the current is reduced to maintain the voltage.

The platformio.ini file i posted above works for me (All fuses set correctly), its a bit hard to understand at first glance, but the ā€œcommonā€ upload flags are in the common_env_data near the top, and they are applied during build/upload along with the flags required for the each programmer type.

@Havinfun you still have the ā€œ-Uefuse:w:0b11110100:mā€ parameter being passed to AVRDUDE when programming which is why the fuse programming is okay.

If you remove this and just keep the platformio board_fuses section it doesnā€™t seem to work.

If looks like a nice clean install you have @Havinfun.

Just to breakdown the technical elements to this:

  1. The controller and each module are electrically isolated from each other via the optoisolators so that canā€™t trigger a reset as seen
  2. Each module is connected to its own power supply (ie. the cell) so what happens in another cell shouldnā€™t be able to affect the module

All I can assume is that there is a sudden low or high voltage across the entire pack which is causing the modules to reset or brown out at the same time - either way, very unusual.

If I remove that the board does not work. I noticed you had both in the updated code so I thought maybe I had done something wrong, so I left ā€œbothā€ entries in and it worked fine.

No problem with that. Are you still getting all the modules restarting when charging ?