Cos'è ElectroYou | Login Iscriviti

ElectroYou - la comunità dei professionisti del mondo elettrico

Reset contatore cicli ricarica batteria DJI mini.

Tecniche per la costruzione e la riparazione di apparecchiature elettriche e non. Ricerca guasti. Adattamenti e riutilizzazioni
0
voti

[11] Re: Reset contatore cicli ricarica batteria DJI mini.

Messaggioda Foto Utentevince59 » 2 giu 2025, 9:34

I2C con i comandi "standard" che ho trovato qui.
https://sbs-forum.org/specs/sbdat110.pdf
Avatar utente
Foto Utentevince59
664 2 3 6
Sostenitore
Sostenitore
 
Messaggi: 1062
Iscritto il: 17 giu 2019, 19:32

0
voti

[12] Re: Reset contatore cicli ricarica batteria DJI mini.

Messaggioda Foto Utentevince59 » 2 giu 2025, 15:28

...guarda qui. Mi è chiaro in senso generale ma nonsaprei come farlo in pratica. :?

To write to a smart battery, you'll need to use an I2C or SMBus interface and a compatible host device (like an Arduino or microcontroller) to send commands and data. The process involves setting up the I2C/SMBus connection, defining the target address, specifying the register address (or command), and then sending the data. You'll also need to account for the PEC (Packet Error Checking) byte if required by the specific protocol or device.
Here's a more detailed breakdown:

1. Establish the I2C/SMBus connection:
Hardware Setup: Connect the host device's SDA (Serial Data) and SCL (Serial Clock) lines to the smart battery's corresponding pins.

Software Setup: Configure the host device's I2C/SMBus library (like the Wire library on Arduino) to communicate at the appropriate speed and address.

2. Define the Target Address:

Smart Battery's Address: Smart batteries typically have an 7-bit address, and you'll need to find the correct address for your specific battery. The address might be 0x58 or 0x59 in some cases.

Host Device Configuration: Set the target address in the I2C/SMBus library configuration on the host device.

3. Specify the Register Address (or SMBus Command):

Registers: The smart battery has internal registers that store information like voltage, current, state of charge, etc. You'll need to find the specific register address you want to write to based on the smart battery's datasheet.

SMBus Commands: In SMBus, instead of register addresses, you might use SMBus commands to access the appropriate registers.

4. Send the Data:

Data Format: The data you send will depend on what you're trying to write (e.g., a new charge current limit, a new voltage target, etc.).

I2C/SMBus Write Function: Use the I2C/SMBus library's write function to send the data to the specified address and register.
PEC Byte (if required): Some SMBus protocols require a PEC byte for error checking. Ensure you calculate and include the PEC byte in your write operation if necessary.

Example (using a hypothetical scenario):
Let's say you want to set a new charge current limit for a smart battery with the address 0x58. You need to write the new current value to register address 0x02.

1. Setup:
Configure your I2C library on your Arduino (or other host device) for a 7-bit address of 0x58.
2. Write:
Use the I2C write function to send the following:
Target address: 0x58 (or 0x58 if you are using an 8-bit address and need to right-shift)
Register address: 0x02 (to write to the current register)
Data (new current value in the appropriate format)
PEC Byte (if required by your protocol)

Key Considerations:

Datasheet:
Always consult the smart battery's datasheet for specific instructions on register addresses, SMBus commands, and data formats.
Avatar utente
Foto Utentevince59
664 2 3 6
Sostenitore
Sostenitore
 
Messaggi: 1062
Iscritto il: 17 giu 2019, 19:32

0
voti

[13] Re: Reset contatore cicli ricarica batteria DJI mini.

Messaggioda Foto Utentetheking0 » 2 giu 2025, 17:38

Beh, io direi una cosa del genere:

Codice: Seleziona tutto
#include <Wire.h>

#define I2C_ADDRESS 0x58 
#define REG_CURRENT 0x02

void setup() {
  Wire.begin();     

  delay(100);     

  byte currentValue = 0x01;

  Wire.beginTransmission(I2C_ADDRESS);
  Wire.write(REG_CURRENT);           
  Wire.write(currentValue);         
  Wire.endTransmission();           
}

void loop() {}
Avatar utente
Foto Utentetheking0
1.442 1 6 11
Master
Master
 
Messaggi: 605
Iscritto il: 11 feb 2012, 22:37

0
voti

[14] Re: Reset contatore cicli ricarica batteria DJI mini.

Messaggioda Foto Utentevince59 » 2 giu 2025, 19:54

...studio.
Avatar utente
Foto Utentevince59
664 2 3 6
Sostenitore
Sostenitore
 
Messaggi: 1062
Iscritto il: 17 giu 2019, 19:32

Precedente

Torna a Costruzione, riparazione, riutilizzo

Chi c’è in linea

Visitano il forum: Nessuno e 11 ospiti