stuartpittaway / diyBMSv4Code

Software for diyBMS v4
Other
145 stars 66 forks source link

Programming Module V4.5 #133

Closed Solarbot closed 1 year ago

Solarbot commented 1 year ago

Would it be possible to include information on programming the latest V4.5 module which doesn't have an ISP header? Many thanks.

atanisoft commented 1 year ago

I believe it is the same process as the external current shunt with UPDI.

stuartpittaway commented 1 year ago

Hi @Solarbot its an UPDI protocol.

You can program these boards using a simple USB to Serial adapter like the FT232. This is the documentation for it.

https://github.com/SpenceKonde/AVR-Guidance/blob/master/UPDI/jtag2updi.md

Solarbot commented 1 year ago

Hi both, thanks for responding.

I've looked up UPDI programming which seems pretty neat - am I correct in thinking that the V4.5 module cannot therefore be programmed by the DIYBMS controller? If so, may I ask if I need to compile and upload or is there a precompiled version availble? Also, happy to say the ATTINY seems to be avaible once more :-)

stuartpittaway commented 1 year ago

am I correct in thinking that the V4.5 module cannot therefore be programmed by the DIYBMS controller?

Unfortunately - you are correct, it cannot be programmed using the controller.

There is a pre-compiled code in the release https://github.com/stuartpittaway/diyBMSv4ESP32/releases

Take a look in the modules/HEX folder for these files - use the one for 5K or 10K speed as required. image

Solarbot commented 1 year ago

Thanks Stuart, appreciated.

Is there handy guide/workflow showing how to upload the HEX to the V4.5 module including what the 5K and 10K speed refers to :-)

stuartpittaway commented 1 year ago

No guide on this one I'm afraid - use the 5K if you are starting out - it refers to the communication speed between the modules and controller.

Do some google searching on UPDI programming - its quite simple, but a lot do struggle with it.

Solarbot commented 1 year ago

The advantage of working it out for myself is that new stuff gets learnt :-)

Thanks for the pointers šŸ‘

Cheers

atanisoft commented 1 year ago

@stuartpittaway https://github.com/adafruit/Adafruit_AVRProg or https://gitlab.com/bradanlane/portaprog/-/tree/master/ might provide the functionality. I didn't have much luck with Adafruit_AVRProg on a standalone ESP32 setup, but portaprog might be usable. The key will be disabling all other functionality of the BMS during flashing to maximize the time allotted to UART interaction.

Solarbot commented 1 year ago

Hi Stuart,

Iā€™m just looking at this again and found BitLuniā€™s guide to using an Arduino to upload using UPDI along with ATtinyCore by SpenceKonde which looks like a nice option, links below.

I havenā€™t had any luck as yet using your files on github all saved in one folder with the file main.cpp saved as an ā€˜inoā€™ file. I donā€™t have an option to select 2MHZ as the clock speed for the MCU selected as ATTINY841 (no bootloader) and get the compile error below.

Am I barking up the wrong tree? Iā€™ve also looked at using an FTDI serial board and XLOADER but there is no option to select ATTINY841 as the MCU.

A bit stuckā€¦ any pointers much appreciated.

Cheers,

Cam

https://www.youtube.com/watch?v=AL9vK_xMt4E https://www.youtube.com/watch?v=AL9vK_xMt4E&t=463s &t=463s

https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/Installation.md

Compile error:

In file included from C:\Users\Me\Documents\Arduino\DIYBMS45\main.cpp:46:0:

diybms_attiny841.h:18:2: error: #error Processor speed should be 2Mhz

error Processor speed should be 2Mhz

^~~~~

main.cpp:49:2: error: #error Expected DIYBMSBAUD define

error Expected DIYBMSBAUD define

^~~~~

main.cpp:53:2: error: #error Expected SAMPLEAVERAGING define

error Expected SAMPLEAVERAGING define

^~~~~

