Other Parts Discussed in Thread: UCD3028
您好,我最近在学习您们的《 UCD3028 数字电源软件设计说明》文档,有些问题不太懂,想向您们请教。
有疑惑的章节如下:
“ 2.4 GUI 软件显示值的转换与实现
1 、显示值算法如下: Io=Io × R15 × 331 × (4096/2.5) × (0.25 × K × 1/216) × 0.25 ,由此可计算出K=15711,因此有如下代码:
#define IOUT_ADC_TO_LITERAL_SCALER_NOMINAL (15711)
2、函数的具体实现
在函数 pmbus_read_iout_handler()中调用函数 unsigned_short_q_multiply(),并完成数据格式的转换,
如下所示:
temporary = unsigned_short_q_multiply(iout >> 2, K);
pmbus_number_of_bytes = 2;
pmbus_buffer[1] = ((temporary & 0x700) >> 8) + 0x F0;
pmbus_buffer[0] = temporary & 0xff;
而函数 unsigned_short_q_multiply()完成两个输入值的乘积计算并对结果进行转换,如下所示:
product = ((unsigned int) multiplier) * ((unsigned int) multiplicand);
return (signed short)((product + 0x8000) >> 16); //8000 is for rounding”
问题如下:
Q1:显示值算法如下: Io=Io × R15 × 331 × (4096/2.5) × (0.25 × K × 1/216) × 0.25,这个公式的前半部分“Io × R15 × 331 × (4096/2.5)”我能理解,是和调理电路与采样量化有关,但公式的后半部分“ × (0.25 × K × 1/216) × 0.25”,我就不懂了。不知道这些系数是怎么来的,与什么相关,0.25、1/216、0.25这些系数是怎么来的?
Q2:temporary = unsigned_short_q_multiply(iout >> 2, K);
而函数 unsigned_short_q_multiply()完成两个输入值的乘积计算并对结果进行转换,如下所示:
product = ((unsigned int) multiplier) * ((unsigned int) multiplicand);
return (signed short)((product + 0x8000) >> 16); //8000 is for rounding”
那么,temporary=(iout/4*K+2e15)/2e16,是这样理解的吧?可是这个temporary 的值是什么意思,感觉和前面的公式对应不上。
这个GUI转换让我很糊涂,麻烦您们指点一二,谢谢!