Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
CONTROLLER=stm8s105k6
SDCC=sdcc
STM8FLASH=stm8flash

MAIN=main.c
SRC=system.c systemtimer.c strings.c flash.c uart.c displays.c button.c encoder.c encoderbutton.c beep.c fan.c load.c adc.c ringbuffer.c
RELS=$(SRC:.c=.rel)
Expand All @@ -6,17 +10,25 @@ all: bin

bin: $(MAIN) $(RELS)
@mkdir -p bin
/home/dev/local/sdcc-3.6.0/bin/sdcc --std-c11 --opt-code-size -mstm8 -lstm8 $(MAIN) $(wildcard bin/*.rel) -o bin/
$(SDCC) --std-c11 --opt-code-size -mstm8 -lstm8 $(MAIN) $(wildcard bin/*.rel) -o bin/

.c.rel:
@mkdir -p bin
/home/dev/local/sdcc-3.6.0/bin/sdcc -c --std-c11 --opt-code-size -mstm8 -lstm8 $< -o bin/
$(SDCC) -c --std-c11 --opt-code-size -mstm8 -lstm8 $< -o bin/

clean:
@rm -rf bin

flash: bin
/home/dev/local/stm8flash/stm8flash -c stlinkv2 -p stm8s105k4 -w bin/main.ihx
#echo "0000ff00ff00ff00ff00ff00ff00ff" | xxd -r -p > misc/default_opt.bin
unlock:
$(STM8FLASH) -c stlinkv2 -p $(CONTROLLER) -s opt -w misc/default_opt.bin
#$(STM8FLASH) -c stlinkv2 -p $(CONTROLLER) -u # Works only in stm8flash versions after git commit f3f547b4

flash:
$(STM8FLASH) -c stlinkv2 -p $(CONTROLLER) -w bin/main.ihx

eeprom:
$(STM8FLASH) -c stlinkv2 -p $(CONTROLLER) -s eeprom -w misc/eeprom.bin

.SUFFIXES: .c .rel

Expand Down
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,40 @@ The load can be ordered from China (AliExpress, eBay etc), something like this o

![The electronic load](docs/1.jpg)

Added features:
* full control via UART
## Added features
* full control via UART (connected to pins T and R)
* calibration (via direct EEPROM programming)
* parameters (e.g. minimal current) are changable
* bootloader can be enabled

I would recommend to not program the chip in the device, because:
* then you cannot return to original firmware if you don't like this one
* it's STM8S**0**05K6T6C, that means you can one program it about 100 times
* you cannot user a simple USB-UART adapter to program it first time
## Programming
Programming the chip in the device has some drawbacks:
* you cannot return to original firmware if you don't like this one
* you cannot use a simple USB-UART adapter to program it first time

Take rather a new (empty) STM8S**1**05K4T6C or STM8S**1**05K6T6C and solder it.
Also the datasheet claims a write endurance of only 100 flash cycles but this is probably only for marketing purposes as it [contains the same die](https://hackaday.io/project/16097-eforth-for-cheap-stm8s-gadgets/log/76731-stm8l001j3-a-new-sop8-chip-and-the-limits-of-stm8flash) as the STM8S105 which is rated for 10000 cycles.

Programmer connection:
### Programmer connection
Connect an STLink V2 to the pins at the bottom of the board:

![Programmer connection](docs/2.jpg)

[Analog part schematic](http://www.voltlog.com/pub/dummy-load-sch.pdf) (one correction: PB3 is connected to +12V via 20k).
### Flashing
If you are using the chip which is already on the board you first have to unlock it via

make unlock

Then you write the new firmware with

make flash

and if you are flashing for the first time you also have to program the EEPROM:

make eeprom


[Analog part schematic](http://www.voltlog.com/pub/dummy-load-sch.pdf) (corrections: PB3 is connected to +12V via 20k, R27 is 510 Ohm).
[Full schematic](https://github.com/ArduinoHannover/ZPB30A1_Firmware/raw/master/hardware/schematic.pdf) (one correction: polarity of D6 is reversed).

Calibration values in the code are for my instance, may be you have to adjust them for your one.