In file included from C:\Users\Me\Documents\Arduino\DIYBMS45\main.cpp:57:0:

defines.h:15:10: fatal error: EmbeddedFiles_Defines.h: No such file or directory

include "EmbeddedFiles_Defines.h"

      ^~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

exit status 1

error Processor speed should be 2Mhz

From: Stuart Pittaway @.> Sent: Friday, March 24, 2023 10:08 AM To: stuartpittaway/diyBMSv4Code @.> Cc: Solarbot @.>; Mention @.> Subject: Re: [stuartpittaway/diyBMSv4Code] Programming Module V4.5 (Issue #133)

No guide on this one I'm afraid - use the 5K if you are starting out - it refers to the communication speed between the modules and controller.

Do some google searching on UPDI programming - its quite simple, but a lot do struggle with it.

ā€” Reply to this email directly, view it on GitHub https://github.com/stuartpittaway/diyBMSv4Code/issues/133#issuecomment-1482550489 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AX23XXYMZQKW5WM6OHLAX7LW5VW6HANCNFSM6AAAAAAWFLMDVE . You are receiving this because you were mentioned. https://github.com/notifications/beacon/AX23XXZJJSOUD6PUNAB3VWTW5VW6HA5CNFSM6AAAAAAWFLMDVGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSYLXWNS.gif Message ID: @. @.> >

stuartpittaway commented 1 year ago

Hi @Solarbot

Use the pre-compiled firmware/code directly from GITHUB Releases.

Additionally, use a simple USB Serial adapter as an UPDI programmer, you don't need anything fancy, diode and couple of resistors. https://github.com/SpenceKonde/AVR-Guidance/blob/master/UPDI/jtag2updi.md#serial-adapter-requirements

After this, AVRDUDE command line tool will program the chips

Alternatively, you can use a spare Arduino Uno like in this guide - https://daumemo.com/diy-updi-usb-programmer-which-can-be-made-with-cheap-hardware/

And finally, another option is to use the Microchip python code... https://github.com/microchip-pic-avr-tools/pymcuprog

Solarbot commented 1 year ago

Hi Stuart,

Perfect, thank you ā€“ AVRDUDESS proved to be the key for me in the end.

Much appreciated as is all your work ā€“ Iā€™m slowly working towards building a battery but at the rate Iā€™m going you will have a whole new ecosystem up and running by then :-)

Cheers.

From: Stuart Pittaway @.> Sent: Tuesday, October 17, 2023 9:43 AM To: stuartpittaway/diyBMSv4Code @.> Cc: Solarbot @.>; Mention @.> Subject: Re: [stuartpittaway/diyBMSv4Code] Programming Module V4.5 (Issue #133)

Hi @Solarbot https://github.com/Solarbot

Use the pre-compiled firmware/code directly from GITHUB Releases.

Additionally, use a simple USB Serial adapter as an UPDI programmer, you don't need anything fancy, diode and couple of resistors. https://github.com/SpenceKonde/AVR-Guidance/blob/master/UPDI/jtag2updi.md#serial-adapter-requirements

After this, AVRDUDE command line tool will program the chips

Alternatively, you can use a spare Arduino Uno like in this guide - https://daumemo.com/diy-updi-usb-programmer-which-can-be-made-with-cheap-hardware/

And finally, another option is to use the Microchip python code... https://github.com/microchip-pic-avr-tools/pymcuprog

ā€” Reply to this email directly, view it on GitHub https://github.com/stuartpittaway/diyBMSv4Code/issues/133#issuecomment-1765950525 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AX23XX634GBNXN5HGU4DEZ3X7ZAIPAVCNFSM6AAAAAAWFLMDVGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRVHE2TANJSGU . You are receiving this because you were mentioned. https://github.com/notifications/beacon/AX23XX3DRZ3TV7O6PP2OWEDX7ZAIPA5CNFSM6AAAAAAWFLMDVGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTJIJCD2.gif Message ID: @. @.> >