程序会不会 发表于 2020-8-22 18:21

AD7190如何进行校准

<p>初始化AD7190的时候想进行内部零电位和内部满量程校准,但是都不成功。</p>

<p>基本配置程序如下</p>

<p>void initAD7190()<br />
{<br />
&nbsp;&nbsp; &nbsp;u8 sendData={0,0,0,0};<br />
&nbsp;&nbsp; &nbsp;resetAD7190();&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//复位AD7190<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; <span style="background-color:#e74c3c;">&nbsp;</span><span style="color:#e74c3c;">//设置配置寄存器</span><br />
&nbsp;&nbsp; &nbsp;sendData = 0x00;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//斩波失能,外部基准在ref1+和ref1-之间<br />
&nbsp;&nbsp; &nbsp;sendData = 0x00;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/<span style="color:#e74c3c;"><span style="font-size:20px;">/初始选择通道0,在AIN1和AIN2之间</span></span>,<br />
&nbsp;&nbsp; &nbsp;sendData = 0x60;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//500nA电流源关闭,&nbsp;&nbsp; &nbsp;使能外部基准电压检测,使能输入缓冲器。<span style="font-size:20px;"><span style="color:#e74c3c;">双极性模式</span></span>,增益128&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;writeAd7190Register(0x10,sendData);//写AD7190配置寄存器<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; <span style="color:#e74c3c;">&nbsp;//通道0进行内部零电平校准</span><br />
&nbsp;&nbsp; &nbsp;sendData = 0x80;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//内部零电平校准&nbsp; <font color="#c0392b"><span style="font-size: 20px;">MD2 MD1 MD0=0b100是零电平校准模式</span></font><br />
&nbsp;&nbsp; &nbsp;sendData = 0x04;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//sinc4滤波器,禁止奇偶校准,REJ60=1,更好的50Hz抑制<br />
&nbsp;&nbsp; &nbsp;sendData = 0x10;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//,输出速率=50Hz &nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;writeAd7190Register(0x08,sendData);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//写AD7190模式寄存器<br />
&nbsp;&nbsp; &nbsp;while(RDY);&nbsp;&nbsp; &nbsp;//等待校准完成 处于空闲模式<br />
&nbsp;&nbsp; &nbsp;//通道0进行内部满量程校准<br />
&nbsp;&nbsp; &nbsp;sendData = 0xA0;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//内部满量程校准&nbsp;<font color="#c0392b"><span style="font-size:20px">MD2 MD1 MD0=0b101是满量程校准模式</span></font><br />
&nbsp;&nbsp; &nbsp;sendData = 0x04;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//sinc4滤波器,禁止奇偶校准,REJ60=1,更好的50Hz抑制<br />
&nbsp;&nbsp; &nbsp;sendData = 0x10;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//输出速率=50Hz &nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;writeAd7190Register(0x08,sendData);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//写AD7190模式寄存器<br />
&nbsp;&nbsp; &nbsp;delay(10000);&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:20px;"><span style="color:#c0392b;">在这边延时好像并没有起到作用</span></span><br />
&nbsp;&nbsp; &nbsp;while(RDY);&nbsp;&nbsp; &nbsp;//等待校准完成 处于空闲模式<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;/* 读出零电平校准值查看 */</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:20px;"><span style="color:#c0392b;">在这里读出的值还是初始值,说明校准不成功。。。。。</span></span><br />
&nbsp;&nbsp; &nbsp;readAD7190Reg(0x70);<br />
&nbsp;&nbsp; &nbsp;zeroScalVaule=(u32)spiRevArry&lt;&lt;16;<br />
&nbsp;&nbsp; &nbsp;zeroScalVaule|=(u16)spiRevArry&lt;&lt;8;<br />
&nbsp;&nbsp; &nbsp;zeroScalVaule|=spiRevArry;<br />
&nbsp;</p>

<p>/* 读出满量程校准值查看 */</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:20px;"><span style="color:#c0392b;">在这里读出的值还是初始值,说明校准不成功。。。。。</span></span></p>

<p>&nbsp;<br />
&nbsp;&nbsp; &nbsp;readAD7190Reg(0x78);<br />
&nbsp;&nbsp; &nbsp;fullScalVaule=(u32)spiRevArry&lt;&lt;16;<br />
&nbsp;&nbsp; &nbsp;fullScalVaule|=(u16)spiRevArry&lt;&lt;8;<br />
&nbsp;&nbsp; &nbsp;fullScalVaule|=spiRevArry;</p>

<p>&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; <span style="color:#e74c3c;">&nbsp;//切换到通道1</span></p>

<p><span style="color:#e74c3c;">&nbsp; &nbsp;<span style="font-size:20px;"> 这里将通道切换到通道1 ,对通道1进行校准</span></span><br />
&nbsp;&nbsp; &nbsp;sendData = 0x00;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//斩波失能,外部基准在ref1+和ref1-之间<br />
&nbsp;&nbsp; &nbsp;<span style="background-color:#e74c3c;">sendData = 0x01;</span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//<span style="color:#e74c3c;"><span style="font-size:20px;">初始选择选择通道1,在AIN3和AIN4之间,</span></span><br />
&nbsp;&nbsp; &nbsp;sendData = 0x60;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//500nA电流源关闭,&nbsp;&nbsp; &nbsp;使能外部基准电压检测,使能输入缓冲器。<span style="font-size:20px;"><span style="color:#e74c3c;">双极性模式</span></span>,增益128&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;writeAd7190Register(0x10,sendData);//写AD7190配置寄存器<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;//通道1进行内部零电平校准<br />
&nbsp;&nbsp; &nbsp;sendData = 0x80;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//内部零电平校准<br />
&nbsp;&nbsp; &nbsp;sendData = 0x04;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//sinc4滤波器,禁止奇偶校准,REJ60=1,更好的50Hz抑制,输出速率=300Hz&nbsp;<br />
&nbsp;&nbsp; &nbsp;sendData = 0x10;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;writeAd7190Register(0x08,sendData);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//写AD7190模式寄存器<br />
&nbsp;&nbsp; &nbsp;while(RDY);&nbsp;&nbsp; &nbsp;//等待校准完成 处于空闲模式<br />
&nbsp;&nbsp; &nbsp;//通道0进行内部满量程校准<br />
&nbsp;&nbsp; &nbsp;sendData = 0xA0;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//内部满量程校准<br />
&nbsp;&nbsp; &nbsp;sendData = 0x04;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//sinc4滤波器,禁止奇偶校准,REJ60=1,更好的50Hz抑制,输出速率=300Hz&nbsp;<br />
&nbsp;&nbsp; &nbsp;sendData = 0x10;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;writeAd7190Register(0x08,sendData);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//写AD7190模式寄存器<br />
&nbsp;&nbsp; &nbsp;while(RDY);&nbsp;&nbsp; &nbsp;//等待校准完成 处于空闲模式</p>

<p>&nbsp;</p>

<p>/* 读出零电平校准值查看 */</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:20px;"><span style="color:#c0392b;">在这里读出的值还是初始值,说明校准不成功。。。。。</span></span></p>

<p>&nbsp;&nbsp; &nbsp;readAD7190Reg(0x70);<br />
&nbsp;&nbsp; &nbsp;zeroScalVaule=(u32)spiRevArry&lt;&lt;16;<br />
&nbsp;&nbsp; &nbsp;zeroScalVaule|=(u16)spiRevArry&lt;&lt;8;<br />
&nbsp;&nbsp; &nbsp;zeroScalVaule|=spiRevArry;<br />
&nbsp;&nbsp; &nbsp;</p>

<p>/* 读出满量程校准值查看 */</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:20px;"><span style="color:#c0392b;">在这里读出的值还是初始值,说明校准不成功。。。。。</span></span></p>

<p>&nbsp;&nbsp; &nbsp;readAD7190Reg(0x78);<br />
&nbsp;&nbsp; &nbsp;fullScalVaule=(u32)spiRevArry&lt;&lt;16;<br />
&nbsp;&nbsp; &nbsp;fullScalVaule|=(u16)spiRevArry&lt;&lt;8;<br />
&nbsp;&nbsp; &nbsp;fullScalVaule|=spiRevArry;&nbsp;<br />
}</p>

<p><span style="font-size:20px;"><span style="color:#c0392b;">上面是AD7190的初始化程序,通信是正常的,程序上也没发现什么问题!是不是AD7190的校准有特定的步骤吗?谢谢!</span></span></p>
页: [1]
查看完整版本: AD7190如何进行校准