getFilterPNC()


Описание

This function gets the noise counter value of the low-pass filter.

Синтаксис

dcmotor.getFilterPNC()

Параметры

none

Возврат значений

the current noise counter value of the low-pass filter

Пример

#include <PhpocExpansion.h>
#include <Phpoc.h>

byte spcId = 1;

int freq = 1000;
int count_prev = 0;
int count;
int diff;

ExpansionDCMotor dcmotor(spcId, 1);

void setup() {
    Serial.begin(9600);
    while(!Serial)
        ;

    Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
    Expansion.begin();

    Serial.println(dcmotor.getPID());
    Serial.println(dcmotor.getName());

    dcmotor.setPeriod(10000);
    dcmotor.setWidth(3000);
}

void loop() {
    if(freq > 7000) {
        dcmotor.setWidth(0);
        return;
    }
    dcmotor.setFilterFrequency(freq);

    // set the noise counter value
    count = dcmotor.getFilterPNC();
    diff = count - count_prev;
    Serial.print("noise count at freq");
    Serial.print(freq);
    Serial.print(" : ");
    Serial.println(diff);

    freq += 200;
    count_prev = count;
    delay(200); 
}