DS2436 battery chip programming (reset counter, read/write eeprom)

Interesting examples and tutorials about REVELPROG-IS features and device programming
ArT
Posts: 1497
Joined: Wed Mar 25, 2015 8:54 am
Location: Warsaw, Poland
Has thanked: 51 times
Been thanked: 160 times

DS2436 battery chip programming (reset counter, read/write eeprom)

Postby ArT » Tue Feb 12, 2019 12:24 pm

REVELPROG-IS since v1.8.1 will be supporting DS2436 Battery ID/Monitor Chip with 1-Wire interface and custom scripts tool.

DS2346 is 1-wire device with 64-bit unique ID, 2-byte battery cycle counter, A/D converter for battery monitoring (voltage & temperature) and 32 bytes eeprom for user data.

Connection requires 3 wires:
- ground (pin 4 in programmer),
- data line (pin 5 in programmer),
- vdd (pin 8 in programmer)

Below are ready to use scripts for REVELPROG-IS.
You can read more about Custom Scripts Programming here: viewtopic.php?f=22&t=280

DS2436 Read EEPROM (5 pages, 32 bytes per page = 160 bytes total*)

Code: Select all

#SCRIPT HEADER;
SCRIPT:v1.8.1;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

// PAGE 1 read (24 EEPROM bytes + 8 dummy bytes)
#OPERATION;
SW:0,0,0,0,0,0,0,0,0,500;
INSTR:CC, 71; // SKIP ROM + COPY NV1 to SP1
#OPERATION;
SW:0,0,1,31,0,0,0,0,0,500;
INSTR:CC, 11, 00; // SKIP ROM + READ SCRATCHPAD + SP1 ADDR

// PAGE 2 read (8 EEPROM bytes + 24 dummy bytes)
#OPERATION;
SW:0,0,0,0,0,0,0,0,0,500;
INSTR:CC, 77; // SKIP ROM + COPY NV2 to SP2
#OPERATION;
SW:0,0,1,31,0,0,0,0,0,500;
INSTR:CC, 11, 20; // SKIP ROM + READ SCRATCHPAD + SP2 ADDR

// PAGE 3 read (8 SRAM bytes + 24 dummy bytes)
#OPERATION;
SW:0,0,0,0,0,0,0,0,0,500;
INSTR:CC, 7A; // SKIP ROM + COPY SRAM to SP3
#OPERATION;
SW:0,0,1,31,0,0,0,0,0,500;
INSTR:CC, 11, 40; // SKIP ROM + READ SCRATCHPAD + ADDR

// PAGE 4 read
#OPERATION;
SW:0,0,1,31,0,0,0,0,0,500;
INSTR:CC, B2, 60; // SKIP ROM + READ REGISTERS + REG. START. ADDR

// PAGE 5 read
#OPERATION;
SW:0,0,1,31,0,0,0,0,0,500;
INSTR:CC, B2, 80; // SKIP ROM + READ REGISTERS + REG. START. ADDR

* there are dummy bytes, please check datasheet which bytes are valid and which can be changed

ds2436_programming.jpg
ds2436_programming.jpg (74.01 KiB) Viewed 13990 times


DS2436 Read 64-bit unique ID

Code: Select all

#SCRIPT HEADER;
SCRIPT:v1.8.1;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

#OPERATION;
SW:0,0,1,7,0,0,0,0,0,500;
INSTR:33;


DS2436 Write EEPROM (2 pages: SP1 and SP2 = 24 + 8 = 32 bytes of user data)
- hard coded data in script

Code: Select all

#SCRIPT HEADER;
SCRIPT:v1.8.1;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

// Unlock NV1
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR:CC, 44; // SKIP ROM + Unlock NV1

// PAGE1 Write EEPROM (24 bytes)
#OPERATION;
SW:1,23,0,0,0,0,0,0,0,500;
INSTR:CC, 17, 00; // SKIP ROM + WRITE SCRATCHPAD + SP1 address
DATA: 11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,11,22,33,44,55,66,77,88,99,AA;
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR:CC, 22; // SKIP ROM + Copy SP1 to NV1

