Skip to content

Instantly share code, notes, and snippets.

@dirksan28
Last active January 5, 2023 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dirksan28/4671db81ac1009e13b50d0cd0259570e to your computer and use it in GitHub Desktop.
Save dirksan28/4671db81ac1009e13b50d0cd0259570e to your computer and use it in GitHub Desktop.
Custom Firmware for Electronic load ZPB30A1 (60W)

HowTo Update the Firmware of the Electronic load ZPB30A1 (60W)

FwUpdateDone

Motivation

  • new operation modes:
    • CC: Constant current
    • CR: Constant resistance
    • CP: Constant power
    • CV: Constant voltage (slow regulation due to hardware limitations)
  • Easily usable menu system with many configuration options
  • Logging and remote control of all operating parameters via UART.
  • Much better accuracy than stock firmware.
  • Clean firmware structure for easy extendability.

See https://github.com/herm/ZPB30A1_Firmware for more details regarding the custom firmware.

Preparation

Make sure you have GIT installed

sudo apt install git

Install the compiler

sudo apt install sdcc

Install the stm-flash-tool

sudo apt install libusb-1.0-0-dev pkg-config build-essentials
git clone https://github.com/vdudouyt/stm8flash.git

At least for ubuntu 22.04 you have to patch pgm.h in order to find libusb.h (vdudouyt/stm8flash#100):

#if defined(WIN32) || defined(__CYGWIN__)
 #include <libusb-1.0/libusb.h>
#else
 #include </usr/include/libusb-1.0/libusb.h>
#endif

then build and install the stm-flash-tool

make
sudo make install

for an stlink v2 mini programmer (as used bellow) put

# stm32 discovery boards, with onboard st/linkv2
# ie, STM32L, STM32F4.

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", \
    MODE="660", GROUP="plugdev", TAG+="uaccess", \
    SYMLINK+="stlinkv2_%n"

to /etc/udev/rules.d/ as 49-stlinkv2.rules then do a

sudo udevadm control --reload-rules && sudo udevadm trigger

Build the new firmware

There are many forks of https://github.com/ArduinoHannover/ZPB30A1_Firmware on github. I found this one to be the most recent and well maintained: https://github.com/herm/ZPB30A1_Firmware.git

For V2.8 PCBs

git clone https://github.com/herm/ZPB30A1_Firmware.git
cd software
make

Hint: The fork https://github.com/neonll/ZPB30A1_Firmware has V2.9 support (but untested because it does not work with my 2.8 board)

Connect the programmer

Board

TopView

ST-LINK/V2 Clone

The cheapest alternative to both official ST options is a Chinese ST-LINK/V2 clone. This clone offers the same connectivity when it comes to SWD. It does not expose a full JTAG interface. However, it does feature some additional power pins, both +5V and +3.3V. This debugger has a 10-pin IDC connector. The pinout of this connector can be found below. ST-LINK_V2_Clone_Header

(from https://stm32-base.org/guides/connecting-your-debugger.html)

ST-LINK/V2 Clone Pin ZPB30A1 pin
1 RST 2 NRST
2 GND 1 GND
3 SWIM 3 SWIM
5 5V 4 +5V

Flashing

  • remove 7-Segment daughter board, don't power the board via 12V connector!
cd ZPB30A1_Firmware/software
make flash
make clear_eeprom

  • remove the programmer,
  • put the 7-segment board back again
  • and power up the el. load

MCU

  • Either you replace the installed STM8S005 MCU with an new STM8S105 Which is the preferred way because you can go back to the original firmware when ever you want.

  • Or you go with the existing one - but you have to clear it in order to flash your fresh compiled firmware...

ZPB30A1_Firmware/software$ make unlock

Warning: This irreversibly deletes the original firmware.

Serial connection

stty -F /dev/ttyUSB0 115200  raw -clocal -echo
cat /dev/ttyUSB0 

VAL: D 1 T 191 Vi    44 Vl   101 Vs     0 I     0 mWs          0 mAs          0 
VAL: D 1 T 191 Vi    44 Vl   101 Vs     0 I     0 mWs          0 mAs          0 
...

more to be come ;-)

More infos about the electronic load:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment