This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] BQ27441-G1:设置容量并显示正确的值

Guru**** 1135610 points
Other Parts Discussed in Thread: BQ27441-G1, BQSTUDIO
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/1334843/bq27441-g1-setting-capacity-and-displaying-correct-values

器件型号:BQ27441-G1
主题中讨论的其他器件: BQSTUDIO

您好!

我们将 bq27441-G1电量监测计 IC 用于电池监控系统。 以下是我们面临的问题。

  1. 设置电池容量时出现问题: 有时、我无法为我们的电池设置正确的容量。 默认使用1340 mA 您能解释一下如何正确更新参数吗? 如果需要延迟、正确的量是多少?
  2. 尽管电池电压有以下情况、但显示零值: 启动应用时、即使电池电压正常(约4伏)、电量计上的所有值都显示为0 mA (剩余电量、满可用容量)。 您认为这是因为我们是如何收集数据的、还是因为有关电量监测计如何学习的问题? 如果这是一个学习问题、您能否告诉我修复它的正确步骤?

 我已附上上述2个问题的日志。

注意:我们正在使用用于电量监测计的定制 PCB 板。

e2e.ti.com/.../1.-DesignCapacityWrite_5F00_issue.txte2e.ti.com/.../2.-Wrong_5F00_capacity_5F00_display.txt

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Ashish:  

    您如何尝试写入电池容量、您能向我提供您已采取的步骤吗? 是否使用 bqStudio 来读取和写入监测计? 您能为我提供相关的 gg 文件吗?  

    此致、  

    Jonny.  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    目前、我正在将该 IC 与我们的嵌入式 Linux 板 进行对接、我引用了 Spark fun 库、但会根据我的 Linux 板更改所有低级接口。 该 spark-fun 库遵循 bq27441-TRM 第14页中提到的所有步骤。

    注:我不在使用 bqStudio。

    以下是我为电量监测计设置编写的步骤。

    void config_gauge()
    {
      if (itporFlag())
      {
        setCapacity((uint16_t)bmsconfig.designCapacity);
        delay(2000);
        setDesignEnergy(bmsconfig.designCapacity * 3.7f);
        delay(2000);
        setTerminateVoltage(bmsconfig.terminalVoltage);
        delay(2000);
        setTaperRate(bmsconfig.designCapacity / (.01 * 100));
    
        printf("MY Desired Full Design_capacity: %d mAh\n", bmsconfig.designCapacity);
        printf("MYFull Design_capacity: %d mAh\n", capacity(DESIGN));
      }
    }

    以下是低级代码。

    int16_t i2cReadBytes(uint8_t subAddress, uint8_t *dest, uint8_t count)
    {
    	int16_t timeout = BQ72441_I2C_TIMEOUT;
    	I2cSendData(BQ72441_I2C_ADDRESS, &subAddress, 1);
    
    	I2cReadData(BQ72441_I2C_ADDRESS, dest, count);
    
    	return timeout;
    }
    
    void I2cSendData(uint8_t addr, uint8_t *data, uint8_t len)
    {
    	if (ioctl(deviceDescriptor, I2C_SLAVE, addr))
    		syslog(LOG_USER | LOG_INFO, "I2cSendData_device : IOCTL Problem \n");
    
    	write(deviceDescriptor, data, len);
    
    }
    
    /* This function reads data from the I2C device*/
    void I2cReadData(uint8_t addr, uint8_t *data, uint8_t len)
    {
    	if (ioctl(deviceDescriptor, I2C_SLAVE, addr))
    		syslog(LOG_USER | LOG_INFO, "I2cReadData_device : IOCTL Problem \n");
    
    	read(deviceDescriptor, data, len);
    }
    
    // // Write a specified number of bytes over I2C to a given subAddress
    uint16_t i2cWriteBytes(uint8_t subAddress, uint8_t *src, uint8_t count)
    {
    	uint8_t buf[3];
    	buf[0] = subAddress;
    	buf[1] = src[0];
    	buf[2] = src[1];
    
    	I2cSendData1(BQ72441_I2C_ADDRESS, buf, 3);
    	delay(1); //in ms
    
    	return true;
    }

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Ashish:  

    在尝试更改电量监测计中的每个参数之前、请确保您正在发送 SET_CFGUPDATE 子命令。 如果不这样做、则电量监测计将不允许您写入新值。  

    此致、  

    Jonny.  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Jonny、您好!

    在尝试修改每个参数之前、我已确保正确配置了 SET_CFGUPDATE 子命令。 此外、我已经验证了它是否成功更新了状态。

    以下代码供您参考。 请查看:

    _Bool setCapacity(uint16_t capacity)
    {
    	// Write to STATE subclass (82) of BQ27441 extended memory.
    	// Offset 0x0A (10)
    	// Design capacity is a 2-byte piece of data - MSB first
    	// Unit: mAh
    	uint8_t capMSB = capacity >> 8;
    	uint8_t capLSB = capacity & 0x00FF;
    	uint8_t capacityData[2] = {capMSB, capLSB};
    	return writeExtendedData(BQ27441_ID_STATE, 10, capacityData, 2);
    }
    
    _Bool writeExtendedData(uint8_t classID, uint8_t offset, uint8_t *data, uint8_t len)
    {
    	if (len > 32)
    		return false;
    
    	if (!_userConfigControl)
    		enterConfig(false);
    	printf("in write extended data\n");
    	if (!blockDataControl())	  // // enable block data memory control
    		return false;			  // Return false if enable fails
    	if (!blockDataClass(classID)) // Write class ID using DataBlockClass()
    		return false;
    
    	blockDataOffset(offset / 32); // Write 32-bit block offset (usually 0)
    	computeBlockChecksum();		  // Compute checksum going in
    	uint8_t oldCsum = blockDataChecksum();
    	printf("after checksum data\n");
    	//  Write data bytes:
    	for (int i = 0; i < len; i++)
    	{
    		// Write to offset, mod 32 if offset is greater than 32
    		// The blockDataOffset above sets the 32-bit block
    		writeBlockData((offset % 32) + i, data[i]);
    	}
    	printf("wroteblock data\n");
    	// Write new checksum using BlockDataChecksum (0x60)
    	uint8_t newCsum = computeBlockChecksum(); // Compute the new checksum
    	writeBlockChecksum(newCsum);
    
    	if (!_userConfigControl)
    		exitConfig(true);
    
    	return true;
    }
    _Bool enterConfig(_Bool userControl)
    {
    	if (userControl)
    		_userConfigControl = true;
    
    	if (sealed())
    	{
    		_sealFlag = true;
    		printf("doing unseal\n");
    		unseal(); // Must be unsealed before making changes
    	}
    	printf("Now in execute control word\n");
    	if (executeControlWord(BQ27441_CONTROL_SET_CFGUPDATE))
    	{
    		int16_t timeout = BQ72441_I2C_TIMEOUT;
    		while ((timeout--) && (!(flags() & BQ27441_FLAG_CFGUPMODE)))
    		{
    			printf("in while loop\n");
    			delay1(1);
    		}
    
    		if (timeout > 0)
    			return true;
    	}
    	printf("timeout occured\n");
    	return false;
    }
    
    
    
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Ashish:  

    我建议遵循 监测计通信 应用报告中的示例。  

    此致、  

    Jonny.