// PAGE2 Write EEPROM (8 bytes)
#OPERATION;
SW:1,7,0,0,0,0,0,0,0,500;
INSTR:CC, 17, 20; // SKIP ROM + WRITE SCRATCHPAD + SP2 address
DATA: 11,22,33,44,55,66,77,88;
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR:CC, 25; // SKIP ROM + Copy SP2 to NV2


DS2436 Write EEPROM (2 pages: SP1 and SP2 = 24 + 8 = 32 bytes of user data)
- data from buffer (since v1.8.5 only)

Code: Select all

//DS2436 WRITE EEPROM (using current data in buffer)

#SCRIPT HEADER;
SCRIPT:v1.8.5;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

// Unlock NV1
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR:CC, 44; // SKIP ROM + Unlock NV1

// PAGE1 Write EEPROM (24 bytes)
#OPERATION;
SW:1,23,0,0,0,0,0,0,0,500;
INSTR:CC, 17, 00; // SKIP ROM + WRITE SCRATCHPAD + SP1 address
DATA: BUFFER, 0;
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR:CC, 22; // SKIP ROM + Copy SP1 to NV1

// PAGE2 Write EEPROM (8 bytes)
#OPERATION;
SW:1,7,0,0,0,0,0,0,0,500;
INSTR:CC, 17, 20; // SKIP ROM + WRITE SCRATCHPAD + SP2 address
DATA: BUFFER, 20;
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR:CC, 25; // SKIP ROM + Copy SP2 to NV2


DS2436 Reset Battery Cycle Counter

Code: Select all

#SCRIPT HEADER;
SCRIPT:v1.8.1;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

// Reset cycle counter
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR: CC, B8; // SKIP ROM + Reset cycle counter (=0)


DS2436 Increment Cycle Counter

Code: Select all

#SCRIPT HEADER;
SCRIPT:v1.8.1;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

// Increment cycle counter
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR: CC, B5; // SKIP ROM + Inrement cycle counter (+1)


DS2436 Read Cycle Counter

Code: Select all

#SCRIPT HEADER;
SCRIPT:v1.8.1;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

// Read cycle counter
#OPERATION;
SW:0,0,1,1,0,0,0,0,0,500;
INSTR:CC, B2, 82; // SKIP ROM + READ Cycle counter register



DS2436 Read Battery Temperature (with A/D conversion at first step)

Code: Select all

#SCRIPT HEADER;
SCRIPT:v1.8.1;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

// Start A/D conversion for temperature
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR: CC, D2; // SKIP ROM + Convert T

// Read Temperature
#OPERATION;
SW:0,0,1,1,0,0,0,0,0,500;
INSTR:CC, B2, 60; // SKIP ROM + READ Temperature Register


DS2436 Read Battery Voltage (with A/D conversion at first step)

Code: Select all

#SCRIPT HEADER;
SCRIPT:v1.8.1;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

// Convert Voltage
#OPERATION;
SW:0,0,0,0,0,0,0,10,0,500;
INSTR: CC, B4; // SKIP ROM + Convert V

// Read Voltage
#OPERATION;
SW:0,0,1,1,0,0,0,0,0,500;
INSTR:CC, B2, 77; // SKIP ROM + READ Voltage Register


ds2436_read_eeprom_log.jpg
ds2436_read_eeprom_log.jpg (21.17 KiB) Viewed 13990 times

ArT
Posts: 1497
Joined: Wed Mar 25, 2015 8:54 am
Location: Warsaw, Poland
Has thanked: 51 times
Been thanked: 160 times

Re: DS2436 battery chip programming (reset counter, read/write eeprom)

Postby ArT » Tue Jun 22, 2021 11:25 am

I added new write eeprom script for DS2436 in first post. It's implementing v1.8.5 new feature "BUFFER" in custom script tool - there is no necessary to hard code write data in script - now it can be imported from buffer during script execution, more info: viewtopic.php?f=32&t=280&start=10#p3657

I added also tutorial for older DS2434 chip - you can find it here: viewtopic.php?f=32&t=897

Do you need to programm other 1-wire device? Please let me know, maybe I can help you and write a script for it :)


Return to “Tutorials and Examples”

Who is online

Users browsing this forum: No registered users and 7 guests

cron