计算DAC输出为十进制值

时间:2018-09-19 07:46:39

标签: arm microcontroller keil 8051

我对以十进制值计算DAC输出的方法感到困惑。我正在使用DAC7741。我需要估计的电压称为Vint。以下代码是我引用的示例。但是我不知道为什么电压= DAC_buf * 3052?我检查了DAC7741数据表,但没有看到3052的任何线索。请向我解释如何获得该公式。谢谢!

                unsigned long DAC_buf   =0x0000; 
                unsigned char idata Vint_H              _at_ 0xB3;
                unsigned char idata Vint_L              _at_ 0xB4;

                DAC_buf += Vint_H;
                DAC_buf = DAC_buf << 8;
                DAC_buf += Vint_L;

                if(Vint_H<0x80)
                {   
                    DAC_buf = 0x8000-DAC_buf;
                    voltage = DAC_buf *3052;
                    voltage_ten_thousand = (voltage%100000000)/10000000;
                    voltage_thousand = (voltage%10000000)/1000000;
                    voltage_hundred = (voltage%1000000)/100000 ;
                    voltage_ten = (voltage%100000)/10000 ;
                    voltage_unit = (voltage%10000)/1000;
                }
                else
                {
                    DAC_buf = DAC_buf- 0x8000;
                    voltage = DAC_buf *3052;
                    voltage_ten_thousand = (voltage%100000000)/10000000;
                    voltage_thousand =     (voltage%10000000)/1000000;
                    voltage_hundred =      (voltage%1000000)/100000 ;
                    voltage_ten =          (voltage%100000)/10000 ;
                    voltage_unit =         (voltage%10000)/1000;
                }  

我需要从功率IC(LTC2606)计算出另一个电压。

voltage = 13050- OVSS_buf*100;   // OVSS_buf is the hex value assigned to the                      power IC

我经过多次尝试和错误后得到了该公式。即使我将正确的结果显示在监视器上,我仍然不知道如何获取正确的公式。我检查了LTC2606的Vout =(k / 2 ^ 16)* Vcc的公式。 Vcc = 3V

如果有人能向我解释上面提到的两种电压的计算方法,我将不胜感激。

0 个答案:

没有答案