Setting and Monitoring a Low-pass Filter


The low-pass filter setup and monitoring command for encoder monitoring is "lpf".

The related commands are setting cut-off frequency, setting noise counter and monitoring noise counter.

Setting a cut-off frequency

The command to set a cut-off frequency of the low-pass filter is set freq.

"dc1 lpf set freq (frequency)"

Specify a cut-off frequency for frequency.

When a cut-off frequency of the low-pass filter is set, signals corresponding to frequencies higher than the cut-off frequency are not counted during encoder monitoring.

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

Setting a noise counter

The command to set a noise counter value of the low-pass filter is set pnc.

"dc1 lpf set pnc (value)"

Specify a noise counter value for value.

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

Monitoring noise counter values

The command to monitor noise counter values of the low-pass filter is 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);
}
?>