设定和监控低通滤波器


为了进行编辑器监控的低通滤波器设定及监控的命令是"lpf"。 相关命令有截止频率,设置噪声计数器和监控噪声计数器。

设定截止频率

设定低通滤波器截止频率的命令是set freq

"dc1 lpf set freq (frequency)"

frequency上指定低通滤波器。

设定了低通滤波器截止频率时,在进行编辑器监控时,比相应频率高的信号将不被计算。

spc_request_dev($sid, "dc1 lpf freq 5000");

设置噪声计数器

设定低通滤波器噪声计数命令的是set pnc

"dc1 lpf set pnc (value)"

value上指定噪声计数值。

spc_request_dev($sid, "dc1 lpf set pnc 0");

监控噪声计数器

监控低通滤波器噪声计数器命令是get pnc

"dc1 lpf get pnc"


<?php
include "/lib/sd_spc.php";
spc_reset();
spc_sync_baud(115200);
$sid = 1;

spc_request_dev($sid, "dc1 pwm set period 10000");
spc_request_dev($sid, "dc1 pwm set width 1000");

$freq = 1000;
$count_prev = 0;

while(1)
{
    if($freq > 7000)
    {
        spc_request_dev($sid, "dc1 pwm set width 0");
        break;
    }
    spc_request_dev($sid, "dc1 lpf set freq $freq");
    $count = (int)spc_request_dev($sid, "dc1 lpf get pnc");
    $diff = $count - $count_prev;
    echo "noise count at freq $freq: $diff\r\n";

    $freq += 200;
    $count_prev = $count;
    usleep(200000);
}
?>